Description Usage Arguments Details Value Note Author(s) References See Also Examples
This function fits the Huff Model using a local optimization of attraction algorithm
1 2 | huff.optim(huffmodel, location.dataset, location.id, location.total,
tolerance = 5, iterations = 3, show_proc = TRUE)
|
huffmodel |
Object ( |
location.dataset |
A |
location.id |
Name of the column in |
location.total |
Name of the column in |
tolerance |
Accepted value of absolute percentage error between observed (T_{j,obs}) and estimated total values (T_{j,exp}) to skip a local optimization of location j |
iterations |
a single numeric value for the desired number of iterations |
show_proc |
logical argument that indicates if the function prints messages about the state of process during the work |
In many cases, only total empirical market areas (e.g. annual turnover) of the destinations/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 introduced and explained in Wieland (2017a) and Wieland (2017b).
A huffmodel list
(invisible) containing the following components:
huffmat |
Huff interaction matrix ( |
hufftotal |
Total location market areas ( |
diag |
A |
params |
A |
coords |
A |
tc.mode |
A |
The function is a wrapper of huff.attrac
from the MCI package. For further information see the MCI documentation and the corresponding RJ paper (Wieland 2017).
Thomas Wieland
Wieland, T. (2017a): “Market Area Analysis for Retail and Service Locations with MCI”. In: The R Journal, 9, 1, p. 298-323. https://journal.r-project.org/archive/2017/RJ-2017-020/RJ-2017-020.pdf.
Wieland, T. (2017b): “Raum- und standortoekonomische Optimierungsmodelle in Open-Source-Umgebungen - Implementation und Anwendungsmoeglichkeiten im Kontext der Einzelhandels- und Versorgungsforschung”. In: Schrenk, M./Popovich, V./Zeile, P./Elisei, P./Beyer, C. (eds.): REAL CORP 2017. PANTA RHEI - A World in Constant Motion. Proceedings of 22nd International Conference on Urban Planning, Regional Development and Information Society. p. 463-473. https://programm.corp.at/cdrom2017/papers2017/CORP2017_98.pdf.
huff
, huff.newdest
, huff.updest
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # Compilation of tcmat list from existing datasets:
# (Results from the tcmat.create function)
data(Haslach_tcmatAirline)
# airline distances
data(Haslach_coords_origins)
# Coordinates of origins
data(Haslach_coords_destinations)
# Coordinates of destinationes
# Component "tc.mode":
Airline_tc.mode <- list()
Airline_tc.mode$tc.type = "airline"
Airline_tc.mode$tc.unit = "km"
Airline_tc.mode$tc.constant = 0
# tcmat with airline distances
# Compilation as a list:
tcmat_haslach_airline <- list(tcmat = Haslach_tcmatAirline,
coords_origins = Haslach_coords_origins,
coords_destinations = Haslach_coords_destinations,
tc.mode = Airline_tc.mode)
Drvtime_tc.mode <- list()
Drvtime_tc.mode$tc.type = "street"
Drvtime_tc.mode$tc.unit = "min"
Drvtime_tc.mode$tc.constant = 0
data(Haslach_tcmatDrvtime)
# car driving times
# tcmat with car driving times
# Compilation as a list:
tcmat_haslach_drvtime <- list(tcmat = Haslach_tcmatDrvtime,
coords_origins = Haslach_coords_origins,
coords_destinations = Haslach_coords_destinations,
tc.mode = Drvtime_tc.mode)
data(HaslachDistricts)
# IDs and information about customer origins
data(HaslachStores)
# IDs and information about destinations (grocery stores)
huffmodel1 <- huff (HaslachDistricts$WO, HaslachDistricts$WO_Einwohner,
HaslachStores$LM, HaslachStores$LM_VKF,
tcmat = tcmat_haslach_airline)
# Huff Model with standard parameters
# uses given transport costs matrix (tcmat_haslach_airline)
huffmod_total <- huffmodel1$hufftotal
# Total values from the Huff Model
huff.optim(huffmodel1, location.dataset = huffmod_total,
location.id = "j_dest", location.total = "T_j")
# Using calculated total market areas for optimization
# now adding random errors:
rnderr <- runif(8, min=-1000, max=1500)
huffmod_total2 <- huffmod_total
huffmod_total2$T_j <- huffmod_total2$T_j+rnderr
# New optimization:
# now saving as huffmodel list object
huffmodel_opt <- huff.optim(huffmodel1, location.dataset = huffmod_total2,
location.id = "j_dest", location.total = "T_j")
huffmodel_opt
# complete huffmodel list object
huffmodel_opt$huffmat
# local market shares
|
Huff Model
Attraction function: pow
Transport costs function: pow
Total results
j_dest T_j T_j_share
1 LM01 3099.119 0.15707648
2 LM02 1560.078 0.07907138
3 LM03 2029.496 0.10286348
4 LM04 2315.850 0.11737708
5 LM05 2128.933 0.10790335
6 LM06 1104.456 0.05597850
7 LM07 4292.602 0.21756727
8 LM08 3199.465 0.16216245
Attraction min.: 500, max.: 8900, mean: 1955.5
Transport cost min.: 0.18, max.: 2.02, mean: 1.02
Iteration 1 of 3 ...
Processing location LM01 ...
Processing location LM02 ...
Processing location LM03 ...
Processing location LM04 ...
Processing location LM05 ...
Processing location LM06 ...
Processing location LM07 ...
Processing location LM08 ...
Iteration 2 of 3 ...
Processing location LM01 ...
Processing location LM02 ...
Processing location LM03 ...
Processing location LM04 ...
Processing location LM05 ...
Processing location LM06 ...
Processing location LM07 ...
Processing location LM08 ...
Iteration 3 of 3 ...
Processing location LM01 ...
Processing location LM02 ...
Processing location LM03 ...
Processing location LM04 ...
Processing location LM05 ...
Processing location LM06 ...
Processing location LM07 ...
Processing location LM08 ...
$huffmat
ij i_orig C_i j_dest A_j d_ij U_ij sum_U_ij p_ij
1 SB611-LM01 SB611 6761 LM01 748 1.0186008 720.9308 17341.05 0.041573654
5 SB611-LM02 SB611 6761 LM02 900 1.7047910 309.6708 17341.05 0.017857671
9 SB611-LM03 SB611 6761 LM03 694 0.5514531 2282.1402 17341.05 0.131603351
13 SB611-LM04 SB611 6761 LM04 2170 1.3846319 1131.8557 17341.05 0.065270311
17 SB611-LM05 SB611 6761 LM05 750 0.5627798 2368.0144 17341.05 0.136555424
21 SB611-LM06 SB611 6761 LM06 982 1.4113274 493.0103 17341.05 0.028430243
25 SB611-LM07 SB611 6761 LM07 8900 2.0170833 2187.4712 17341.05 0.126144106
29 SB611-LM08 SB611 6761 LM08 500 0.2524101 7847.9562 17341.05 0.452565239
2 SB612-LM01 SB612 8016 LM01 748 0.2868160 9092.7422 26735.34 0.340101976
6 SB612-LM02 SB612 8016 LM02 900 1.2178480 606.8150 26735.34 0.022697112
10 SB612-LM03 SB612 8016 LM03 694 0.4397744 3588.3893 26735.34 0.134218947
14 SB612-LM04 SB612 8016 LM04 2170 0.8815306 2792.4472 26735.34 0.104447788
18 SB612-LM05 SB612 8016 LM05 750 0.4451331 3785.1354 26735.34 0.141577976
22 SB612-LM06 SB612 8016 LM06 982 0.6857878 2088.0071 26735.34 0.078099139
26 SB612-LM07 SB612 8016 LM07 8900 1.4273096 4368.7144 26735.34 0.163405974
30 SB612-LM08 SB612 8016 LM08 500 1.1001771 413.0901 26735.34 0.015451088
3 SB613-LM01 SB613 1114 LM01 748 0.4382241 3895.0140 76775.73 0.050732363
7 SB613-LM02 SB613 1114 LM02 900 1.8337781 267.6387 76775.73 0.003485981
11 SB613-LM03 SB613 1114 LM03 694 1.1108366 562.4179 76775.73 0.007325465
15 SB613-LM04 SB613 1114 LM04 2170 0.1783452 68223.9476 76775.73 0.888613509
19 SB613-LM05 SB613 1114 LM05 750 1.1217139 596.0697 76775.73 0.007763778
23 SB613-LM06 SB613 1114 LM06 982 1.2093575 671.4321 76775.73 0.008745370
27 SB613-LM07 SB613 1114 LM07 8900 1.9550341 2328.5273 76775.73 0.030328952
31 SB613-LM08 SB613 1114 LM08 500 1.4722479 230.6790 76775.73 0.003004583
4 SB614-LM01 SB614 3839 LM01 748 1.2488959 479.5668 52204.59 0.009186297
8 SB614-LM02 SB614 3839 LM02 900 0.2297791 17045.9631 52204.59 0.326522325
12 SB614-LM03 SB614 3839 LM03 694 0.9574969 756.9805 52204.59 0.014500268
16 SB614-LM04 SB614 3839 LM04 2170 1.8350540 644.4096 52204.59 0.012343928
20 SB614-LM05 SB614 3839 LM05 750 0.9420755 845.0645 52204.59 0.016187553
24 SB614-LM06 SB614 3839 LM06 982 0.5110920 3759.3551 52204.59 0.072011968
28 SB614-LM07 SB614 3839 LM07 8900 0.5587846 28503.6931 52204.59 0.545999781
32 SB614-LM08 SB614 3839 LM08 500 1.7172382 169.5543 52204.59 0.003247882
$hufftotal
j_dest T_j T_j_share T_j_obs T_j_diff A_opt
1 LM01 3099.119 0.15707648 3099.119 0 748
2 LM02 1560.078 0.07907138 1560.078 0 900
3 LM03 2029.496 0.10286348 2029.496 0 694
4 LM04 2315.850 0.11737708 2315.850 0 2170
5 LM05 2128.933 0.10790335 2128.933 0 750
6 LM06 1104.456 0.05597850 1104.456 0 982
7 LM07 4292.602 0.21756727 4292.602 0 8900
8 LM08 3199.465 0.16216245 3199.465 0 500
$diag
iterations_count resids_sq_sum pseudorsq globerr mape
1 1 0 1 0 0
2 2 0 1 0 0
3 3 0 1 0 0
$params
param1 param2
pow 1 NA
pow -2 NA
$coords
$coords$coords_origins
origins.id origins.pot origins.addr origins.x_lon
1 SB611 6761 Markgrafenstraße 68, Freiburg, Germany 7.822323
2 SB612 8016 Belchenstraße 10, Freiburg, Germany 7.816491
3 SB613 1114 Schopfheimer Straße 4, Freiburg, Germany 7.822583
4 SB614 3839 Christaweg 8, Freiburg, Germany 7.803482
origins.y_lat
1 47.99389
2 47.98718
3 47.98211
4 47.98978
$coords$coords_destinations
destinations.id destinations.attrac
1 LM01 748
2 LM02 900
3 LM03 694
4 LM04 2170
5 LM05 750
6 LM06 982
7 LM07 8900
8 LM08 500
destinations.addr destinations.x_lon
1 Basler Straße 113, Freiburg, Germany 7.818690
2 Heckerstraße 4, Freiburg, Germany 7.800468
3 Carl-Kistner-Straße 32-34, Freiburg, Germany 7.816177
4 Lörracher Straße 8, Freiburg, Germany 7.824830
5 Carl-Kistner-Straße 2, Freiburg, Germany 7.815958
6 Bettackerstraße 23, Freiburg, Germany 7.807447
7 St. Georgener Straße 2, Freiburg, Germany 7.797338
8 Markgrafenstraße 95, Freiburg, Germany 7.825045
destinations.y_lat
1 47.98506
2 47.98934
3 47.99112
4 47.98156
5 47.99116
6 47.98604
7 47.98690
8 47.99524
$tc.mode
$tc.mode$tc.type
[1] "airline"
$tc.mode$tc.unit
[1] "km"
$tc.mode$tc.constant
[1] 0
Iteration 1 of 3 ...
Processing location LM01 ...
Processing location LM02 ...
Processing location LM03 ...
Processing location LM04 ...
Processing location LM05 ...
Processing location LM06 ...
Processing location LM07 ...
Processing location LM08 ...
Iteration 2 of 3 ...
Processing location LM01 ...
Processing location LM02 ...
Processing location LM03 ...
Processing location LM04 ...
Processing location LM05 ...
Processing location LM06 ...
Processing location LM07 ...
Processing location LM08 ...
Iteration 3 of 3 ...
Processing location LM01 ...
Processing location LM02 ...
Processing location LM03 ...
Processing location LM04 ...
Processing location LM05 ...
Processing location LM06 ...
Processing location LM07 ...
Processing location LM08 ...
$huffmat
ij i_orig C_i j_dest A_j d_ij U_ij sum_U_ij
1 SB611-LM01 SB611 6761 LM01 908.5657 1.0186008 875.6858 14228.09
5 SB611-LM02 SB611 6761 LM02 514.4865 1.7047910 177.0238 14228.09
9 SB611-LM03 SB611 6761 LM03 658.4625 0.5514531 2165.2791 14228.09
13 SB611-LM04 SB611 6761 LM04 2170.0000 1.3846319 1131.8557 14228.09
17 SB611-LM05 SB611 6761 LM05 613.4878 0.5627798 1936.9972 14228.09
21 SB611-LM06 SB611 6761 LM06 2309.2930 1.4113274 1159.3739 14228.09
25 SB611-LM07 SB611 6761 LM07 7626.0343 2.0170833 1874.3517 14228.09
29 SB611-LM08 SB611 6761 LM08 312.6625 0.2524101 4907.5235 14228.09
2 SB612-LM01 SB612 8016 LM01 908.5657 0.2868160 11044.5908 29596.63
6 SB612-LM02 SB612 8016 LM02 514.4865 1.2178480 346.8869 29596.63
10 SB612-LM03 SB612 8016 LM03 658.4625 0.4397744 3404.6393 29596.63
14 SB612-LM04 SB612 8016 LM04 2170.0000 0.8815306 2792.4472 29596.63
18 SB612-LM05 SB612 8016 LM05 613.4878 0.4451331 3096.1792 29596.63
22 SB612-LM06 SB612 8016 LM06 2309.2930 0.6857878 4910.2039 29596.63
26 SB612-LM07 SB612 8016 LM07 7626.0343 1.4273096 3743.3669 29596.63
30 SB612-LM08 SB612 8016 LM08 312.6625 1.1001771 258.3156 29596.63
3 SB613-LM01 SB613 1114 LM01 908.5657 0.4382241 4731.1179 77847.68
7 SB613-LM02 SB613 1114 LM02 514.4865 1.8337781 152.9961 77847.68
11 SB613-LM03 SB613 1114 LM03 658.4625 1.1108366 533.6183 77847.68
15 SB613-LM04 SB613 1114 LM04 2170.0000 0.1783452 68223.9476 77847.68
19 SB613-LM05 SB613 1114 LM05 613.4878 1.1217139 487.5753 77847.68
23 SB613-LM06 SB613 1114 LM06 2309.2930 1.2093575 1578.9547 77847.68
27 SB613-LM07 SB613 1114 LM07 7626.0343 1.9550341 1995.2168 77847.68
31 SB613-LM08 SB613 1114 LM08 312.6625 1.4722479 144.2494 77847.68
4 SB614-LM01 SB614 3839 LM01 908.5657 1.2488959 582.5107 45750.96
8 SB614-LM02 SB614 3839 LM02 514.4865 0.2297791 9744.3539 45750.96
12 SB614-LM03 SB614 3839 LM03 658.4625 0.9574969 718.2179 45750.96
16 SB614-LM04 SB614 3839 LM04 2170.0000 1.8350540 644.4096 45750.96
20 SB614-LM05 SB614 3839 LM05 613.4878 0.9420755 691.2490 45750.96
24 SB614-LM06 SB614 3839 LM06 2309.2930 0.5110920 8840.5829 45750.96
28 SB614-LM07 SB614 3839 LM07 7626.0343 0.5587846 24423.6114 45750.96
32 SB614-LM08 SB614 3839 LM08 312.6625 1.7172382 106.0266 45750.96
p_ij
1 0.061546265
5 0.012441853
9 0.152183389
13 0.079550779
17 0.136138940
21 0.081484853
25 0.131735997
29 0.344917924
2 0.373170556
6 0.011720485
10 0.115034695
14 0.094350176
18 0.104612559
22 0.165904157
26 0.126479501
30 0.008727871
3 0.060774042
7 0.001965327
11 0.006854646
15 0.876377447
19 0.006263197
23 0.020282618
27 0.025629754
31 0.001852969
4 0.012732206
8 0.212986863
12 0.015698422
16 0.014085160
20 0.015108950
24 0.193232722
28 0.533838204
32 0.002317472
$hufftotal
j_dest T_j T_j_share T_j_obs T_j_diff A_opt
1 LM01 3524.0307 0.17861281 3523.0888 -0.9419144 908.5657
2 LM02 997.9167 0.05057865 957.2014 -40.7153598 514.4865
3 LM03 2018.9323 0.10232805 1988.6621 -30.2702128 658.4625
4 LM04 2324.5112 0.11781608 2364.5097 39.9985117 2170.0000
5 LM05 1823.9901 0.09244755 1741.4326 -82.5574605 613.4878
6 LM06 2645.2221 0.13407106 2597.2630 -47.9591165 2309.2930
7 LM07 3982.4832 0.20184912 3891.7185 -90.7646264 7626.0343
8 LM08 2412.9137 0.12229669 2279.3166 -133.5971316 312.6625
$diag
iterations_count resids_sq_sum pseudorsq globerr mape
1 1 201203.39 0.9706746 0.05069991 0.05171379
2 2 81073.36 0.9899779 0.03142618 0.02992982
3 3 39377.02 0.9966779 0.02413274 0.02784364
$params
param1 param2
pow 1 NA
pow -2 NA
$coords
$coords$coords_origins
origins.id origins.pot origins.addr origins.x_lon
1 SB611 6761 Markgrafenstraße 68, Freiburg, Germany 7.822323
2 SB612 8016 Belchenstraße 10, Freiburg, Germany 7.816491
3 SB613 1114 Schopfheimer Straße 4, Freiburg, Germany 7.822583
4 SB614 3839 Christaweg 8, Freiburg, Germany 7.803482
origins.y_lat
1 47.99389
2 47.98718
3 47.98211
4 47.98978
$coords$coords_destinations
destinations.id destinations.attrac
1 LM01 748
2 LM02 900
3 LM03 694
4 LM04 2170
5 LM05 750
6 LM06 982
7 LM07 8900
8 LM08 500
destinations.addr destinations.x_lon
1 Basler Straße 113, Freiburg, Germany 7.818690
2 Heckerstraße 4, Freiburg, Germany 7.800468
3 Carl-Kistner-Straße 32-34, Freiburg, Germany 7.816177
4 Lörracher Straße 8, Freiburg, Germany 7.824830
5 Carl-Kistner-Straße 2, Freiburg, Germany 7.815958
6 Bettackerstraße 23, Freiburg, Germany 7.807447
7 St. Georgener Straße 2, Freiburg, Germany 7.797338
8 Markgrafenstraße 95, Freiburg, Germany 7.825045
destinations.y_lat
1 47.98506
2 47.98934
3 47.99112
4 47.98156
5 47.99116
6 47.98604
7 47.98690
8 47.99524
$tc.mode
$tc.mode$tc.type
[1] "airline"
$tc.mode$tc.unit
[1] "km"
$tc.mode$tc.constant
[1] 0
ij i_orig C_i j_dest A_j d_ij U_ij sum_U_ij
1 SB611-LM01 SB611 6761 LM01 908.5657 1.0186008 875.6858 14228.09
5 SB611-LM02 SB611 6761 LM02 514.4865 1.7047910 177.0238 14228.09
9 SB611-LM03 SB611 6761 LM03 658.4625 0.5514531 2165.2791 14228.09
13 SB611-LM04 SB611 6761 LM04 2170.0000 1.3846319 1131.8557 14228.09
17 SB611-LM05 SB611 6761 LM05 613.4878 0.5627798 1936.9972 14228.09
21 SB611-LM06 SB611 6761 LM06 2309.2930 1.4113274 1159.3739 14228.09
25 SB611-LM07 SB611 6761 LM07 7626.0343 2.0170833 1874.3517 14228.09
29 SB611-LM08 SB611 6761 LM08 312.6625 0.2524101 4907.5235 14228.09
2 SB612-LM01 SB612 8016 LM01 908.5657 0.2868160 11044.5908 29596.63
6 SB612-LM02 SB612 8016 LM02 514.4865 1.2178480 346.8869 29596.63
10 SB612-LM03 SB612 8016 LM03 658.4625 0.4397744 3404.6393 29596.63
14 SB612-LM04 SB612 8016 LM04 2170.0000 0.8815306 2792.4472 29596.63
18 SB612-LM05 SB612 8016 LM05 613.4878 0.4451331 3096.1792 29596.63
22 SB612-LM06 SB612 8016 LM06 2309.2930 0.6857878 4910.2039 29596.63
26 SB612-LM07 SB612 8016 LM07 7626.0343 1.4273096 3743.3669 29596.63
30 SB612-LM08 SB612 8016 LM08 312.6625 1.1001771 258.3156 29596.63
3 SB613-LM01 SB613 1114 LM01 908.5657 0.4382241 4731.1179 77847.68
7 SB613-LM02 SB613 1114 LM02 514.4865 1.8337781 152.9961 77847.68
11 SB613-LM03 SB613 1114 LM03 658.4625 1.1108366 533.6183 77847.68
15 SB613-LM04 SB613 1114 LM04 2170.0000 0.1783452 68223.9476 77847.68
19 SB613-LM05 SB613 1114 LM05 613.4878 1.1217139 487.5753 77847.68
23 SB613-LM06 SB613 1114 LM06 2309.2930 1.2093575 1578.9547 77847.68
27 SB613-LM07 SB613 1114 LM07 7626.0343 1.9550341 1995.2168 77847.68
31 SB613-LM08 SB613 1114 LM08 312.6625 1.4722479 144.2494 77847.68
4 SB614-LM01 SB614 3839 LM01 908.5657 1.2488959 582.5107 45750.96
8 SB614-LM02 SB614 3839 LM02 514.4865 0.2297791 9744.3539 45750.96
12 SB614-LM03 SB614 3839 LM03 658.4625 0.9574969 718.2179 45750.96
16 SB614-LM04 SB614 3839 LM04 2170.0000 1.8350540 644.4096 45750.96
20 SB614-LM05 SB614 3839 LM05 613.4878 0.9420755 691.2490 45750.96
24 SB614-LM06 SB614 3839 LM06 2309.2930 0.5110920 8840.5829 45750.96
28 SB614-LM07 SB614 3839 LM07 7626.0343 0.5587846 24423.6114 45750.96
32 SB614-LM08 SB614 3839 LM08 312.6625 1.7172382 106.0266 45750.96
p_ij
1 0.061546265
5 0.012441853
9 0.152183389
13 0.079550779
17 0.136138940
21 0.081484853
25 0.131735997
29 0.344917924
2 0.373170556
6 0.011720485
10 0.115034695
14 0.094350176
18 0.104612559
22 0.165904157
26 0.126479501
30 0.008727871
3 0.060774042
7 0.001965327
11 0.006854646
15 0.876377447
19 0.006263197
23 0.020282618
27 0.025629754
31 0.001852969
4 0.012732206
8 0.212986863
12 0.015698422
16 0.014085160
20 0.015108950
24 0.193232722
28 0.533838204
32 0.002317472
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.