# NOT RUN {
# Controlling the fit of a Huff Model market area estimation #
data(Freiburg1)
data(Freiburg2)
data(Freiburg3)
# Loads the data
huff_mat <- huff.shares (Freiburg1, "district", "store", "salesarea", "distance")
# Market area estimation using the Huff Model with standard parameters
# (gamma = 1, lambda = -2)
huff_mat_pp <- merge (huff_mat, Freiburg2)
# Adding the purchasing power data for the city districts
huff_total <- shares.total (huff_mat_pp, "district", "store", "p_ij", "ppower")
# Total expected sales and shares
huff_total_control <- merge (huff_total, Freiburg3, by.x = "suppliers_single",
by.y = "store")
model.fit(huff_total_control$annualsales, huff_total_control$sum_E_j, plotVal = TRUE)
# Observed vs. expected
# Results can be adressed directly:
huff_fit <- model.fit(huff_total_control$annualsales, huff_total_control$sum_E_j, plotVal = TRUE)
huff_fit$mape
# }
Run the code above in your browser using DataLab