huff.lambda {MCI}R Documentation

Fitting the distance parameter lambda in the Huff model

Description

This function estimates a distance decay parameter from observed total store/location data (e.g. complete annual turnovers) using bisection or "trial and error"

Usage

huff.lambda(huffdataset, origins, locations, attrac, dist, gamma = 1, atype = "pow", 
gamma2 = NULL, lambda_startv = -1, lambda_endv = -3, dtype = "pow", 
localmarket_dataset, origin_id, localmarket, 
location_dataset, location_id, location_total, 
method = "bisection", iterations = 10, output = "matrix", 
plotVal = FALSE, 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)

gamma

a single numeric value of \gamma for the exponential weighting of the attraction variable (default: 1)

atype

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

gamma2

if atype = "logistic" a second \gamma parameter is needed

lambda_startv

Start value for \lambda search

lambda_endv

End value for \lambda search

dtype

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

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)

method

If method = "bisection" (default value), the optimal \lambda is found by bisection. If method = "compare", several values are tried and the best one is found ("trial and error")

iterations

a single numeric value for the desired number of iterations

output

If output = "iterations", the results for every single iteration is shown. If output = "total", total sales and market shares (or total market area) of the suppliers are shown.

plotVal

If plotVal = TRUE, the function shows a simple plot of \lambda values against residuals

show_proc

logical argument that indicates if the function prints messages about the state of process during the work (e.g. “Processing variable xyz ...”). 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 (e.g. annual turnover) can be used for market area estimation. This function fits the Huff model by estimating the \lambda parameter iteratively using an optimization algorithm based on the idea of Klein (1988). The fitting process in the huff.lambda includes of given number of iterations, while the fit gets better with every iteration, measured using the sum of squared residuals of observed vs. expected total values. The iterative optimization can be done via bisection (see Kaw et al. 2011, ch. 03.03) or "trial and error" (see Fuelop et al. 2011).

Value

The function output can be controlled by the function argument output. If output = "iterations", the results for every single iteration is shown (data.frame). If output = "total", total sales and market shares (or total market area) of the suppliers are shown (data.frame). The default output is a list with \gamma and \lambda.

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

Fuelop, G./Kopetsch, T./Schoepe, P. (2011): “Catchment areas of medical practices and the role played by geographical distance in the patient's choice of doctor”. In: The Annals of Regional Science, 46, 3, p. 691-706.

Kaw, A. K./Kalu, E. E./Nguyen, D. (2011): “Numerical Methods with Applications”. http://nm.mathforcollege.com/topics/textbook_index.html

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

See Also

huff.attrac, huff.shares, huff.decay, huff.fit

Examples

data(DIY1)
data(DIY2)
data(DIY3)
# Loading the three DIY store datasets

DIY_alldata <- merge (DIY1, DIY2, by.x = "j_destination", by.y = "j_destination")
# Add store data to distance matrix

huff_DIY <- huff.shares (DIY_alldata, "i_origin", "j_destination", "A_j_salesarea_sqm", 
"t_ij_min", gamma = 1, lambda = -2)
# Calculating Huff local market shares
# Gamma = 1, Lambda = -2

huff_DIY <- merge (huff_DIY, DIY3, by.x = "i_origin", by.y = "district")
# Add data for origins

huff_DIY_total <- shares.total (huff_DIY, "i_origin", "j_destination", "p_ij", 
"population")
# Calculating total market areas (=sums of customers)

colnames(DIY3) <- c("district", "pop")
# Change column name to "pop" (must be other name)

huff.lambda (huff_DIY, "i_origin", "j_destination", "A_j_salesarea_sqm", 
"t_ij_min", gamma = 1, atype = "pow", gamma2 = NULL,
lambda_startv = -1, lambda_endv = -2.5, dtype= "pow",
DIY3, "district", "pop", huff_DIY_total, "suppliers_single", "sum_E_j", 
method = "bisection", iterations = 10)
# Iterative search for the best lambda value using bisection
# Output: gamma and lambda

huff.lambda (huff_DIY, "i_origin", "j_destination", "A_j_salesarea_sqm", 
"t_ij_min", gamma = 1, atype = "pow", gamma2 = NULL,
lambda_startv = -1, lambda_endv = -2.5, dtype= "pow",
DIY3, "district", "pop", huff_DIY_total, "suppliers_single", "sum_E_j", 
method = "bisection", iterations = 10, output = "iterations", show_proc = TRUE)
# Same procedure, output: single iterations  

huff.lambda (huff_DIY, "i_origin", "j_destination", "A_j_salesarea_sqm", 
"t_ij_min", gamma = 1, atype = "pow", gamma2 = NULL,
lambda_startv = -1, lambda_endv = -2.5, dtype= "pow",
DIY3, "district", "pop", huff_DIY_total, "suppliers_single", "sum_E_j", 
method = "compare", iterations = 10, output = "iterations", show_proc = TRUE, plotVal = TRUE)
# Using compare method, output: single iterations and plot 

[Package MCI version 1.3.3 Index]