huff.fit: Fitting the Huff model using local optimization of...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This function fits the Huff model with a given interaction matrix by optimizing the attractivity values of suppliers/locations iteratively and calculates the market shares/market areas

Usage

1
2
3
4
huff.fit(huffdataset, origins, locations, attrac, dist, lambda = -2, dtype = "pow", 
lambda2 = NULL, localmarket_dataset, origin_id, localmarket, location_dataset, 
location_id, location_total, tolerance = 5, iterations = 3, output = "total", 
show_proc = FALSE, check_df = TRUE)

Arguments

huffdataset

an interaction matrix which is a data.frame containing the origins, locations and the explanatory variables (attraction, transport costs)

origins

the column in the interaction matrix huffdataset containing the origins (e.g. ZIP codes)

locations

the column in the interaction matrix huffdataset containing the locations (e.g. store codes)

attrac

the column in the interaction matrix huffdataset containing the attraction variable (e.g. sales area)

dist

the column in the interaction matrix huffdataset containing the transport costs (e.g. travelling time or street distance)

lambda

a single numeric value of λ for the (exponential) weighting of distance (transport costs, default: -2)

dtype

Type of distance weighting function: "pow" (power function), "exp" (exponential function) or "logistic" (logistic function) (default: dtype = "pow")

lambda2

if dtype = "logistic" a second λ parameter is needed

localmarket_dataset

A data.frame containing the origins saved in a column which has the same name as in huffdataset and another column containing the local market potential

origin_id

the column in the dataset localmarket_dataset containing the origins (e.g. statistical districts, ZIP codes)

localmarket

the column in the dataset localmarket_dataset containing the local market potential (e.g. purchasing power, number of customers)

location_dataset

A data.frame containing the suppliers/locations and their observed total values

location_id

the column in the dataset location_dataset containing the locations (e.g. store codes), j, according to the codes in huffdataset

location_total

the column in the dataset location_dataset containing the observed total values of suppliers/locations, T_{j,obs} (e.g. annual sales, total number of customers)

tolerance

accepted value of absolute percentage error between observed (T_{j,obs}) and modeled total values (T_{j,exp}) to skip a local optimization of location/supplier j

iterations

a single numeric value for the desired number of iterations

output

Type of function output: output = "matrix" returns a Huff interaction matrix with the optimized attractivity values and the expected market shares/market areas. If output = "total", the old (observed) and the new (expected) total values are returned. If output = "diag", the function returns the diagnosis results (fitting measures)

show_proc

logical argument that indicates if the function prints messages about the state of process during the work (e.g. “Processing variable xyz ...” or “Variable xyz is regarded as dummy variable”). Default: show_proc = FALSE (messages off)

check_df

logical argument that indicates if the given dataset is checked for correct input, only for internal use, should not be deselected (default: TRUE)

Details

In many cases, only total empirical values of the suppliers/locations can be used for market area estimation. This function fits the Huff model not by estimating the parameters but by optimizing the attraction variable (transport cost weighting by λ is given) using an optimization algorithm based on the idea of the local optimization of attraction algorithm developed by Guessefeldt (2002) and other model fit approaches. The fitting process in the huff.fit includes of given number of (m) iterations, while the fit gets better with every iteration. The algorithm results can be evaluated by several diagnosis criteria which have been frequently used to evaluate Huff model results: Besides the sum of squared residuals, the function also calculates a Pseudo-R-squared measure and the MAPE (mean average percentage error), both used by De Beule et al. (2014), and the global error used by Klein (1988).

Value

The function output can be controlled by the function argument output. If output = "matrix" the function returns a Huff interaction matrix with the optimized attractivity values and the expected market shares/market areas. If output = "total", the old (observed) and the new (expected) total values are returned. If output = "diag", the diagnosis results (fitting measures) are returned. All results are data.frame.

Note

Note that the iterations can be time-consuming and depend on the number of suppliers/locations. Use show_proc = TRUE for monitoring the iteration process.

Author(s)

Thomas Wieland

References

De Beule, M./Van den Poel, D./Van de Weghe, N. (2014): “An extended Huff-model for robustly benchmarking and predicting retail network performance”. In: Applied Geography, 46, 1, p. 80-89.

Guessefeldt, J. (2002): “Zur Modellierung von raeumlichen Kaufkraftstroemen in unvollkommenen Maerkten”. In: Erdkunde, 56, 4, p. 351-370.

Klein, R. (1988): “Der Lebensmittel-Einzelhandel im Raum Verden. Raeumliches Einkaufsverhalten unter sich wandelnden Bedingungen”. Flensburger Arbeitspapiere zur Landeskunde und Raumordnung, 6. Flensburg.

Wieland, T. (2015): “Nahversorgung im Kontext raumoekonomischer Entwicklungen im Lebensmitteleinzelhandel - Konzeption und Durchfuehrung einer GIS-gestuetzten Analyse der Strukturen des Lebensmitteleinzelhandels und der Nahversorgung in Freiburg im Breisgau”. Projektbericht. Goettingen : GOEDOC, Dokumenten- und Publikationsserver der Georg-August-Universitaet Goettingen. http://webdoc.sub.gwdg.de/pub/mon/2015/5-wieland.pdf

See Also

huff.attrac, huff.shares, huff.decay

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(Freiburg1)
data(Freiburg2)
data(Freiburg3)
# Loading the three Freiburg datasets

# NOTE: This may take a while!
# huff_total_opt2 <- huff.fit(Freiburg1, "district", "store", "salesarea", "distance", 
# lambda = -2, dtype= "pow", lambda2 = NULL, Freiburg2, "district", "ppower", 
# Freiburg3, "store", "annualsales", tolerance = 1, iterations = 2, output = "total", 
# show_proc = TRUE)
# 2 iterations of the optimization algorithm with an accepted difference of +/- 1 %
# Output of total sales/shares, stored in dataset huff_total_opt10

# model.fit(huff_total_opt2$total_obs, huff_total_opt2$sum_E_j, plotVal = TRUE)
# total_obs = observed total values, originally from dataset Freiburg3
# sum_E_j = expected total values

Example output



MCI documentation built on May 2, 2019, 6:02 a.m.