# Example from Levy/Weitz (2009):
# Data for the existing and the new location
locations <- c("Existing Store", "New Store")
S_j <- c(5000, 10000)
location_data <- data.frame(locations, S_j)
# Data for the two communities (Rock Creek and Oak Hammock)
communities <- c("Rock Creek", "Oak Hammock")
C_i <- c(5000000, 3000000)
community_data <- data.frame(communities, C_i)
# Combining location and submarket data in the interaction matrix
interactionmatrix <- merge (community_data, location_data)
# Adding driving time:
interactionmatrix[1,5] <- 10
interactionmatrix[2,5] <- 5
interactionmatrix[3,5] <- 5
interactionmatrix[4,5] <- 15
colnames(interactionmatrix) <- c("communities", "C_i", "locations", "S_j", "d_ij")
shoppingcenters1 <- interactionmatrix
save(shoppingcenters1, file="shoppingcenters1.rda")
huff_shares <- huff(shoppingcenters1, "communities", "locations", "S_j", "d_ij")
# Market shares of the new location:
huff_shares[huff_shares$locations == "New Store",]
# Hansen accessibility for Oak Hammock and Rock Creek:
hansen (huff_shares, "communities", "locations", "S_j", "d_ij")
# Example from Berman/Evans (2012):
locations <- c(1, 2, 3)
S_j <- c(200, 300, 500)
location_data <- data.frame(locations, S_j)
d_ij <- c(7, 10, 15)
interactionmatrix <- data.frame(location_data, d_ij)
interactionmatrix$cgroup <- 1
shoppingcenters2 <- interactionmatrix
huff (shoppingcenters2, "cgroup", "locations", "S_j", "d_ij")
Run the code above in your browser using DataLab