diff --git a/404.html b/404.html index 35db6f7..43ea5a9 100644 --- a/404.html +++ b/404.html @@ -12,7 +12,7 @@ - + @@ -29,7 +29,7 @@ - +
- +
@@ -147,16 +147,16 @@

Page not found (404)

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/LICENSE-text.html b/LICENSE-text.html index 131176c..44a3d01 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -1,9 +1,9 @@ -License • logitrLicense • logitr - +
- +
@@ -111,15 +111,15 @@

License

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/LICENSE.html b/LICENSE.html index 6d12683..d62b6b2 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -1,9 +1,9 @@ -MIT License • logitrMIT License • logitr - +
- +
@@ -115,15 +115,15 @@

MIT License

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/basic_usage.html b/articles/basic_usage.html index cc5c365..2c39101 100644 --- a/articles/basic_usage.html +++ b/articles/basic_usage.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -128,7 +122,7 @@

Basic Usage

- Source: vignettes/basic_usage.Rmd + Source: vignettes/basic_usage.Rmd
@@ -180,7 +174,7 @@

Model specification interface\[\begin{equation} +

uj=αpj+β1xj1+β2xj2+β3xj3+β4xj4+εj,\begin{equation} u_{j} = \alpha p_{j} + \beta_1 x_{j1} + @@ -189,13 +183,16 @@

Model specification interface\(p_{j}\) is -price, \(x_{j1}\) is -feat, and \(x_{j2-4}\) are -dummy-coded variables for each brand (with the fourth brand -representing the reference level). This model can be estimated using the -logitr() function as follows:

+\end{equation}

+

where +pjp_{j} +is price, +xj1x_{j1} +is feat, and +xj24x_{j2-4} +are dummy-coded variables for each brand (with the fourth +brand representing the reference level). This model can be estimated +using the logitr() function as follows:

 library("logitr")
 
@@ -207,7 +204,7 @@ 

Model specification interface)

The equivalent model in the WTP space is given by the following utility model:

-

\[\begin{equation} +

uj=λ(ω1xj1+ω1xj2+ω1xj3+ω2xj4pj)+εj,\begin{equation} u_{j} = \lambda \left( \omega_1 x_{j1} + @@ -218,7 +215,7 @@

Model specification interface from the pars argument to the scalePar argument:

@@ -287,11 +284,17 @@ 

Mixed logit models), log-normal ("ln"), and zero-censored normal ("cn") distributions.

-

For example, assume the observed utility for yogurts was \(v_{j} = \alpha p_{j} + \beta_1 x_{j1} + \beta_2 -x_{j2} + \beta_3 x_{j3} + \beta_4 x_{j4}\), where \(p_{j}\) is price, \(x_{j1}\) is feat, and \(x_{j2-4}\) are dummy-coded variables for -brand. To model feat as well as each of the -brands as normally-distributed, set -randPars = c(feat = "n", brand = "n"):

+

For example, assume the observed utility for yogurts was +vj=αpj+β1xj1+β2xj2+β3xj3+β4xj4v_{j} = \alpha p_{j} + \beta_1 x_{j1} + \beta_2 x_{j2} + \beta_3 x_{j3} + \beta_4 x_{j4}, +where +pjp_{j} +is price, +xj1x_{j1} +is feat, and +xj24x_{j2-4} +are dummy-coded variables for brand. To model +feat as well as each of the brands as normally-distributed, +set randPars = c(feat = "n", brand = "n"):

 mxl_pref <- logitr(
     data     = yogurt,
@@ -319,7 +322,7 @@ 

Viewing resultssummary(mnl_pref) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:08:38 2023 +#> Model estimated on: Tue Jul 23 23:43:09 2024 #> #> Using logitr version: 1.1.1 #> @@ -337,7 +340,7 @@

Viewing results#> Model Space: Preference #> Model Run: 1 of 1 #> Iterations: 21 -#> Elapsed Time: 0h:0m:0.03s +#> Elapsed Time: 0h:0m:0.02s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE @@ -384,7 +387,7 @@

Viewing results#> price 0.0005936657 5.729619e-04 0.001851795 1.249988e-04 #> feat 0.0005729619 1.441482e-02 0.000855011 5.092011e-06 #> brandhiland 0.0018517954 8.550110e-04 0.021146019 1.490080e-03 -#> brandweight 0.0001249988 5.092011e-06 0.001490080 2.970026e-03 +#> brandweight 0.0001249988 5.092012e-06 0.001490080 2.970026e-03 #> brandyoplait -0.0015377721 -1.821331e-03 -0.003681036 7.779428e-04 #> brandyoplait #> price -0.0015377721 @@ -404,11 +407,11 @@

Computing and comparing WTP
 wtp(mnl_pref, scalePar = "price")
 #>                Estimate Std. Error  z-value  Pr(>|z|)    
-#> scalePar       0.366555   0.024328  15.0672 < 2.2e-16 ***
-#> feat           1.340699   0.358779   3.7368 0.0001864 ***
-#> brandhiland  -10.136219   0.584288 -17.3480 < 2.2e-16 ***
-#> brandweight   -1.749094   0.181021  -9.6624 < 2.2e-16 ***
-#> brandyoplait   2.003848   0.142754  14.0371 < 2.2e-16 ***
+#> scalePar       0.366555   0.024367  15.0429 < 2.2e-16 ***
+#> feat           1.340699   0.360685   3.7171 0.0002015 ***
+#> brandhiland  -10.136219   0.585034 -17.3259 < 2.2e-16 ***
+#> brandweight   -1.749094   0.182224  -9.5986 < 2.2e-16 ***
+#> brandyoplait   2.003848   0.143809  13.9341 < 2.2e-16 ***
 #> ---
 #> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The wtp() function divides the non-price parameters by @@ -421,12 +424,12 @@

Computing and comparing WTP
 wtpCompare(mnl_pref, mnl_wtp, scalePar = "price")
 #>                       pref           wtp  difference
-#> scalePar         0.3665546     0.3665832  0.00002867
-#> feat             1.3406987     1.3405926 -0.00010605
-#> brandhiland    -10.1362190   -10.1357635  0.00045548
-#> brandweight     -1.7490940    -1.7490826  0.00001133
-#> brandyoplait     2.0038476     2.0038208 -0.00002686
-#> logLik       -2656.8878790 -2656.8878779  0.00000106

+#> scalePar 0.3665546 0.3665844 0.00002982 +#> feat 1.3406987 1.3405717 -0.00012701 +#> brandhiland -10.1362190 -10.1357262 0.00049285 +#> brandweight -1.7490940 -1.7490778 0.00001617 +#> brandyoplait 2.0038476 2.0038274 -0.00002024 +#> logLik -2656.8878790 -2656.8878779 0.00000107

Predicting probabilities and outcomes @@ -464,14 +467,14 @@

Predicting probabilities and outc probs #> obsID predicted_prob predicted_prob_lower predicted_prob_upper -#> 49 13 0.43685145 0.41548141 0.45831104 -#> 50 13 0.03312986 0.02621551 0.04163921 -#> 51 13 0.19155548 0.17611690 0.20769226 -#> 52 13 0.33846321 0.31834357 0.35853405 -#> 165 42 0.60764778 0.57295269 0.64051799 -#> 166 42 0.02602007 0.01847637 0.03684122 -#> 167 42 0.17803313 0.16200991 0.19495439 -#> 168 42 0.18829902 0.16826428 0.20943161

+#> 49 13 0.43685145 0.41577964 0.45832350 +#> 50 13 0.03312986 0.02623050 0.04157896 +#> 51 13 0.19155548 0.17600023 0.20831105 +#> 52 13 0.33846321 0.31833043 0.35844177 +#> 165 42 0.60764778 0.57371241 0.64034793 +#> 166 42 0.02602007 0.01845982 0.03640252 +#> 167 42 0.17803313 0.16174641 0.19529813 +#> 168 42 0.18829902 0.16844415 0.20928650

The resulting probs data frame contains the expected probabilities for each alternative. The lower and upper predictions reflect a 95% confidence interval (controlled by the ci @@ -490,14 +493,14 @@

Predicting probabilities and outc probs #> obsID predicted_prob predicted_prob_lower predicted_prob_upper -#> 49 13 0.43686141 0.41510320 0.45781470 -#> 50 13 0.03312947 0.02649838 0.04216022 -#> 51 13 0.19154829 0.17626189 0.20722689 -#> 52 13 0.33846083 0.31821812 0.35884461 -#> 165 42 0.60767120 0.57306657 0.63930872 -#> 166 42 0.02601800 0.01829250 0.03650514 -#> 167 42 0.17802363 0.16242400 0.19454452 -#> 168 42 0.18828717 0.16766408 0.20933291 +#> 49 13 0.43686116 0.41513987 0.45788692 +#> 50 13 0.03312963 0.02643243 0.04224291 +#> 51 13 0.19154802 0.17606584 0.20755745 +#> 52 13 0.33846119 0.31872018 0.35905184 +#> 165 42 0.60767163 0.57343133 0.64002670 +#> 166 42 0.02601791 0.01845253 0.03647376 +#> 167 42 0.17802339 0.16222249 0.19447613 +#> 168 42 0.18828706 0.16757845 0.20892092

You can also use the predict() method to predict outcomes by setting type = "outcome" (the default value is "prob" for predicting probabilities). If no new data are @@ -517,8 +520,8 @@

Predicting probabilities and outc #> obsID choice predicted_outcome #> 1 1 0 0 #> 2 1 0 0 -#> 3 1 1 1 -#> 4 1 0 0 +#> 3 1 1 0 +#> 4 1 0 1 #> 5 2 1 0 #> 6 2 0 0

You can quickly compute the accuracy by dividing the number of @@ -527,7 +530,7 @@

Predicting probabilities and outc chosen <- subset(outcomes, choice == 1) chosen$correct <- chosen$choice == chosen$predicted_outcome sum(chosen$correct) / nrow(chosen) -#> [1] 0.3631841 +#> [1] 0.3922056

See the “Predicting Probabilities and Choices from Estimated Models” vignette for more details about making predictions.

@@ -536,9 +539,7 @@

Predicting probabilities and outc + @@ -551,16 +552,16 @@

Predicting probabilities and outc

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/benchmark.html b/articles/benchmark.html index 471b888..cbca356 100644 --- a/articles/benchmark.html +++ b/articles/benchmark.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -130,7 +124,7 @@

Benchmarking estimation speed against other packages

- Source: vignettes/benchmark.Rmd + Source: vignettes/benchmark.Rmd
@@ -569,14 +563,14 @@

Comparing run times
 library(ggplot2)
-library(ggrepel)
+library(ggrepel)
 
 plotColors <- c("black", RColorBrewer::brewer.pal(n = 5, name = "Set1"), "gold")
 benchmark <- runtimes %>% 
     ggplot(aes(x = numDraws, y = time_sec, color = package)) +
     geom_line() +
     geom_point() +
-    geom_text_repel(
+    geom_text_repel(
         data = . %>% filter(numDraws == max(numDraws)),
         aes(label = package),
         hjust = 0, nudge_x = 40, direction = "y",
@@ -611,9 +605,7 @@ 

Comparing run times - -

+ @@ -626,16 +618,16 @@

Comparing run times

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/convergence.html b/articles/convergence.html index 3966a0a..ca5c318 100644 --- a/articles/convergence.html +++ b/articles/convergence.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -129,7 +123,7 @@

WTP space convergence issues in other packages

- Source: vignettes/convergence.Rmd + Source: vignettes/convergence.Rmd
@@ -723,9 +717,7 @@

{apollo} - -

+
@@ -738,16 +730,16 @@

{apollo}

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/data_formatting.html b/articles/data_formatting.html index fd8be98..f98ea98 100644 --- a/articles/data_formatting.html +++ b/articles/data_formatting.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -128,7 +122,7 @@

Data Formatting and Encoding

- Source: vignettes/data_formatting.Rmd + Source: vignettes/data_formatting.Rmd
@@ -251,7 +245,7 @@

Creating dummy coded variablessummary(mnl_pref_dummies) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:02 2023 +#> Model estimated on: Tue Jul 23 23:43:26 2024 #> #> Using logitr version: 1.1.1 #> @@ -269,7 +263,7 @@

Creating dummy coded variables#> Model Space: Preference #> Model Run: 1 of 1 #> Iterations: 18 -#> Elapsed Time: 0h:0m:0.02s +#> Elapsed Time: 0h:0m:0.01s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE @@ -296,9 +290,7 @@

Creating dummy coded variables - -

+
@@ -311,16 +303,16 @@

Creating dummy coded variables

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/index.html b/articles/index.html index c6188cd..4d9bccb 100644 --- a/articles/index.html +++ b/articles/index.html @@ -1,9 +1,9 @@ -Articles • logitrArticles • logitr - +
- + - - + + diff --git a/articles/interactions.html b/articles/interactions.html index c8633c6..57c57fe 100644 --- a/articles/interactions.html +++ b/articles/interactions.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -128,7 +122,7 @@

Estimating Models with Interactions

- Source: vignettes/interactions.Rmd + Source: vignettes/interactions.Rmd
@@ -167,7 +161,7 @@

Interactions with continuous var summary(model_price_feat) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:06 2023 +#> Model estimated on: Tue Jul 23 23:43:28 2024 #> #> Using logitr version: 1.1.1 #> @@ -185,7 +179,7 @@

Interactions with continuous var #> Model Space: Preference #> Model Run: 1 of 1 #> Iterations: 19 -#> Elapsed Time: 0h:0m:0.02s +#> Elapsed Time: 0h:0m:0.01s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE @@ -234,7 +228,7 @@

Interactions with discrete variabl summary(model_price_brand) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:06 2023 +#> Model estimated on: Tue Jul 23 23:43:29 2024 #> #> Using logitr version: 1.1.1 #> @@ -251,31 +245,31 @@

Interactions with discrete variabl #> Model Type: Multinomial Logit #> Model Space: Preference #> Model Run: 1 of 1 -#> Iterations: 37 -#> Elapsed Time: 0h:0m:0.04s +#> Iterations: 42 +#> Elapsed Time: 0h:0m:0.03s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE #> #> Model Coefficients: #> Estimate Std. Error z-value Pr(>|z|) -#> price -0.389503 0.045247 -8.6085 < 2.2e-16 *** -#> feat 0.421899 0.122578 3.4419 0.0005777 *** -#> brandhiland -1.691789 0.623149 -2.7149 0.0066295 ** -#> brandweight -2.228475 0.561641 -3.9678 7.254e-05 *** -#> brandyoplait 0.438702 0.450424 0.9740 0.3300689 -#> price:brandhiland -0.434271 0.115531 -3.7589 0.0001707 *** -#> price:brandweight 0.199919 0.069830 2.8629 0.0041973 ** -#> price:brandyoplait 0.033233 0.050372 0.6598 0.5094089 +#> price -0.389813 0.045256 -8.6135 < 2.2e-16 *** +#> feat 0.422188 0.122588 3.4440 0.0005732 *** +#> brandhiland -1.692896 0.623122 -2.7168 0.0065917 ** +#> brandweight -2.226187 0.561605 -3.9640 7.371e-05 *** +#> brandyoplait 0.441559 0.450562 0.9800 0.3270779 +#> price:brandhiland -0.434214 0.115521 -3.7587 0.0001708 *** +#> price:brandweight 0.199624 0.069825 2.8589 0.0042512 ** +#> price:brandyoplait 0.033040 0.050385 0.6558 0.5119777 #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> -#> Log-Likelihood: -2643.2046775 +#> Log-Likelihood: -2643.2048908 #> Null Log-Likelihood: -3343.7419990 -#> AIC: 5302.4093549 -#> BIC: 5348.7150000 -#> McFadden R2: 0.2095070 -#> Adj McFadden R2: 0.2071145 +#> AIC: 5302.4097816 +#> BIC: 5348.7155000 +#> McFadden R2: 0.2095069 +#> Adj McFadden R2: 0.2071144 #> Number of Observations: 2412.0000000

@@ -326,7 +320,7 @@

Interactions with indiv summary(model_price_group) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:07 2023 +#> Model estimated on: Tue Jul 23 23:43:29 2024 #> #> Using logitr version: 1.1.1 #> @@ -344,7 +338,7 @@

Interactions with indiv #> Model Space: Preference #> Model Run: 1 of 1 #> Iterations: 26 -#> Elapsed Time: 0h:0m:0.03s +#> Elapsed Time: 0h:0m:0.02s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE @@ -393,7 +387,7 @@

Interactions in mixed logit modelssummary(model_price_feat_mxl) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:07 2023 +#> Model estimated on: Tue Jul 23 23:43:30 2024 #> #> Using logitr version: 1.1.1 #> @@ -410,43 +404,41 @@

Interactions in mixed logit models#> Model Type: Mixed Logit #> Model Space: Preference #> Model Run: 1 of 1 -#> Iterations: 32 -#> Elapsed Time: 0h:0m:1s +#> Iterations: 34 +#> Elapsed Time: 0h:0m:0.68s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE #> #> Model Coefficients: #> Estimate Std. Error z-value Pr(>|z|) -#> price -0.388138 0.027026 -14.3615 < 2.2e-16 *** -#> feat 0.829059 0.552235 1.5013 0.1333 -#> brandhiland -3.991584 0.165893 -24.0612 < 2.2e-16 *** -#> brandweight -0.662161 0.055780 -11.8709 < 2.2e-16 *** -#> brandyoplait 0.787758 0.086233 9.1352 < 2.2e-16 *** -#> price:feat -0.076752 0.071063 -1.0800 0.2801 -#> sd_feat -2.341209 0.493326 -4.7458 2.077e-06 *** +#> price -0.388123 0.027026 -14.3612 < 2.2e-16 *** +#> feat 0.829004 0.552278 1.5011 0.1333 +#> brandhiland -3.991559 0.165894 -24.0609 < 2.2e-16 *** +#> brandweight -0.662086 0.055779 -11.8698 < 2.2e-16 *** +#> brandyoplait 0.787718 0.086232 9.1348 < 2.2e-16 *** +#> price:feat -0.076733 0.071069 -1.0797 0.2803 +#> sd_feat -2.341507 0.493413 -4.7455 2.08e-06 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> -#> Log-Likelihood: -2645.2196926 +#> Log-Likelihood: -2645.2196929 #> Null Log-Likelihood: -3343.7419990 -#> AIC: 5304.4393851 +#> AIC: 5304.4393858 #> BIC: 5344.9569000 #> McFadden R2: 0.2089044 #> Adj McFadden R2: 0.2068109 #> Number of Observations: 2412.0000000 #> #> Summary of 10k Draws for Random Coefficients: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> feat -Inf -0.7475368 0.8308482 0.832337 2.409772 Inf

+#> Min. 1st Qu. Median Mean 3rd Qu. Max. +#> feat -Inf -0.747793 0.8307929 0.8322819 2.409918 Inf
+ @@ -459,16 +451,16 @@

Interactions in mixed logit models

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/mnl_models.html b/articles/mnl_models.html index 2af1625..3ab9e1d 100644 --- a/articles/mnl_models.html +++ b/articles/mnl_models.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -128,7 +122,7 @@

Estimating Multinomial Logit Models

- Source: vignettes/mnl_models.Rmd + Source: vignettes/mnl_models.Rmd
@@ -165,24 +159,24 @@

The data -\(p\) +pp The price in US dollars. -\(x_{j}^{\mathrm{Feat}}\) +xjFeatx_{j}^{\mathrm{Feat}} Dummy variable for whether the newspaper advertisement was shown to the customer. -\(x_{j}^{\mathrm{Hiland}}\) +xjHilandx_{j}^{\mathrm{Hiland}} Dummy variable for the “Highland” brand. -\(x_{j}^{\mathrm{Weight}}\) +xjWeightx_{j}^{\mathrm{Weight}} Dummy variable for the “Weight Watchers” brand. -\(x_{j}^{\mathrm{Yoplait}}\) +xjYoplaitx_{j}^{\mathrm{Yoplait}} Dummy variable for the “Yoplait” brand. @@ -194,7 +188,7 @@

Preference space model

This example will estimate the following homogeneous multinomial logit model in the preference space:

-

\[\begin{equation} +

uj=αpj+β1xjFeat+β2xjHiland+β3xjWeight+β4xjYoplait+εj\begin{equation} u_{j} = \alpha p_{j} + \beta_1 x_{j}^{\mathrm{Feat}} + @@ -203,9 +197,15 @@

Preference space model

-

where the parameters \(\alpha\), -\(\beta_1\), \(\beta_2\), \(\beta_3\), and \(\beta_4\) have units of utility.

+\end{equation}

+

where the parameters +α\alpha, +β1\beta_1, +β2\beta_2, +β3\beta_3, +and +β4\beta_4 +have units of utility.

Estimate the model using the logitr() function:

 library("logitr")
@@ -221,7 +221,7 @@ 

Preference space modelsummary(mnl_pref) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:12 2023 +#> Model estimated on: Tue Jul 23 23:43:37 2024 #> #> Using logitr version: 1.1.1 #> @@ -239,7 +239,7 @@

Preference space model#> Model Space: Preference #> Model Run: 1 of 1 #> Iterations: 21 -#> Elapsed Time: 0h:0m:0.03s +#> Elapsed Time: 0h:0m:0.02s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE @@ -271,11 +271,11 @@

Preference space modelwtp_mnl_pref <- wtp(mnl_pref, scalePar = "price") wtp_mnl_pref #> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.366555 0.024317 15.0742 < 2.2e-16 *** -#> feat 1.340699 0.360736 3.7166 0.0002019 *** -#> brandhiland -10.136219 0.582992 -17.3865 < 2.2e-16 *** -#> brandweight -1.749094 0.181459 -9.6391 < 2.2e-16 *** -#> brandyoplait 2.003848 0.143636 13.9509 < 2.2e-16 *** +#> scalePar 0.366555 0.024388 15.0299 < 2.2e-16 *** +#> feat 1.340699 0.359070 3.7338 0.0001886 *** +#> brandhiland -10.136219 0.585204 -17.3208 < 2.2e-16 *** +#> brandweight -1.749094 0.181314 -9.6468 < 2.2e-16 *** +#> brandyoplait 2.003848 0.143059 14.0071 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

@@ -284,7 +284,7 @@

WTP space model

This example will estimate the following homogeneous multinomial logit model in the WTP space:

-

\[\begin{equation} +

uj=λ(ω1xjFeat+ω2xjHiland+ω3xjWeight+ω4xjYoplaitpj)+εj\begin{equation} u_{j} = \lambda ( \omega_1 x_{j}^{\mathrm{Feat}} + @@ -294,9 +294,16 @@

WTP space model

-

where the parameters \(\omega_1\), -\(\omega_2\), \(\omega_3\), and \(\omega_4\) have units of dollars and \(\lambda\) is the scale parameter.

+\end{equation}

+

where the parameters +ω1\omega_1, +ω2\omega_2, +ω3\omega_3, +and +ω4\omega_4 +have units of dollars and +λ\lambda +is the scale parameter.

Estimate the model using the logitr() function:

 mnl_wtp <- logitr(
@@ -316,7 +323,7 @@ 

WTP space modelsummary(mnl_wtp) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:13 2023 +#> Model estimated on: Tue Jul 23 23:43:37 2024 #> #> Using logitr version: 1.1.1 #> @@ -332,15 +339,15 @@

WTP space model#> Summary Of Multistart Runs: #> Log Likelihood Iterations Exit Status #> 1 -2656.888 84 3 -#> 2 -2656.888 39 3 -#> 3 -2656.888 42 3 -#> 4 -2656.888 52 3 -#> 5 -2656.888 44 3 -#> 6 -2805.407 100 4 -#> 7 -2656.888 39 3 -#> 8 -2656.888 47 3 -#> 9 -2656.888 36 3 -#> 10 -2656.888 45 3 +#> 2 -2805.308 82 4 +#> 3 -2656.888 35 3 +#> 4 -2656.888 36 3 +#> 5 -2656.888 51 3 +#> 6 -2656.888 37 3 +#> 7 -2656.888 36 3 +#> 8 -2804.821 87 4 +#> 9 -2656.888 45 3 +#> 10 -2656.888 39 3 #> #> Use statusCodes() to view the meaning of each status code #> @@ -348,20 +355,20 @@

WTP space model#> #> Model Type: Multinomial Logit #> Model Space: Willingness-to-Pay -#> Model Run: 3 of 10 -#> Iterations: 42 -#> Elapsed Time: 0h:0m:0.12s +#> Model Run: 1 of 10 +#> Iterations: 84 +#> Elapsed Time: 0h:0m:0.06s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Robust? FALSE #> #> Model Coefficients: #> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.366584 0.024366 15.0449 < 2.2e-16 *** -#> feat 1.340569 0.355865 3.7671 0.0001652 *** -#> brandhiland -10.135733 0.576084 -17.5942 < 2.2e-16 *** -#> brandweight -1.749071 0.179896 -9.7227 < 2.2e-16 *** -#> brandyoplait 2.003825 0.142377 14.0741 < 2.2e-16 *** +#> scalePar 0.366585 0.024366 15.0450 < 2.2e-16 *** +#> feat 1.340566 0.355864 3.7671 0.0001652 *** +#> brandhiland -10.135707 0.576078 -17.5943 < 2.2e-16 *** +#> brandweight -1.749066 0.179896 -9.7227 < 2.2e-16 *** +#> brandyoplait 2.003824 0.142377 14.0741 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> @@ -376,7 +383,7 @@

WTP space model
 coef(mnl_wtp)
 #>     scalePar         feat  brandhiland  brandweight brandyoplait 
-#>    0.3665844    1.3405695  -10.1357334   -1.7490710    2.0038253

+#> 0.3665849 1.3405656 -10.1357075 -1.7490664 2.0038243

Compare WTP from both models @@ -395,17 +402,17 @@

Compare WTP from both models
 wtpCompare(mnl_pref, mnl_wtp, scalePar = 'price')
 #>                       pref           wtp  difference
-#> scalePar         0.3665546     0.3665844  0.00002988
-#> feat             1.3406987     1.3405695 -0.00012922
-#> brandhiland    -10.1362190   -10.1357334  0.00048557
-#> brandweight     -1.7490940    -1.7490710  0.00002300
-#> brandyoplait     2.0038476     2.0038253 -0.00002228
-#> logLik       -2656.8878790 -2656.8878779  0.00000107

+#> scalePar 0.3665546 0.3665849 0.00003030 +#> feat 1.3406987 1.3405656 -0.00013309 +#> brandhiland -10.1362190 -10.1357075 0.00051155 +#> brandweight -1.7490940 -1.7490664 0.00002759 +#> brandyoplait 2.0038476 2.0038243 -0.00002336 +#> logLik -2656.8878790 -2656.8878779 0.00000106

References

-
+
Jain, Dipak C, Naufel J Vilcassim, and Pradeep K Chintagunta. 1994. “A Random-Coefficients Logit Brand-Choice Model Applied to Panel @@ -418,9 +425,7 @@

References - -

+
@@ -433,16 +438,16 @@

References

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/mnl_models_weighted.html b/articles/mnl_models_weighted.html index f351833..4a2d6fe 100644 --- a/articles/mnl_models_weighted.html +++ b/articles/mnl_models_weighted.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -128,7 +122,7 @@

Estimating Weighted Logit Models

- Source: vignettes/mnl_models_weighted.Rmd + Source: vignettes/mnl_models_weighted.Rmd
@@ -162,67 +156,67 @@

The data -\(p\) +pp The price in US dollars. -\(x_{j}^{\mathrm{hev}}\) +xjhevx_{j}^{\mathrm{hev}} Dummy variable for HEV vehicle type -\(x_{j}^{\mathrm{phev10}}\) +xjphev10x_{j}^{\mathrm{phev10}} Dummy variable for PHEV10 vehicle type -\(x_{j}^{\mathrm{phev20}}\) +xjphev20x_{j}^{\mathrm{phev20}} Dummy variable for PHEV20 vehicle type -\(x_{j}^{\mathrm{phev40}}\) +xjphev40x_{j}^{\mathrm{phev40}} Dummy variable for PHEV40 vehicle type -\(x_{j}^{\mathrm{bev75}}\) +xjbev75x_{j}^{\mathrm{bev75}} Dummy variable for BEV75 vehicle type -\(x_{j}^{\mathrm{bev100}}\) +xjbev100x_{j}^{\mathrm{bev100}} Dummy variable for BEV100 vehicle type -\(x_{j}^{\mathrm{bev150}}\) +xjbev150x_{j}^{\mathrm{bev150}} Dummy variable for BEV150 vehicle type -\(x_{j}^{\mathrm{phevFastcharge}}\) +xjphevFastchargex_{j}^{\mathrm{phevFastcharge}} Dummy variable for if the PHEV has a fast charging capability -\(x_{j}^{\mathrm{bevFastcharge}}\) +xjbevFastchargex_{j}^{\mathrm{bevFastcharge}} Dummy variable for if the BEV has a fast charging capability -\(x_{j}^{\mathrm{opCost}}\) +xjopCostx_{j}^{\mathrm{opCost}} The vehicle operating costs (cents / mile) -\(x_{j}^{\mathrm{accelTime}}\) +xjaccelTimex_{j}^{\mathrm{accelTime}} The vehicle 0-60mph acceleration time -\(x_{j}^{\mathrm{american}}\) +xjamericanx_{j}^{\mathrm{american}} Dummy variable for an American brand -\(x_{j}^{\mathrm{japanese}}\) +xjjapanesex_{j}^{\mathrm{japanese}} Dummy variable for a Japanese brand -\(x_{j}^{\mathrm{chinese}}\) +xjchinesex_{j}^{\mathrm{chinese}} Dummy variable for a Chinese brand -\(x_{j}^{\mathrm{skorean}}\) +xjskoreanx_{j}^{\mathrm{skorean}} Dummy variable for a S. Korean brand @@ -235,30 +229,32 @@

The utility model(2015):

-

\[\begin{equation} +

uj=λ(ω1xjhev+ω2xjphev10+ω3xjphev20+ω4xjphev40+ω5xjbev75+ω6xjbev100+ω7xjbev150+ω8xjphevFastcharge+ω9xjbevFastcharge+ω10xjopCost+ω11xjaccelTime+ω12xjamerican+ω13xjjapanese+ω14xjchinese+ω15xjskoreanpj)+εj\begin{equation} \begin{split} &u_{j} = \lambda (\\ &\omega_1 x_{j}^{\mathrm{hev}} + -\omega_2 x_{j}^{\mathrm{phev10}} + -\omega_3 x_{j}^{\mathrm{phev20}} + -\omega_4 x_{j}^{\mathrm{phev40}} +\\ + \omega_2 x_{j}^{\mathrm{phev10}} + + \omega_3 x_{j}^{\mathrm{phev20}} + + \omega_4 x_{j}^{\mathrm{phev40}} +\\ &\omega_5 x_{j}^{\mathrm{bev75}} + -\omega_6 x_{j}^{\mathrm{bev100}} + -\omega_7 x_{j}^{\mathrm{bev150}} +\\ + \omega_6 x_{j}^{\mathrm{bev100}} + + \omega_7 x_{j}^{\mathrm{bev150}} +\\ &\omega_8 x_{j}^{\mathrm{phevFastcharge}} + -\omega_9 x_{j}^{\mathrm{bevFastcharge}} + -\omega_{10} x_{j}^{\mathrm{opCost}} + -\omega_{11} x_{j}^{\mathrm{accelTime}} +\\ + \omega_9 x_{j}^{\mathrm{bevFastcharge}} + + \omega_{10} x_{j}^{\mathrm{opCost}} + + \omega_{11} x_{j}^{\mathrm{accelTime}} +\\ &\omega_{12} x_{j}^{\mathrm{american}} + -\omega_{13} x_{j}^{\mathrm{japanese}} + -\omega_{14} x_{j}^{\mathrm{chinese}} + -\omega_{15} x_{j}^{\mathrm{skorean}} - p_{j}\\ + \omega_{13} x_{j}^{\mathrm{japanese}} + + \omega_{14} x_{j}^{\mathrm{chinese}} + + \omega_{15} x_{j}^{\mathrm{skorean}} - p_{j}\\ &) +\varepsilon_{j} \end{split} \label{eq:mnlWtpCarsExample} -\end{equation}\]

-

where all the \(\omega\) parameters -have units of dollars and \(\lambda\) +\end{equation}

+

where all the +ω\omega +parameters have units of dollars and +λ\lambda is the scale parameter.

@@ -288,7 +284,7 @@

Unweighted modelsummary(mnl_wtp_unweighted) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:18 2023 +#> Model estimated on: Tue Jul 23 23:43:32 2024 #> #> Using logitr version: 1.1.1 #> @@ -306,15 +302,15 @@

Unweighted model#> Summary Of Multistart Runs: #> Log Likelihood Iterations Exit Status #> 1 -4616.952 26 3 -#> 2 -4616.955 32 3 +#> 2 -4616.952 32 3 #> 3 -4616.952 35 3 -#> 4 -4616.952 42 3 -#> 5 -4616.952 31 3 -#> 6 -4616.952 37 3 -#> 7 -4616.952 30 3 -#> 8 -4616.952 34 3 -#> 9 -4616.952 31 3 -#> 10 -4616.952 32 3 +#> 4 -4616.952 31 3 +#> 5 -4616.952 34 3 +#> 6 -4616.952 42 3 +#> 7 -4616.952 37 3 +#> 8 -4616.952 33 3 +#> 9 -4616.952 37 3 +#> 10 -4616.952 31 3 #> #> Use statusCodes() to view the meaning of each status code #> @@ -322,38 +318,38 @@

Unweighted model#> #> Model Type: Multinomial Logit #> Model Space: Willingness-to-Pay -#> Model Run: 8 of 10 -#> Iterations: 34 -#> Elapsed Time: 0h:0m:0.19s +#> Model Run: 4 of 10 +#> Iterations: 31 +#> Elapsed Time: 0h:0m:0.09s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: FALSE #> Cluster ID: obsnum #> Robust? TRUE #> #> Model Coefficients: -#> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.073880 0.002193 33.6893 < 2.2e-16 *** -#> hev 0.807097 0.999046 0.8079 0.4191670 -#> phev10 1.164799 1.061488 1.0973 0.2724985 -#> phev20 1.646504 1.061732 1.5508 0.1209565 -#> phev40 2.578501 1.049915 2.4559 0.0140527 * -#> bev75 -16.046518 1.254137 -12.7949 < 2.2e-16 *** -#> bev100 -13.003530 1.238852 -10.4964 < 2.2e-16 *** -#> bev150 -9.573554 1.164168 -8.2235 2.220e-16 *** -#> american 2.343789 0.797959 2.9372 0.0033116 ** -#> japanese -0.375067 0.799823 -0.4689 0.6391146 -#> chinese -10.269041 0.885942 -11.5911 < 2.2e-16 *** -#> skorean -6.031437 0.851429 -7.0839 1.402e-12 *** -#> phevFastcharge 2.880482 0.802883 3.5877 0.0003336 *** -#> bevFastcharge 2.919178 0.918125 3.1795 0.0014753 ** -#> opCost -1.636056 0.068632 -23.8381 < 2.2e-16 *** -#> accelTime -1.697024 0.163808 -10.3598 < 2.2e-16 *** +#> Estimate Std. Error z-value Pr(>|z|) +#> scalePar 0.0738774 0.0021929 33.6897 < 2.2e-16 *** +#> hev 0.8067157 0.9990727 0.8075 0.4193989 +#> phev10 1.1661239 1.0615105 1.0986 0.2719638 +#> phev20 1.6479612 1.0617569 1.5521 0.1206364 +#> phev40 2.5799061 1.0499398 2.4572 0.0140027 * +#> bev75 -16.0466139 1.2541622 -12.7947 < 2.2e-16 *** +#> bev100 -13.0036334 1.2388778 -10.4963 < 2.2e-16 *** +#> bev150 -9.5739892 1.1642037 -8.2236 2.220e-16 *** +#> american 2.3440498 0.7979799 2.9375 0.0033089 ** +#> japanese -0.3747159 0.7998412 -0.4685 0.6394358 +#> chinese -10.2689884 0.8859572 -11.5908 < 2.2e-16 *** +#> skorean -6.0310531 0.8514411 -7.0833 1.407e-12 *** +#> phevFastcharge 2.8788982 0.8028866 3.5857 0.0003362 *** +#> bevFastcharge 2.9189842 0.9181490 3.1792 0.0014768 ** +#> opCost -1.6360751 0.0686328 -23.8381 < 2.2e-16 *** +#> accelTime -1.6970516 0.1638115 -10.3598 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> -#> Log-Likelihood: -4616.9517825 +#> Log-Likelihood: -4616.9517792 #> Null Log-Likelihood: -6328.0067827 -#> AIC: 9265.9035649 +#> AIC: 9265.9035584 #> BIC: 9372.4426000 #> McFadden R2: 0.2703940 #> Adj McFadden R2: 0.2678655 @@ -391,7 +387,7 @@

Weighted modelsummary(mnl_wtp_weighted) #> ================================================= #> -#> Model estimated on: Wed Sep 27 15:09:20 2023 +#> Model estimated on: Tue Jul 23 23:43:34 2024 #> #> Using logitr version: 1.1.1 #> @@ -409,15 +405,15 @@

Weighted model#> Summary Of Multistart Runs: #> Log Likelihood Iterations Exit Status #> 1 -3425.633 19 3 -#> 2 -3425.630 34 3 -#> 3 -3425.630 36 3 -#> 4 -3425.630 32 3 -#> 5 -3425.630 35 3 -#> 6 -3425.630 29 3 -#> 7 -3425.630 31 3 -#> 8 -3425.630 29 3 -#> 9 -3425.630 29 3 -#> 10 -3425.630 31 3 +#> 2 -3425.630 35 3 +#> 3 -3425.630 32 3 +#> 4 -3425.630 36 3 +#> 5 -3425.630 30 3 +#> 6 -3425.630 36 3 +#> 7 -3425.630 38 3 +#> 8 -3425.630 32 3 +#> 9 -3425.630 36 3 +#> 10 -3425.630 32 3 #> #> Use statusCodes() to view the meaning of each status code #> @@ -425,9 +421,9 @@

Weighted model#> #> Model Type: Multinomial Logit #> Model Space: Willingness-to-Pay -#> Model Run: 2 of 10 -#> Iterations: 34 -#> Elapsed Time: 0h:0m:0.2s +#> Model Run: 8 of 10 +#> Iterations: 32 +#> Elapsed Time: 0h:0m:0.08s #> Algorithm: NLOPT_LD_LBFGS #> Weights Used?: TRUE #> Cluster ID: obsnum @@ -435,28 +431,28 @@

Weighted model#> #> Model Coefficients: #> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.0522797 0.0040689 12.8487 < 2.2e-16 *** -#> hev -1.1755983 2.9133504 -0.4035 0.6865649 -#> phev10 0.0281109 3.1280505 0.0090 0.9928297 -#> phev20 1.6956836 3.0997523 0.5470 0.5843523 -#> phev40 2.6504028 2.9852177 0.8878 0.3746256 -#> bev75 -20.1359622 3.6671604 -5.4909 3.999e-08 *** -#> bev100 -19.4963233 3.6256240 -5.3774 7.558e-08 *** -#> bev150 -13.6907975 3.4927133 -3.9198 8.862e-05 *** -#> american 8.1897552 2.4054065 3.4047 0.0006623 *** -#> japanese 0.9362407 2.3603989 0.3966 0.6916292 -#> chinese -19.0061927 2.8539665 -6.6596 2.746e-11 *** -#> skorean -9.5083395 2.5233474 -3.7681 0.0001645 *** -#> phevFastcharge 3.9436347 2.3624326 1.6693 0.0950558 . -#> bevFastcharge 3.3424301 2.8087133 1.1900 0.2340378 -#> opCost -1.5975603 0.1948511 -8.1989 2.220e-16 *** -#> accelTime -1.1718133 0.4834731 -2.4237 0.0153616 * +#> scalePar 0.0522816 0.0040689 12.8490 < 2.2e-16 *** +#> hev -1.1767755 2.9132608 -0.4039 0.6862586 +#> phev10 0.0259001 3.1279545 0.0083 0.9933934 +#> phev20 1.6936471 3.0996513 0.5464 0.5847915 +#> phev40 2.6493078 2.9851129 0.8875 0.3748062 +#> bev75 -20.1364665 3.6670723 -5.4912 3.993e-08 *** +#> bev100 -19.4956474 3.6254343 -5.3775 7.554e-08 *** +#> bev150 -13.6901824 3.4925299 -3.9198 8.861e-05 *** +#> american 8.1856838 2.4051540 3.4034 0.0006655 *** +#> japanese 0.9329586 2.3602742 0.3953 0.6926396 +#> chinese -19.0092581 2.8541735 -6.6602 2.735e-11 *** +#> skorean -9.5128579 2.5235142 -3.7697 0.0001635 *** +#> phevFastcharge 3.9425031 2.3623349 1.6689 0.0951370 . +#> bevFastcharge 3.3425219 2.8085873 1.1901 0.2340040 +#> opCost -1.5975391 0.1948443 -8.1991 2.220e-16 *** +#> accelTime -1.1716178 0.4834534 -2.4234 0.0153745 * #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> -#> Log-Likelihood: -3425.6302867 +#> Log-Likelihood: -3425.6302899 #> Null Log-Likelihood: -4360.5909275 -#> AIC: 6883.2605735 +#> AIC: 6883.2605798 #> BIC: 6989.7997000 #> McFadden R2: 0.2144115 #> Adj McFadden R2: 0.2107422 @@ -475,23 +471,23 @@

Compare results Unweighted = coef(mnl_wtp_unweighted), Weighted = coef(mnl_wtp_weighted) ) -#> Unweighted Weighted -#> scalePar 0.07387993 0.05227968 -#> hev 0.80709659 -1.17559826 -#> phev10 1.16479942 0.02811089 -#> phev20 1.64650366 1.69568361 -#> phev40 2.57850057 2.65040275 -#> bev75 -16.04651841 -20.13596220 -#> bev100 -13.00352957 -19.49632333 -#> bev150 -9.57355416 -13.69079748 -#> american 2.34378890 8.18975522 -#> japanese -0.37506676 0.93624067 -#> chinese -10.26904087 -19.00619271 -#> skorean -6.03143704 -9.50833948 -#> phevFastcharge 2.88048245 3.94363474 -#> bevFastcharge 2.91917811 3.34243006 -#> opCost -1.63605621 -1.59756026 -#> accelTime -1.69702410 -1.17181332

+#> Unweighted Weighted +#> scalePar 0.0738774 0.05228164 +#> hev 0.8067157 -1.17677549 +#> phev10 1.1661239 0.02590006 +#> phev20 1.6479612 1.69364709 +#> phev40 2.5799061 2.64930778 +#> bev75 -16.0466139 -20.13646650 +#> bev100 -13.0036334 -19.49564743 +#> bev150 -9.5739892 -13.69018245 +#> american 2.3440498 8.18568382 +#> japanese -0.3747159 0.93295864 +#> chinese -10.2689884 -19.00925808 +#> skorean -6.0310531 -9.51285786 +#> phevFastcharge 2.8788982 3.94250307 +#> bevFastcharge 2.9189842 3.34252186 +#> opCost -1.6360751 -1.59753905 +#> accelTime -1.6970516 -1.17161781

Here is a comparison of the log-likelihood for the weighted and unweighted models:

@@ -505,7 +501,7 @@ 

Compare results

References

-
+
Helveston, John Paul, Yimin Liu, Eleanor Mcdonnell Feit, Erica R. H. Fuchs, Erica Klampfl, and Jeremy J. Michalek. 2015. Will Subsidies Drive Electric Vehicle Adoption? Measuring @@ -519,9 +515,7 @@

References - -

+
@@ -534,16 +528,16 @@

References

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/mxl_models.html b/articles/mxl_models.html index 2b09781..ea77598 100644 --- a/articles/mxl_models.html +++ b/articles/mxl_models.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -128,7 +122,7 @@

Estimating Mixed Logit Models

- Source: vignettes/mxl_models.Rmd + Source: vignettes/mxl_models.Rmd
@@ -197,24 +191,24 @@

The data -\(p\) +pp The price in US dollars. -\(x_{j}^{\mathrm{Feat}}\) +xjFeatx_{j}^{\mathrm{Feat}} Dummy variable for whether the newspaper advertisement was shown to the customer. -\(x_{j}^{\mathrm{Hiland}}\) +xjHilandx_{j}^{\mathrm{Hiland}} Dummy variable for the “Highland” brand. -\(x_{j}^{\mathrm{Weight}}\) +xjWeightx_{j}^{\mathrm{Weight}} Dummy variable for the “Weight Watchers” brand. -\(x_{j}^{\mathrm{Yoplait}}\) +xjYoplaitx_{j}^{\mathrm{Yoplait}} Dummy variable for the “Yoplait” brand. @@ -226,7 +220,7 @@

Preference space model

This example will estimate the following mixed logit model in the preference space:

-

\[\begin{equation} +

uj=αpj+β1xjFeat+β2xjHiland+β3xjWeight+β4xjYoplait+εj\begin{equation} u_{j} = \alpha p_{j} + \beta_1 x_{j}^{\mathrm{Feat}} + @@ -235,13 +229,23 @@

Preference space model

-

where the parameters \(\alpha\), -\(\beta_1\), \(\beta_2\), \(\beta_3\), and \(\beta_4\) have units of utility. In the -example below, we will model \(\beta_1\), \(\beta_2\), \(\beta_3\), and \(\beta_4\) as normally -distributed across the population. As a result, the model will -estimate a mean and standard deviation for each of these -coefficients.

+\end{equation}

+

where the parameters +α\alpha, +β1\beta_1, +β2\beta_2, +β3\beta_3, +and +β4\beta_4 +have units of utility. In the example below, we will model +β1\beta_1, +β2\beta_2, +β3\beta_3, +and +β4\beta_4 +as normally distributed across the population. As a +result, the model will estimate a mean and standard deviation for each +of these coefficients.

Note that since the yogurt data has a panel structure (i.e. multiple choice observations for each respondent), it is necessary to set the panelID argument to the id @@ -352,15 +356,15 @@

Preference space modelwtp_mxl_pref <- wtp(mxl_pref, scalePar = "price") wtp_mxl_pref #> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.448338 0.039923 11.2302 < 2.2e-16 *** -#> feat 1.733046 0.500197 3.4647 0.0005308 *** -#> brandhiland -14.202148 1.390325 -10.2150 < 2.2e-16 *** -#> brandweight -8.182853 0.978981 -8.3585 < 2.2e-16 *** -#> brandyoplait 2.503674 0.411853 6.0791 1.209e-09 *** -#> sd_feat 1.265776 0.504768 2.5076 0.0121541 * -#> sd_brandhiland -7.096979 0.959459 -7.3969 1.394e-13 *** -#> sd_brandweight 9.138487 0.950027 9.6192 < 2.2e-16 *** -#> sd_brandyoplait 7.274160 0.772008 9.4224 < 2.2e-16 *** +#> scalePar 0.448338 0.039907 11.2345 < 2.2e-16 *** +#> feat 1.733046 0.501989 3.4524 0.0005557 *** +#> brandhiland -14.202148 1.388633 -10.2274 < 2.2e-16 *** +#> brandweight -8.182853 0.980394 -8.3465 < 2.2e-16 *** +#> brandyoplait 2.503674 0.412611 6.0679 1.296e-09 *** +#> sd_feat 1.265776 0.502743 2.5177 0.0118111 * +#> sd_brandhiland -7.096979 0.957852 -7.4093 1.270e-13 *** +#> sd_brandweight 9.138487 0.948231 9.6374 < 2.2e-16 *** +#> sd_brandyoplait 7.274160 0.771625 9.4271 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

@@ -369,7 +373,7 @@

WTP space model

This example will estimate the following mixed logit model in the WTP space:

-

\[\begin{equation} +

uj=λ(ω1xjFeat+ω2xjHiland+ω3xjWeight+ω4xjYoplaitpj)+εj\begin{equation} u_{j} = \lambda ( \omega_1 x_{j}^{\mathrm{Feat}} + @@ -379,15 +383,26 @@

WTP space model

-

where the parameters \(\omega_1\), -\(\omega_2\), \(\omega_3\), and \(\omega_4\) have units of dollars and \(\lambda\) is the scale parameter. In the -example below, we will model \(\omega_1\), \(\omega_2\), \(\omega_3\), and \(\omega_4\) as normally distributed across -the population. Note that this is a slightly different assumption than -in the preference space model. In the WTP space, we are assuming that -the WTP for these features is normally-distributed (as opposed to the -preference space model where the utility coefficients are assumed to -follow a normal distribution).

+\end{equation}

+

where the parameters +ω1\omega_1, +ω2\omega_2, +ω3\omega_3, +and +ω4\omega_4 +have units of dollars and +λ\lambda +is the scale parameter. In the example below, we will model +ω1\omega_1, +ω2\omega_2, +ω3\omega_3, +and +ω4\omega_4 +as normally distributed across the population. Note that this is a +slightly different assumption than in the preference space model. In the +WTP space, we are assuming that the WTP for these features is +normally-distributed (as opposed to the preference space model where the +utility coefficients are assumed to follow a normal distribution).

In the example below, we also use a 10-iteration multistart. We also set the starting values for the first iteration to the computed WTP from the preference space model:

@@ -607,7 +622,7 @@

Correlated heterogeneity

References

-
+
Jain, Dipak C, Naufel J Vilcassim, and Pradeep K Chintagunta. 1994. “A Random-Coefficients Logit Brand-Choice Model Applied to Panel @@ -634,9 +649,7 @@

References - -

+
@@ -649,16 +662,16 @@

References

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/predict.html b/articles/predict.html index 4cdd700..d4b4d42 100644 --- a/articles/predict.html +++ b/articles/predict.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
+#> 49 13 0.43686141 0.41571405 0.45793143 +#> 50 13 0.03312947 0.02649892 0.04223331 +#> 51 13 0.19154829 0.17575006 0.20763470 +#> 52 13 0.33846083 0.31869601 0.35867394 +#> 165 42 0.60767120 0.57401029 0.63990618 +#> 166 42 0.02601800 0.01837239 0.03665495 +#> 167 42 0.17802364 0.16177407 0.19447174 +#> 168 42 0.18828717 0.16762572 0.20856281

Here is a bar chart comparing the predicted probabilities from the preference space and WTP space models. Since both models are equivalent except in different spaces, the predicted probabilities are @@ -374,7 +368,7 @@

Predicting outcomes

References

-
+
Krinsky, Itzhak, and A Leslie Robb. 1986. “On Approximating the Statistical Properties of Elasticities.” The Review of @@ -386,9 +380,7 @@

References - -

+
@@ -401,16 +393,16 @@

References

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/summarizing_results.html b/articles/summarizing_results.html index 56bf44a..30a81bc 100644 --- a/articles/summarizing_results.html +++ b/articles/summarizing_results.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
+#> 3 brandyoplait 0.735 0.0806 9.11 0 0.577 0.892 +#> 4 feat 0.491 0.120 4.09 0.0000425 0.256 0.726 +#> 5 price -0.367 0.0244 -15.0 0 -0.415 -0.319
-
- - - - + + - + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + +1CI = Confidence Interval +
CharacteristicBeta -95% CI1 +CharacteristicBeta +95% CI1 p-valuep-value
brand


    dannon
    hiland -3.7-4.0, -3.4<0.001-4.0, -3.4
    weight -0.64-0.75, -0.53<0.001-0.75, -0.54
    yoplait 0.730.57, 0.90<0.0010.58, 0.89
feat 0.490.26, 0.73<0.0010.26, 0.73
price -0.37-0.42, -0.32<0.001-0.41, -0.32
-1 CI = Confidence Interval
@@ -811,23 +815,23 @@

The {gtsummary} package brand = "Yogurt's brand" ) ) -
- - - - + + - + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + +1CI = Confidence Interval +
CharacteristicBeta -95% CI1 +CharacteristicBeta +95% CI1 p-valuep-value
Yogurt's brand


    dannon
    hiland -3.7-4.0, -3.4<0.001-4.0, -3.4
    weight -0.64-0.75, -0.54<0.001-0.75, -0.53
    yoplait 0.730.58, 0.89<0.0010.58, 0.89
Newspaper ad shown? 0.490.26, 0.73<0.0010.26, 0.72
price -0.37-0.41, -0.32<0.001-0.41, -0.32
-1 CI = Confidence Interval
@@ -1344,23 +1358,23 @@

The {gtsummary} package tbls = list(t1, t2), tab_spanner = c("**Baseline**", "**Interaction**") ) -
- - - + - - - + - - - + + - + - - - - - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - - + + + - + +1CI = Confidence Interval +
Characteristic - Baseline +Characteristic + Baseline - Interaction + + Interaction
Beta -95% CI1 +Beta +95% CI1 p-valueBeta -95% CI1 + p-valueBeta +95% CI1 p-valuep-value
brand





    dannon

    hiland -3.7-4.0, -3.4<0.001-4.0, -3.4 + -3.7-4.0, -3.4<0.001-4.0, -3.4
    weight -0.64-0.75, -0.53<0.001-0.75, -0.53 + -0.64-0.75, -0.53<0.001-0.75, -0.54
    yoplait 0.730.58, 0.89<0.0010.57, 0.89 + 0.720.57, 0.88<0.0010.57, 0.88
feat 0.490.26, 0.73<0.0010.25, 0.73 + 1.20.41, 1.90.42, 1.9 0.002
price -0.37-0.41, -0.32<0.001-0.41, -0.32 + -0.36-0.41, -0.31<0.001-0.41, -0.31
price * feat


-0.09-0.18, 0.01-0.18, 0.01 0.068
-1 CI = Confidence Interval
@@ -1915,13 +1944,10 @@

The {texreg} package#> brandyoplait 0.73 *** #> (0.08) #> ---------------------------- +#> Num. obs. 2412 #> Log Likelihood -2656.89 -#> null.logLik -3343.74 #> AIC 5323.78 #> BIC 5352.72 -#> R^2 0.21 -#> Adj. R^2 0.20 -#> nobs 2412.00 #> ============================ #> *** p < 0.01; ** p < 0.05; * p < 0.1

Likewise, you can print the LaTeX code for a summary table using @@ -1948,13 +1974,10 @@

The {texreg} package#> brandyoplait & $0.73^{***}$ \\ #> & $(0.08)$ \\ #> \hline +#> Num. obs. & $2412$ \\ #> Log Likelihood & $-2656.89$ \\ -#> null.logLik & $-3343.74$ \\ #> AIC & $5323.78$ \\ #> BIC & $5352.72$ \\ -#> R$^2$ & $0.21$ \\ -#> Adj. R$^2$ & $0.20$ \\ -#> nobs & $2412.00$ \\ #> \hline #> \multicolumn{2}{l}{\scriptsize{$^{***}p<0.01$; $^{**}p<0.05$; $^{*}p<0.1$}} #> \end{tabular} @@ -1999,13 +2022,10 @@

The {texreg} package#> price:feat -0.09 * #> (0.05) #> ------------------------------------------ +#> Num. obs. 2412 2412 #> Log Likelihood -2656.89 -2655.54 -#> null.logLik -3343.74 -3343.74 #> AIC 5323.78 5323.08 #> BIC 5352.72 5357.81 -#> R^2 0.21 0.21 -#> Adj. R^2 0.20 0.20 -#> nobs 2412.00 2412.00 #> ========================================== #> *** p < 0.01; ** p < 0.05; * p < 0.1 @@ -2014,9 +2034,7 @@

The {texreg} package - - + @@ -2029,16 +2047,16 @@

The {texreg} package

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/articles/utility_models.html b/articles/utility_models.html index 4b08a95..9518926 100644 --- a/articles/utility_models.html +++ b/articles/utility_models.html @@ -12,25 +12,19 @@ - + - - - - - - - +
- +
@@ -129,7 +123,7 @@

Utility Models in the Preference & WTP Space

- Source: vignettes/utility_models.Rmd + Source: vignettes/utility_models.Rmd
@@ -164,55 +158,72 @@

The random utility model in two fields for estimating consumer preferences from observed consumer choices (Louviere, Hensher, and Swait 2000; Train 2009). Random utility models assume that consumers choose the -alternative \(j\) a set of alternatives -that has the greatest utility \(u_{j}\). Utility is a random variable that -is modeled as \(u_{j} = v_{j} + -\varepsilon_{j}\), where \(v_{j}\) is the “observed utility” (a -function of the observed attributes such that \(v_{j} = f(\mathrm{\mathbf{x}}_{j})\)) and -\(\varepsilon_{j}\) is a random -variable representing the portion of utility unobservable to the -modeler.

+alternative +jj +a set of alternatives that has the greatest utility +uju_{j}. +Utility is a random variable that is modeled as +uj=vj+εju_{j} = v_{j} + \varepsilon_{j}, +where +vjv_{j} +is the “observed utility” (a function of the observed attributes such +that +vj=f(𝐱j)v_{j} = f(\mathrm{\mathbf{x}}_{j})) +and +εj\varepsilon_{j} +is a random variable representing the portion of utility unobservable to +the modeler.

Adopting the same notation as in Helveston et al. (2018), consider the following utility model:

-

\[\begin{equation} +

uj*=𝛃*𝐱j+α*pj+εj*,εj*Gumbel(0,σ2π26)\begin{equation} u^*_{j} = \mathbf{β}^{*'} \mathrm{\mathbf{x}}_{j} + \alpha^{*} p_{j} + \varepsilon^{*}_{j}, \quad\quad - \varepsilon^{*}_{j} \sim \textrm{Gumbel}\left(0, -\sigma^2\frac{\pi^2}{6}\right) + \varepsilon^{*}_{j} \sim \textrm{Gumbel}\left(0, \sigma^2\frac{\pi^2}{6}\right) \label{eq:utility} -\end{equation}\]

-

where \(\mathbf{β}^{*}\) is the -vector of coefficients for non-price attributes \(\mathrm{\mathbf{x}}_{j}\), \(\alpha^{*}\) is the coefficient for price -\(p_{j}\), and the error term, \(\varepsilon^{*}_{j}\), is an IID random -variable with a Gumbel extreme value distribution of mean zero and -variance \(\sigma^2(\pi^2/6)\). This -model is not identified since there exists an infinite set of -combinations of values for \(\mathbf{β}^{*}\), \(\alpha^{*}\), and \(\sigma\) that produce the same choice -probabilities. In order to specify an identifiable model, the modeler -must normalize equation (\(\ref{eq:utility}\)). One approach is to -normalize the scale of the error term by dividing equation (\(\ref{eq:utility}\)) by \(\sigma\), producing the “preference space” -utility specification:

-

\[\begin{equation} +\end{equation}

+

where +𝛃*\mathbf{β}^{*} +is the vector of coefficients for non-price attributes +𝐱j\mathrm{\mathbf{x}}_{j}, +α*\alpha^{*} +is the coefficient for price +pjp_{j}, +and the error term, +εj*\varepsilon^{*}_{j}, +is an IID random variable with a Gumbel extreme value distribution of +mean zero and variance +σ2(π2/6)\sigma^2(\pi^2/6). +This model is not identified since there exists an infinite set of +combinations of values for +𝛃*\mathbf{β}^{*}, +α*\alpha^{*}, +and +σ\sigma +that produce the same choice probabilities. In order to specify an +identifiable model, the modeler must normalize equation (). One approach +is to normalize the scale of the error term by dividing equation () by +σ\sigma, +producing the “preference space” utility specification:

+

(uj*σ)=(𝛃*σ)𝐱j+(α*σ)pj+(εj*σ),(εj*σ)Gumbel(0,π26)\begin{equation} \left(\frac{u^*_{j}}{\sigma}\right) = - \left( \frac{\mathbf{β}^{*}}{\sigma} \right)' -\mathrm{\mathbf{x}}_{j} + + \left( \frac{\mathbf{β}^{*}}{\sigma} \right)' \mathrm{\mathbf{x}}_{j} + \left( \frac{\alpha^{*}}{\sigma} \right) p_{j} + \left( \frac{\varepsilon^{*}_{j}}{\sigma} \right), \quad\quad - \left( \frac{\varepsilon^{*}_{j}}{\sigma} \right) \sim -\textrm{Gumbel}\left(0, \frac{\pi^2}{6}\right) + \left( \frac{\varepsilon^{*}_{j}}{\sigma} \right) \sim \textrm{Gumbel}\left(0, \frac{\pi^2}{6}\right) \label{eq:utilityPreferenceScaled} -\end{equation}\]

+\end{equation}

The typical preference space parameterization of the multinomial -logit (MNL) model can then be written by rewriting equation (\(\ref{eq:utilityPreferenceScaled}\)) with -\(u_j = (u^*_j / \sigma)\), \(\mathbf{β}= (\mathbf{β}^{*} / \sigma)\), -\(\alpha = (\alpha^{*} / \sigma)\), and -\(\varepsilon_{j} = (\varepsilon^{*}_{j} / -\sigma)\):

-

\[\begin{equation} +logit (MNL) model can then be written by rewriting equation () with +uj=(uj*/σ)u_j = (u^*_j / \sigma), +𝛃=(𝛃*/σ)\mathbf{β}= (\mathbf{β}^{*} / \sigma), +α=(α*/σ)\alpha = (\alpha^{*} / \sigma), +and +εj=(εj*/σ)\varepsilon_{j} = (\varepsilon^{*}_{j} / \sigma):

+

$$\begin{equation} u_{j} = \mathbf{β}' \mathrm{\mathbf{x}}_{j} + \alpha p_{j} + @@ -221,35 +232,44 @@

The random utility model in two \varepsilon_{j} \sim \textrm{Gumbel}\left(0,\frac{\pi^2}{6}\right) \label{eq:utilityPreference} -\end{equation}\]

-

The vector \(\mathbf{β}\) represents -the marginal utility for changes in each non-price attribute, and \(\alpha\) represents the marginal utility -obtained from price reductions. In addition, the coefficients \(\mathbf{β}\) and \(\alpha\) are measured in units of -utility, which only has relative rather than absolute -meaning.

-

The alternative normalization approach is to normalize equation -(\(\ref{eq:utility}\)) by \(- \alpha^*\) instead of \(\sigma\), producing the “willingness-to-pay -(WTP) space” utility specification:

-

\[\begin{equation} +\end{equation}$$

+

The vector +𝛃\mathbf{β} +represents the marginal utility for changes in each non-price attribute, +and +α\alpha +represents the marginal utility obtained from price reductions. In +addition, the coefficients +𝛃\mathbf{β} +and +α\alpha +are measured in units of utility, which only has relative +rather than absolute meaning.

+

The alternative normalization approach is to normalize equation () by +α*- \alpha^* +instead of +σ\sigma, +producing the “willingness-to-pay (WTP) space” utility +specification:

+

(uj*α*)=(𝛃*α*)𝐱j+(α*α*)pj+(εj*α*),(εj*α*)Gumbel(0,σ2(α*)2π26)\begin{equation} \left(\frac{u^*_{j}}{- \alpha^*}\right) = - \left(\frac{\mathbf{β}^{*}}{- \alpha^{*}}\right)' -\mathrm{\mathbf{x}}_{j} + + \left(\frac{\mathbf{β}^{*}}{- \alpha^{*}}\right)' \mathrm{\mathbf{x}}_{j} + \left(\frac{\alpha^{*}}{- \alpha^{*}}\right) p_{j} + \left(\frac{\varepsilon^{*}_{j}}{- \alpha^{*}}\right), \quad\quad - \left(\frac{\varepsilon^{*}_{j}}{- \alpha^{*}}\right) \sim -\textrm{Gumbel} \left(0, \frac{\sigma^2}{(- -\alpha^{*})^2}\frac{\pi^2}{6} \right) + \left(\frac{\varepsilon^{*}_{j}}{- \alpha^{*}}\right) \sim \textrm{Gumbel} \left(0, \frac{\sigma^2}{(- \alpha^{*})^2}\frac{\pi^2}{6} \right) \label{eq:utilityWtpScaled} -\end{equation}\]

-

Since the error term in equation is scaled by \(\lambda^2 = \sigma^2/(- \alpha^{*})^2\), we -can rewrite equation (\(\ref{eq:utilityWtpScaled}\)) by multiplying -both sides by \(\lambda= (- \alpha^{*} / -\sigma\)) and renaming \(u_j = (\lambda -u^*_j /- \alpha^*)\), \(\mathbf{ω}= -(\mathbf{β}^{*} /- \alpha^{*}\)), and \(\varepsilon_j = (\lambda \varepsilon^*_j / - -\alpha^*)\):

-

\[\begin{equation} +\end{equation}

+

Since the error term in equation is scaled by +λ2=σ2/(α*)2\lambda^2 = \sigma^2/(- \alpha^{*})^2, +we can rewrite equation () by multiplying both sides by +λ=(α*/σ\lambda= (- \alpha^{*} / \sigma) +and renaming +uj=(λuj*/α*)u_j = (\lambda u^*_j /- \alpha^*), +𝛚=(𝛃*/α*\mathbf{ω}= (\mathbf{β}^{*} /- \alpha^{*}), +and +εj=(λεj*/α*)\varepsilon_j = (\lambda \varepsilon^*_j / - \alpha^*):

+

$$\begin{equation} u_{j} = \lambda \left( \mathbf{ω}' \mathrm{\mathbf{x}}_{j} - p_{j} @@ -259,21 +279,24 @@

The random utility model in two \varepsilon_{j} \sim \textrm{Gumbel}\left(0, \frac{\pi^2}{6}\right) \label{eq:utilityWtp} -\end{equation}\]

-

Here \(\mathbf{ω}\) represents the -marginal WTP for changes in each non-price attribute, and \(\lambda\) represents the scale of the -deterministic portion of utility relative to the standardized scale of -the random error term.

-

The utility models in equations \(\ref{eq:utilityPreference}\) and \(\ref{eq:utilityWtp}\) represent the -preference space and WTP space utility specifications, respectively. In -equation \(\ref{eq:utilityPreference}\), WTP is -estimated as \(\hat{\mathbf{β}} / \hat{- -\alpha}\); in equation \(\ref{eq:utilityWtp}\), WTP is simply \(\hat{\mathbf{ω}}\).

+\end{equation}$$

+

Here +𝛚\mathbf{ω} +represents the marginal WTP for changes in each non-price attribute, and +λ\lambda +represents the scale of the deterministic portion of utility relative to +the standardized scale of the random error term.

+

The utility models in equations and represent the preference space +and WTP space utility specifications, respectively. In equation , WTP is +estimated as +𝛃̂/α̂\hat{\mathbf{β}} / \hat{- \alpha}; +in equation , WTP is simply +𝛚̂\hat{\mathbf{ω}}.

References

-
+
Helveston, John Paul, Elea McDonnell Feit, and Jeremy J. Michalek. 2018. Pooling stated and revealed preference data @@ -300,9 +323,7 @@

References - -

+
@@ -315,16 +336,16 @@

References

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/authors.html b/authors.html index b1329bd..0fdd4f4 100644 --- a/authors.html +++ b/authors.html @@ -1,9 +1,9 @@ -Authors and Citation • logitrAuthors and Citation • logitr - +
- +
- +
  • John Helveston. Author, maintainer, copyright holder.

  • -

    Connor Forsythe. Contributor. +

    Connor Forsythe. Contributor.

Citation

- Source: inst/CITATION + Source: inst/CITATION
@@ -114,7 +114,7 @@

Citation

Helveston JP (2023). “logitr: Fast Estimation of Multinomial and Mixed Logit Models with Preference Space and Willingness-to-Pay Space Utility Parameterizations.” Journal of Statistical Software, 105(10), 1–37. -doi:10.18637/jss.v105.i10. +doi:10.18637/jss.v105.i10.

@Article{,
   title = {{logitr}: Fast Estimation of Multinomial and Mixed Logit Models with Preference Space and Willingness-to-Pay Space Utility Parameterizations},
@@ -138,15 +138,15 @@ 

Citation

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/index.html b/index.html index 2a1caac..3d0ebcd 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ - + @@ -30,7 +30,7 @@ - +
- +
@@ -264,16 +264,16 @@

Dev status

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/news/index.html b/news/index.html index ef51b67..2c7a4df 100644 --- a/news/index.html +++ b/news/index.html @@ -1,9 +1,9 @@ -Changelog • logitrChangelog • logitr - +
- +
- +
  • Updated the convergence.Rmd vignette to not run any actual code using other packages to fix issue on CRAN where not all packages are available on all platforms. Now the results are hard-coded in place.
  • Fixed bug in makeObsID() where table() was sorting the results stored in reps, which has to be manually undone. Fixes #50.
@@ -428,15 +428,15 @@
- - + + diff --git a/pkgdown.yml b/pkgdown.yml index 4df0faf..564e819 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -1,5 +1,5 @@ -pandoc: 2.19.2 -pkgdown: 2.0.7 +pandoc: 3.1.11 +pkgdown: 2.1.0 pkgdown_sha: ~ articles: basic_usage: basic_usage.html @@ -7,14 +7,13 @@ articles: convergence: convergence.html data_formatting: data_formatting.html interactions: interactions.html - mnl_models: mnl_models.html mnl_models_weighted: mnl_models_weighted.html + mnl_models: mnl_models.html mxl_models: mxl_models.html predict: predict.html summarizing_results: summarizing_results.html utility_models: utility_models.html -last_built: 2023-09-27T15:08Z +last_built: 2024-07-23T23:41Z urls: reference: https://jhelvy.github.io/logitr/reference article: https://jhelvy.github.io/logitr/articles - diff --git a/reference/apolloModeChoiceData.html b/reference/apolloModeChoiceData.html index 8450909..bf3621b 100644 --- a/reference/apolloModeChoiceData.html +++ b/reference/apolloModeChoiceData.html @@ -1,5 +1,5 @@ -Simulated SP dataset of mode choice (from the apollo package). — apolloModeChoiceData • logitrSimulated SP dataset of mode choice (from the apollo package). — apolloModeChoiceData • logitr - +
- +
@@ -114,7 +114,7 @@

Simulated SP dataset of mode choice (from the apollo package).

Format

- +
VariableDescription
IDindividual identifiers
obsIDidentifier for unique choice observation
altIDalternative in each choice observation
qIDNumeric. Consecutive ID of SP choice tasks.
choicedummy code for choice (1 or 0)
modeCharacter describing mode: "air", "rail", "car", "bus"
timeTravel time in minutes.
costcost (in GBP) of trip.
accessAccess time in minutes.
serviceNumeric. Additional services: 1 for no-frills, 2 for wifi, 3 for food.
mode_airDummy coefficient for "air" mode.
mode_busDummy coefficient for "bus" mode.
mode_carDummy coefficient for "car" mode.
mode_railDummy coefficient for "rail" mode.
service_no_frillsDummy coefficient for "no-frills" additional service.
service_wifiDummy coefficient for "wifi" additional service.
service_foodDummy coefficient for "food" additional service.
time_carTravel time (in minutes) for car trip.
time_busTravel time (in minutes) for bus trip.
time_airTravel time (in minutes) for air trip.
time_railTravel time (in minutes) for rail trip.
femaleNumeric. Sex of individual. 1 for female, 0 for male.
businessNumeric. Purpose of the trip. 1 for business, 0 for other.
incomeNumeric. Income (in GBP per annum) of the individual.

Source

@@ -158,15 +158,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/augment.html b/reference/augment.html new file mode 100644 index 0000000..a60098e --- /dev/null +++ b/reference/augment.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/augment.logitr.html b/reference/augment.logitr.html index e10ba2d..3321b0b 100644 --- a/reference/augment.logitr.html +++ b/reference/augment.logitr.html @@ -1,9 +1,9 @@ -Glance a logitr class object — augment.logitr • logitrGlance a logitr class object — augment.logitr • logitr - +
- +
@@ -99,45 +99,45 @@

Glance a logitr class object

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 augment(x, newdata = NULL, obsID = NULL, type = "prob", ...)

Arguments

-
x
+ + +
x

is an object of class logitr.

-
newdata
+
newdata

a data.frame. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model. Defaults to NULL, in which case predictions are made on the original data used to estimate the model.

-
obsID
+
obsID

The name of the column that identifies each set of alternatives in the data. Required if newdata != NULL. Defaults to NULL, in which case the value for obsID from the data in object is used.

-
type
+
type

A character vector defining what to predict: prob for probabilities, outcomes for outcomes. If you want both outputs, use c("prob", "outcome"). Outcomes are predicted randomly according to the predicted probabilities. Defaults to "prob".

-
...
+
...

further arguments.

Value

- - -

A tibble of ...

+

A tibble of ...

@@ -9820,15 +9820,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/cars_china.html b/reference/cars_china.html index 091ffc0..0bb24f6 100644 --- a/reference/cars_china.html +++ b/reference/cars_china.html @@ -1,5 +1,5 @@ -Stated car choice observations by Chinese car buyers — cars_china • logitrStated car choice observations by Chinese car buyers — cars_china • logitr - +
- +
@@ -116,7 +116,7 @@

Stated car choice observations by Chinese car buyers

Format

- +
VariableDescription
idindividual identifiers
obsnumidentifier for unique choice observation
choicedummy code for choice (1 or 0)
hevdummy code for HEV vehicle type (1 or 0)
phev10dummy code for PHEV vehicle type w/10 mile electric driving range (1 or 0)
phev20dummy code for PHEV vehicle type w/20 mile electric driving range (1 or 0)
phev40dummy code for PHEV vehicle type w/40 mile electric driving range (1 or 0)
bev75dummy code for BEV vehicle type w/75 mile electric driving range (1 or 0)
bev100dummy code for BEV vehicle type w/100 mile electric driving range (1 or 0)
bev150dummy code for BEV vehicle type w/150 mile electric driving range (1 or 0)
phevFastchargedummy code for whether PHEV vehicle had fast charging capability (1 or 0)
bevFastchargedummy code for whether BEV vehicle had fast charging capability (1 or 0)
priceprice of vehicle ($USD)
opCostoperating cost of vehicle (US cents / mile)
accelTime0-60 mph acceleration time (seconds)
americandummy code for whether American brand (1 or 0)
japanesedummy code for whether Japanese brand (1 or 0)
chinesedummy code for whether Chinese brand (1 or 0)
skoreandummy code for whether S. Korean brand (1 or 0)
weightsweights for each individual computed so that the sample age and income demographics matched with those of the general car-buying population

Source

@@ -162,15 +162,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/cars_us.html b/reference/cars_us.html index 9d00b98..56812f4 100644 --- a/reference/cars_us.html +++ b/reference/cars_us.html @@ -1,5 +1,5 @@ -Stated car choice observations by US car buyers — cars_us • logitrStated car choice observations by US car buyers — cars_us • logitr - +
- +
@@ -116,7 +116,7 @@

Stated car choice observations by US car buyers

Format

- +
VariableDescription
idindividual identifiers
obsnumidentifier for unique choice observation
choicedummy code for choice (1 or 0)
hevdummy code for HEV vehicle type (1 or 0)
phev10dummy code for PHEV vehicle type w/10 mile electric driving range (1 or 0)
phev20dummy code for PHEV vehicle type w/20 mile electric driving range (1 or 0)
phev40dummy code for PHEV vehicle type w/40 mile electric driving range (1 or 0)
bev75dummy code for BEV vehicle type w/75 mile electric driving range (1 or 0)
bev100dummy code for BEV vehicle type w/100 mile electric driving range (1 or 0)
bev150dummy code for BEV vehicle type w/150 mile electric driving range (1 or 0)
phevFastchargedummy code for whether PHEV vehicle had fast charging capability (1 or 0)
bevFastchargedummy code for whether BEV vehicle had fast charging capability (1 or 0)
priceprice of vehicle ($USD)
opCostoperating cost of vehicle (US cents / mile)
accelTime0-60 mph acceleration time (seconds)
americandummy code for whether American brand (1 or 0)
japanesedummy code for whether Japanese brand (1 or 0)
chinesedummy code for whether Chinese brand (1 or 0)
skoreandummy code for whether S. Korean brand (1 or 0)
weightsweights for each individual computed so that the sample age and income demographics matched with those of the general car-buying population

Source

@@ -162,15 +162,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/ci.html b/reference/ci.html index a22bd6d..837507a 100644 --- a/reference/ci.html +++ b/reference/ci.html @@ -1,11 +1,11 @@ -Obtain a confidence interval from coefficient draws — ci • logitrObtain a confidence interval from coefficient draws — ci • logitr - +
- +
@@ -108,11 +108,13 @@

Obtain a confidence interval from coefficient draws

Arguments

-
df
+ + +
df

A data frame of draws with all numeric columns.

-
level
+
level

The sensitivity of the computed confidence interval (CI). Defaults to level = 0.95, reflecting a 95% CI.

@@ -140,11 +142,11 @@

Examples

# Compute a confidence interval ci(coef_draws, level = 0.95) #> mean lower upper -#> price -0.3666291 -0.4142882 -0.3191139 -#> feat 0.4927960 0.2562836 0.7325867 -#> brandhiland -3.7160380 -3.9957829 -3.4244018 -#> brandweight -0.6413447 -0.7478007 -0.5337463 -#> brandyoplait 0.7350232 0.5760561 0.8904558 +#> price -0.3667863 -0.4132753 -0.3201336 +#> feat 0.4895536 0.2535630 0.7233272 +#> brandhiland -3.7150454 -3.9958466 -3.4308442 +#> brandweight -0.6414277 -0.7465211 -0.5361054 +#> brandyoplait 0.7355449 0.5771616 0.8900335
@@ -160,15 +162,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/coef.logitr.html b/reference/coef.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/coef.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/coef.summary.logitr.html b/reference/coef.summary.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/coef.summary.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/confint.logitr.html b/reference/confint.logitr.html index 58e39a6..4b56a1e 100644 --- a/reference/confint.logitr.html +++ b/reference/confint.logitr.html @@ -1,9 +1,9 @@ -Extract Model Confidence Interval — confint.logitr • logitrExtract Model Confidence Interval — confint.logitr • logitr - +
- +
@@ -99,36 +99,36 @@

Extract Model Confidence Interval

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 confint(object, parm, level = 0.95, ...)

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
parm
+
parm

A specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered.

-
level
+
level

The confidence level required.

-
...
+
...

further arguments.

Value

- - -

A data frame of the confidence intervals of model coefficients.

+

A data frame of the confidence intervals of model coefficients.

@@ -148,11 +148,11 @@

Examples

# Compute a confidence interval confint(mnl_pref) #> 2.5 % 97.5 % -#> price -0.4148379 -0.3205359 -#> feat 0.2508031 0.7229301 -#> brandhiland -3.9971858 -3.4302625 -#> brandweight -0.7464769 -0.5336879 -#> brandyoplait 0.5768316 0.8953710 +#> price -0.4147620 -0.3183283 +#> feat 0.2525613 0.7273760 +#> brandhiland -4.0019537 -3.4235527 +#> brandweight -0.7462722 -0.5360062 +#> brandyoplait 0.5779527 0.8956858
@@ -167,15 +167,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/dummyCode.html b/reference/dummyCode.html index b2f8e8f..60a620d 100644 --- a/reference/dummyCode.html +++ b/reference/dummyCode.html @@ -1,9 +1,9 @@ -Add dummy-coded variables to data frame. — dummyCode • logitrAdd dummy-coded variables to data frame. — dummyCode • logitr - +
- +
@@ -104,20 +104,20 @@

Add dummy-coded variables to data frame.

Arguments

-
df
+ + +
df

A data frame.

-
vars
+
vars

The variables in the data frame for which you want to create new dummy coded variables.

Value

- - -

A a dataframe with new dummy-coded variables added.

+

A a dataframe with new dummy-coded variables added.

@@ -132,15 +132,15 @@

Value

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/electricity.html b/reference/electricity.html index 8f4c4cd..82acbfa 100644 --- a/reference/electricity.html +++ b/reference/electricity.html @@ -1,9 +1,9 @@ -Stated preference data for the choice of electricity suppliers (from mlogit package) — electricity • logitrStated preference data for the choice of electricity suppliers (from mlogit package) — electricity • logitr - +
- +
@@ -104,7 +104,7 @@

Stated preference data for the choice of electricity suppliers (from mlogit

Format

- +
VariableDescription
idindividual identifiers
obsIDidentifier for unique choice observation
choicedummy code for choice (1 or 0)
altalternative in each choice observation
pffixed price at a stated cents per kWh, with the price varying over suppliers and experiments, for scenario i=(1, 2, 3, 4),
clthe length of contract that the supplier offered, in years (such as 1 year or 5 years.) During this contract period, the supplier guaranteed the prices and the buyer would have to pay a penalty if he/she switched to another supplier. The supplier could offer no contract in which case either side could stop the agreement at any time. This is recorded as a contract length of 0.
locis the supplier a local company.
wkis the supplier a well-known company.
toda time-of-day rate under which the price is 11 cents per kWh from 8am to 8pm and 5 cents per kWh from 8pm to 8am. These TOD prices did not vary over suppliers or experiments: whenever the supplier was said to offer TOD, the prices were stated as above.
seasa seasonal rate under which the price is 10 cents per kWh in the summer, 8 cents per kWh in the winter, and 6 cents per kWh in the spring and fall. Like TOD rates, these prices did not vary. Note that the price is for the electricity only, not transmission and distribution, which is supplied by the local regulated utility.

Source

@@ -142,15 +142,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/fitted.logitr.html b/reference/fitted.logitr.html index 6f0f554..36f34cc 100644 --- a/reference/fitted.logitr.html +++ b/reference/fitted.logitr.html @@ -1,9 +1,9 @@ -Extract Model Fitted Values — fitted.logitr • logitrExtract Model Fitted Values — fitted.logitr • logitr - +
- +
@@ -99,31 +99,31 @@

Extract Model Fitted Values

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 fitted(object, probs = NULL, ...)

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
probs
+
probs

Predicted probabilities for an object of class logitr to use in computing fitted values Defaults to NULL.

-
...
+
...

further arguments.

Value

- - -

A data frame of the obsID and the fitted values extracted from +

A data frame of the obsID and the fitted values extracted from object.

@@ -2570,15 +2570,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/fquantile.html b/reference/fquantile.html index 118aac6..e342eec 100644 --- a/reference/fquantile.html +++ b/reference/fquantile.html @@ -1,5 +1,5 @@ -Predict probabilities and / or outcomes — fquantile • logitr - +
- +
@@ -118,27 +118,27 @@

Predict probabilities and / or outcomes

Arguments

-
x
+ + +
x

numeric vector whose sample quantiles are wanted. NA and NaN values are not allowed in numeric vectors unless na.rm is TRUE.

-
probs
+
probs

numeric vector of probabilities with values in [0,1]. (Values up to 2e-14 outside that range are accepted and moved to the nearby endpoint.)

-
na.rm
+
na.rm

logical; if TRUE, any NA and NaN's are removed from x before the quantiles are computed.

Value

- - -

A vector of length length(probs) is returned;

+

A vector of length length(probs) is returned;

@@ -159,15 +159,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/glance.html b/reference/glance.html new file mode 100644 index 0000000..a60098e --- /dev/null +++ b/reference/glance.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/glance.logitr.html b/reference/glance.logitr.html index 8ae100e..f3b409f 100644 --- a/reference/glance.logitr.html +++ b/reference/glance.logitr.html @@ -1,9 +1,9 @@ -Glance a logitr class object — glance.logitr • logitrGlance a logitr class object — glance.logitr • logitr - +
- +
@@ -99,25 +99,25 @@

Glance a logitr class object

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 glance(x, ...)

Arguments

-
x
+ + +
x

is an object of class logitr.

-
...
+
...

further arguments.

Value

- - -

A tibble of the model summary statistics.

+

A tibble of the model summary statistics.

@@ -155,15 +155,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/index.html b/reference/index.html index c091f95..b1ea531 100644 --- a/reference/index.html +++ b/reference/index.html @@ -1,9 +1,9 @@ -Function reference • logitrPackage index • logitr - +
- +
@@ -99,9 +99,7 @@

Encoding Data

recodeData()

-

Returns a list of the design matrix X and updated pars and -randPars to include any dummy-coded categorical or interaction -variables.

+

Returns a list of the design matrix X and updated pars and randPars to include any dummy-coded categorical or interaction variables.

Estimating Models

Functions for estimating multinomial logit models with preference space and WTP space utility parameterizations.

@@ -251,15 +249,15 @@

Other Helpers
-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/logLik.logitr.html b/reference/logLik.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/logLik.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/logit_probs.html b/reference/logit_probs.html index 8b69567..4eb1f28 100644 --- a/reference/logit_probs.html +++ b/reference/logit_probs.html @@ -1,5 +1,5 @@ -Compute logit fraction for sets of alternatives given coefficient draws — logit_probs • logitrCompute logit fraction for sets of alternatives given coefficient draws — logit_probs • logitr - +
- +
@@ -122,27 +122,29 @@

Compute logit fraction for sets of alternatives given coefficient draws

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
coef_draws
+
coef_draws

A data frame of coefficients draws.

-
newdata
+
newdata

A data frame of sets of alternatives for which to compute logit probabilities. Each row is an alternative.

-
obsID
+
obsID

The name of the column in newdata that identifies each set of alternatives. Defaults to NULL, in which case it assumes the newdata are all one choice scenario.

-
level
+
level

The sensitivity of the computed confidence interval (CI). Defaults to level = 0.95, reflecting a 95% CI.

@@ -200,15 +202,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/logitr.html b/reference/logitr.html index 9585dbd..7c20531 100644 --- a/reference/logitr.html +++ b/reference/logitr.html @@ -1,5 +1,5 @@ -The main function for estimating logit models — logitr • logitr - +
- +
@@ -153,67 +153,69 @@

The main function for estimating logit models

Arguments

-
data
+ + +
data

The data, formatted as a data.frame object.

-
outcome
+
outcome

The name of the column that identifies the outcome variable, which should be coded with a 1 for TRUE and 0 for FALSE.

-
obsID
+
obsID

The name of the column that identifies each observation.

-
pars
+
pars

The names of the parameters to be estimated in the model. Must be the same as the column names in the data argument. For WTP space models, do not include the scalePar variable in pars.

-
scalePar
+
scalePar

The name of the column that identifies the scale variable, which is typically "price" for WTP space models, but could be any continuous variable, such as "time". Defaults to NULL.

-
randPars
+
randPars

A named vector whose names are the random parameters and values the distribution: 'n' for normal, 'ln' for log-normal, or 'cn' for zero-censored normal. Defaults to NULL.

-
randScale
+
randScale

The random distribution for the scale parameter: 'n' for normal, 'ln' for log-normal, or 'cn' for zero-censored normal. Only used for WTP space MXL models. Defaults to NULL.

-
modelSpace
+
modelSpace

This argument is no longer needed as of v0.7.0. The model space is now determined based on the scalePar argument: if NULL (the default), the model will be in the preference space, otherwise it will be in the WTP space. Defaults to NULL.

-
weights
+
weights

The name of the column that identifies the weights to be used in model estimation. Defaults to NULL.

-
panelID
+
panelID

The name of the column that identifies the individual (for panel data where multiple observations are recorded for each individual). Defaults to NULL.

-
clusterID
+
clusterID

The name of the column that identifies the cluster groups to be used in model estimation. Defaults to NULL.

-
robust
+
robust

Determines whether or not a robust covariance matrix is estimated. Defaults to FALSE. Specification of a clusterID or weights will override the user setting and set this to `TRUE' (a @@ -221,38 +223,38 @@

Arguments

Stata's cmcmmixlogit.

-
correlation
+
correlation

Set to TRUE to account for correlation across random parameters (correlated heterogeneity). Defaults to FALSE.

-
startValBounds
+
startValBounds

sets the lower and upper bounds for the starting parameter values for each optimization run, which are generated by runif(n, lower, upper). Defaults to c(-1, 1).

-
startVals
+
startVals

is vector of values to be used as starting values for the optimization. Only used for the first run if numMultiStarts > 1. Defaults to NULL.

-
numMultiStarts
+
numMultiStarts

is the number of times to run the optimization loop, each time starting from a different random starting point for each parameter between startValBounds. Recommended for non-convex models, such as WTP space models and mixed logit models. Defaults to 1.

-
useAnalyticGrad
+
useAnalyticGrad

Set to FALSE to use numerically approximated gradients instead of analytic gradients during estimation. For now, using the analytic gradient is faster for MNL models but slower for MXL models. Defaults to TRUE.

-
scaleInputs
+
scaleInputs

By default each variable in data is scaled to be between 0 and 1 before running the optimization routine because it usually helps with stability, especially if some of the variables have very large or @@ -260,108 +262,106 @@

Arguments

feature off. Defaults to TRUE.

-
standardDraws
+
standardDraws

By default, a new set of standard normal draws are generated during each call to logitr (the same draws are used during each multistart iteration). The user can override those draws by providing a matrix of standard normal draws if desired. Defaults to NULL.

-
drawType
+
drawType

Specify the draw type as a character: "halton" (the default) or "sobol" (recommended for models with more than 5 random parameters).

-
numDraws
+
numDraws

The number of Halton draws to use for MXL models for the maximum simulated likelihood. Defaults to 50.

-
numCores
+
numCores

The number of cores to use for parallel processing of the multistart. Set to 1 to serially run the multistart. Defaults to NULL, in which case the number of cores is set to parallel::detectCores() - 1. Max cores allowed is capped at parallel::detectCores().

-
vcov
+
vcov

Set to TRUE to evaluate and include the variance-covariance matrix and coefficient standard errors in the returned object. Defaults to FALSE.

-
predict
+
predict

If FALSE, predicted probabilities, fitted values, and residuals are not included in the returned object. Defaults to TRUE.

-
options
+
options

A list of options for controlling the nloptr() optimization. -Run nloptr::nloptr.print.options() for details.

+Run nloptr::nloptr.print.options() for details.

-
price
+
price

No longer used as of v0.7.0 - if provided, this is passed to the scalePar argument and a warning is displayed.

-
randPrice
+
randPrice

No longer used as of v0.7.0 - if provided, this is passed to the randScale argument and a warning is displayed.

-
choice
+
choice

No longer used as of v0.4.0 - if provided, this is passed to the outcome argument and a warning is displayed.

-
parNames
+
parNames

No longer used as of v0.2.3 - if provided, this is passed to the pars argument and a warning is displayed.

-
choiceName
+
choiceName

No longer used as of v0.2.3 - if provided, this is passed to the outcome argument and a warning is displayed.

-
obsIDName
+
obsIDName

No longer used as of v0.2.3 - if provided, this is passed to the obsID argument and a warning is displayed.

-
priceName
+
priceName

No longer used as of v0.2.3 - if provided, this is passed to the scalePar argument and a warning is displayed.

-
weightsName
+
weightsName

No longer used as of v0.2.3 - if provided, this is passed to the weights argument and a warning is displayed.

-
clusterName
+
clusterName

No longer used as of v0.2.3 - if provided, this is passed to the clusterID argument and a warning is displayed.

-
cluster
+
cluster

No longer used as of v0.2.3 - if provided, this is passed to the clusterID argument and a warning is displayed.

Value

- - -

The function returns a list object containing the following objects.

ValueDescription
coefficientsThe model coefficients at convergence.
logLikThe log-likelihood value at convergence.
nullLogLikThe null log-likelihood value (if all coefficients are 0).
gradientThe gradient of the log-likelihood at convergence.
hessianThe hessian of the log-likelihood at convergence.
probabilitiesPredicted probabilities. Not returned if predict = FALSE.
fitted.valuesFitted values. Not returned if predict = FALSE.
residualsResiduals. Not returned if predict = FALSE.
startValsThe starting values used.
multistartNumberThe multistart run number for this model.
multistartSummaryA summary of the log-likelihood values for each multistart run (if more than one multistart was used).
timeThe user, system, and elapsed time to run the optimization.
iterationsThe number of iterations until convergence.
messageA more informative message with the status of the optimization result.
statusAn integer value with the status of the optimization (positive values are successes). Use statusCodes() for a detailed description.
callThe matched call to logitr().
inputsA list of the original inputs to logitr().
dataA list of the original data provided to logitr() broken up into components used during model estimation.
numObsThe number of observations.
numParamsThe number of model parameters.
freqThe frequency counts of each alternative.
modelTypeThe model type, 'mnl' for multinomial logit or 'mxl' for mixed logit.
weightsUsedTRUE or FALSE for whether weights were used in the model.
numClustersThe number of clusters.
parSetupA summary of the distributional assumptions on each model parameter ("f"="fixed", "n"="normal distribution", "ln"="log-normal distribution").
parIDsA list identifying the indices of each parameter in coefficients by a variety of types.
scaleFactorsA vector of the scaling factors used to scale each coefficient during estimation.
standardDrawsThe draws used during maximum simulated likelihood (for MXL models).
optionsA list of options for controlling the nloptr() optimization. Run nloptr::nloptr.print.options() for details.
+

The function returns a list object containing the following objects.

ValueDescription
coefficientsThe model coefficients at convergence.
logLikThe log-likelihood value at convergence.
nullLogLikThe null log-likelihood value (if all coefficients are 0).
gradientThe gradient of the log-likelihood at convergence.
hessianThe hessian of the log-likelihood at convergence.
probabilitiesPredicted probabilities. Not returned if predict = FALSE.
fitted.valuesFitted values. Not returned if predict = FALSE.
residualsResiduals. Not returned if predict = FALSE.
startValsThe starting values used.
multistartNumberThe multistart run number for this model.
multistartSummaryA summary of the log-likelihood values for each multistart run (if more than one multistart was used).
timeThe user, system, and elapsed time to run the optimization.
iterationsThe number of iterations until convergence.
messageA more informative message with the status of the optimization result.
statusAn integer value with the status of the optimization (positive values are successes). Use statusCodes() for a detailed description.
callThe matched call to logitr().
inputsA list of the original inputs to logitr().
dataA list of the original data provided to logitr() broken up into components used during model estimation.
numObsThe number of observations.
numParamsThe number of model parameters.
freqThe frequency counts of each alternative.
modelTypeThe model type, 'mnl' for multinomial logit or 'mxl' for mixed logit.
weightsUsedTRUE or FALSE for whether weights were used in the model.
numClustersThe number of clusters.
parSetupA summary of the distributional assumptions on each model parameter ("f"="fixed", "n"="normal distribution", "ln"="log-normal distribution").
parIDsA list identifying the indices of each parameter in coefficients by a variety of types.
scaleFactorsA vector of the scaling factors used to scale each coefficient during estimation.
standardDrawsThe draws used during maximum simulated likelihood (for MXL models).
optionsA list of options for controlling the nloptr() optimization. Run nloptr::nloptr.print.options() for details.

Details

The the options argument is used to control the detailed behavior of the optimization and must be passed as a list, e.g. options = list(...). Below are a list of the default options, but other options can be included. -Run nloptr::nloptr.print.options() for more details.

ArgumentDescriptionDefault
xtol_relThe relative x tolerance for the nloptr optimization loop.1.0e-6
xtol_absThe absolute x tolerance for the nloptr optimization loop.1.0e-6
ftol_relThe relative f tolerance for the nloptr optimization loop.1.0e-6
ftol_absThe absolute f tolerance for the nloptr optimization loop.1.0e-6
maxevalThe maximum number of function evaluations for the nloptr optimization loop.1000
algorithmThe optimization algorithm that nloptr uses."NLOPT_LD_LBFGS"
print_levelThe print level of the nloptr optimization loop.0
+Run nloptr::nloptr.print.options() for more details.

ArgumentDescriptionDefault
xtol_relThe relative x tolerance for the nloptr optimization loop.1.0e-6
xtol_absThe absolute x tolerance for the nloptr optimization loop.1.0e-6
ftol_relThe relative f tolerance for the nloptr optimization loop.1.0e-6
ftol_absThe absolute f tolerance for the nloptr optimization loop.1.0e-6
maxevalThe maximum number of function evaluations for the nloptr optimization loop.1000
algorithmThe optimization algorithm that nloptr uses."NLOPT_LD_LBFGS"
print_levelThe print level of the nloptr optimization loop.0

Examples

@@ -391,7 +391,7 @@

Examples

) #> Running multistart... #> Random starting point iterations: 5 -#> Number of cores: 3 +#> Number of cores: 2 #> Done! # Estimate a MXL model in the Preference space with "feat" @@ -421,15 +421,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/miscmethods.logitr.html b/reference/miscmethods.logitr.html index c27d58a..833a627 100644 --- a/reference/miscmethods.logitr.html +++ b/reference/miscmethods.logitr.html @@ -1,9 +1,9 @@ -Methods for logitr objects — miscmethods.logitr • logitrMethods for logitr objects — miscmethods.logitr • logitr - +
- +
@@ -99,22 +99,22 @@

Methods for logitr objects

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 logLik(object, ...)
 
-# S3 method for logitr
+# S3 method for class 'logitr'
 terms(x, ...)
 
-# S3 method for logitr
+# S3 method for class 'logitr'
 coef(object, ...)
 
-# S3 method for summary.logitr
+# S3 method for class 'summary.logitr'
 coef(object, ...)
 
-# S3 method for logitr
+# S3 method for class 'logitr'
 summary(object, ...)
 
-# S3 method for logitr
+# S3 method for class 'logitr'
 print(
   x,
   digits = max(3, getOption("digits") - 2),
@@ -122,7 +122,7 @@ 

Methods for logitr objects

... ) -# S3 method for summary.logitr +# S3 method for class 'summary.logitr' print( x, digits = max(3, getOption("digits") - 2), @@ -130,7 +130,7 @@

Methods for logitr objects

... ) -# S3 method for logitr_wtp +# S3 method for class 'logitr_wtp' print( x, digits = max(3, getOption("digits") - 2), @@ -141,24 +141,26 @@

Methods for logitr objects

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
...
+
...

further arguments.

-
x
+
x

is an object of class logitr.

-
digits
+
digits

the number of digits for printing, defaults to 3.

-
width
+
width

the width of the printing.

@@ -175,15 +177,15 @@

Arguments

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/model.frame.logitr.html b/reference/model.frame.logitr.html index 2235e1c..e18b2c2 100644 --- a/reference/model.frame.logitr.html +++ b/reference/model.frame.logitr.html @@ -1,10 +1,10 @@ -Extracting the Model Frame from a Formula or Fit — model.frame.logitr • logitrExtracting the Model Frame from a Formula or Fit — model.frame.logitr • logitr - +
- +
@@ -101,25 +101,25 @@

Extracting the Model Frame from a Formula or Fit

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 model.frame(formula, ...)

Arguments

-
formula
+ + +
formula

a model formula or terms object or an R object.

-
...
+
...

further arguments.

Value

- - -

A data.frame with the variables needed to use formula and +

A data.frame with the variables needed to use formula and any ... arguments.

@@ -9802,15 +9802,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/model.matrix.logitr.html b/reference/model.matrix.logitr.html index a06c8c3..9ee7dac 100644 --- a/reference/model.matrix.logitr.html +++ b/reference/model.matrix.logitr.html @@ -1,11 +1,11 @@ -Construct Design Matrices — model.matrix.logitr • logitrConstruct Design Matrices — model.matrix.logitr • logitr - +
- +
@@ -103,26 +103,26 @@

Construct Design Matrices

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 model.matrix(object, ...)

Arguments

-
object
+ + +
object

an object of an appropriate class. For the default method, a model formula or a terms object.

-
...
+
...

further arguments.

Value

- - -

A design matrix

+

A design matrix

@@ -9810,15 +9810,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/predict.logitr.html b/reference/predict.logitr.html index c4d9c8c..a52674b 100644 --- a/reference/predict.logitr.html +++ b/reference/predict.logitr.html @@ -1,11 +1,11 @@ -Predict probabilities and / or outcomes — predict.logitr • logitrPredict probabilities and / or outcomes — predict.logitr • logitr - +
- +
@@ -103,7 +103,7 @@

Predict probabilities and / or outcomes

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 predict(
   object,
   newdata = NULL,
@@ -124,90 +124,90 @@ 

Predict probabilities and / or outcomes

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
newdata
+
newdata

a data.frame. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model. Defaults to NULL, in which case predictions are made on the original data used to estimate the model.

-
obsID
+
obsID

The name of the column that identifies each set of alternatives in the data. Required if newdata != NULL. Defaults to NULL, in which case the value for obsID from the data in object is used.

-
type
+
type

A character vector defining what to predict: prob for probabilities, outcomes for outcomes. If you want both outputs, use c("prob", "outcome"). Outcomes are predicted randomly according to the predicted probabilities. Defaults to "prob".

-
returnData
+
returnData

If TRUE the data is also returned, otherwise only the predicted values ("prob" and / or "outcome") are returned. Defaults to FALSE.

-
interval
+
interval

Type of interval calculation: "none" (default) or "confidence". Future versions will include "prediction" intervals as well.

-
level
+
level

Tolerance / confidence interval. Defaults to 0.95.

-
numDrawsCI
+
numDrawsCI

The number of draws to use in simulating uncertainty for the computed CI. Defaults to 10^4.

-
pars
+
pars

The names of the parameters to be estimated in the model. Must be the same as the column names in the data argument. For WTP space models, do not include the scalePar variable in pars.

-
scalePar
+
scalePar

The name of the column that identifies the scale variable, which is typically "price" for WTP space models, but could be any continuous variable, such as "time". Defaults to NULL.

-
randPars
+
randPars

A named vector whose names are the random parameters and values the distribution: 'n' for normal, 'ln' for log-normal, or 'cn' for zero-censored normal. Defaults to NULL.

-
randScale
+
randScale

The random distribution for the scale parameter: 'n' for normal, 'ln' for log-normal, or 'cn' for zero-censored normal. Only used for WTP space MXL models. Defaults to NULL.

-
ci
+
ci

No longer used as of v1.1.0 - if provided, this is passed to the level argument, interval is set to "confidence", and a warning is displayed.

-
...
+
...

further arguments.

Value

- - -

A data frame of predicted probabilities and / or outcomes.

+

A data frame of predicted probabilities and / or outcomes.

@@ -276,25 +276,25 @@

Examples

level = 0.95 ) #> obsID predicted_prob predicted_prob_lower predicted_prob_upper -#> 1 13 0.43685145 0.41541670 0.45781405 -#> 2 13 0.03312986 0.02627949 0.04162745 -#> 3 13 0.19155548 0.17617362 0.20759161 -#> 4 13 0.33846321 0.31831811 0.35856404 -#> 5 42 0.60764778 0.57395336 0.64111392 -#> 6 42 0.02602007 0.01834621 0.03655238 -#> 7 42 0.17803313 0.16186553 0.19457998 -#> 8 42 0.18829902 0.16758917 0.20929721 +#> 1 13 0.43685145 0.41612646 0.45784256 +#> 2 13 0.03312986 0.02628148 0.04176048 +#> 3 13 0.19155548 0.17628373 0.20826941 +#> 4 13 0.33846321 0.31880300 0.35845900 +#> 5 42 0.60764778 0.57391336 0.63977903 +#> 6 42 0.02602007 0.01828488 0.03670078 +#> 7 42 0.17803313 0.16226990 0.19513591 +#> 8 42 0.18829902 0.16830113 0.20910832 # Predict outcomes predict(mnl_pref, newdata = data, obsID = "obsID", type = "outcome") #> obsID predicted_outcome -#> 1 13 1 -#> 2 13 0 +#> 1 13 0 +#> 2 13 1 #> 3 13 0 #> 4 13 0 -#> 5 42 0 +#> 5 42 1 #> 6 42 0 -#> 7 42 1 +#> 7 42 0 #> 8 42 0 # Predict outcomes and probabilities @@ -302,12 +302,12 @@

Examples

#> obsID predicted_prob predicted_outcome #> 1 13 0.43685145 0 #> 2 13 0.03312986 0 -#> 3 13 0.19155548 0 -#> 4 13 0.33846321 1 -#> 5 42 0.60764778 0 +#> 3 13 0.19155548 1 +#> 4 13 0.33846321 0 +#> 5 42 0.60764778 1 #> 6 42 0.02602007 0 #> 7 42 0.17803313 0 -#> 8 42 0.18829902 1 +#> 8 42 0.18829902 0
@@ -322,15 +322,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/predictChoices.html b/reference/predictChoices.html index 28b30d2..2648014 100644 --- a/reference/predictChoices.html +++ b/reference/predictChoices.html @@ -1,10 +1,10 @@ -Predict choices — predictChoices • logitrPredict choices — predictChoices • logitr - +
- +
@@ -106,25 +106,27 @@

Predict choices

Arguments

-
model
+ + +
model

The output of a model estimated model using the logitr() function. Include if you want to compare true choices from actual observations (e.g. hold outs) to the predicted choices.

-
alts
+
alts

A data frame of a set of alternatives for which to predict choices. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model.

-
altID
+
altID

The name of the column that identifies each alternative in each set of alternatives.

-
obsID
+
obsID

The name of the column that identifies each set of alternatives. Required if predicting results for more than one set of alternatives. Defaults to NULL (for a single set of alternatives).

@@ -132,9 +134,7 @@

Arguments

Value

- - -

A data frame with the predicted choices for each alternative in +

A data frame with the predicted choices for each alternative in alts.

@@ -150,15 +150,15 @@

Value

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/predictProbs.html b/reference/predictProbs.html index 5274dea..82b2068 100644 --- a/reference/predictProbs.html +++ b/reference/predictProbs.html @@ -1,10 +1,10 @@ -Predict expected choice probabilities — predictProbs • logitrPredict expected choice probabilities — predictProbs • logitr - +
- +
@@ -115,44 +115,46 @@

Predict expected choice probabilities

Arguments

-
model
+ + +
model

The output of a model estimated model using the logitr() function.

-
alts
+
alts

A data frame of a set of alternatives for which to predict choice probabilities. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model.

-
altID
+
altID

The name of the column that identifies each alternative in each set of alternatives.

-
obsID
+
obsID

The name of the column that identifies each set of alternatives. Required if predicting results for more than one set of alternatives. Defaults to NULL (for a single set of alternatives).

-
computeCI
+
computeCI

Should a confidence interval be computed? Defaults to TRUE.

-
ci
+
ci

The sensitivity of the computed confidence interval (CI). Defaults to ci = 0.95, reflecting a 95% CI.

-
numDraws
+
numDraws

The number of draws to use in simulating uncertainty for the computed confidence interval.

-
alpha
+
alpha

The sensitivity of the computed confidence interval. No longer used as of v0.2.7 - if provided, a warning is shown and ci is computed from alpha.

@@ -160,9 +162,7 @@

Arguments

Value

- - -

A data frame with the estimated choice probabilities for each +

A data frame with the estimated choice probabilities for each alternative in alts.

@@ -178,15 +178,15 @@

Value

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/print.logitr.html b/reference/print.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/print.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/print.logitr_wtp.html b/reference/print.logitr_wtp.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/print.logitr_wtp.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/print.summary.logitr.html b/reference/print.summary.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/print.summary.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/recodeData.html b/reference/recodeData.html index a84f24c..788f6fb 100644 --- a/reference/recodeData.html +++ b/reference/recodeData.html @@ -1,16 +1,12 @@ -Returns a list of the design matrix X and updated pars and -randPars to include any dummy-coded categorical or interaction -variables. — recodeData • logitrReturns a list of the design matrix X and updated pars and randPars to include any dummy-coded categorical or interaction variables. — recodeData • logitr - +
- +
@@ -116,18 +110,20 @@

Returns a list of the design matrix X and updated pars

Arguments

-
data
+ + +
data

The data, formatted as a data.frame object.

-
pars
+
pars

The names of the parameters to be estimated in the model. Must be the same as the column names in the data argument. For WTP space models, do not include price in pars - it should instead be defined by the scalePar argument.

-
randPars
+
randPars

A named vector whose names are the random parameters and values the distribution: 'n' for normal or 'ln' for log-normal. Defaults to NULL.

@@ -135,9 +131,7 @@

Arguments

Value

- - -

A list of the design matrix (X) and two vectors (pars and +

A list of the design matrix (X) and two vectors (pars and randPars) with discrete (categorical) variables and interaction variables added.

@@ -157,7 +151,7 @@

Examples

result$formula #> ~price + feat + brand + price * brand -#> <environment: 0x7fad67b8d4d8> +#> <environment: 0x12f18a198> result$pars #> [1] "price" "feat" "brandhiland" #> [4] "brandweight" "brandyoplait" "price:brandhiland" @@ -194,15 +188,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/reexports.html b/reference/reexports.html index 5b664fd..ad49dc0 100644 --- a/reference/reexports.html +++ b/reference/reexports.html @@ -1,5 +1,5 @@ -Objects exported from other packages — reexports • logitrObjects exported from other packages — reexports • logitr - +
- +
@@ -124,15 +124,15 @@

Objects exported from other packages

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/residuals.logitr.html b/reference/residuals.logitr.html index cc63903..5f14511 100644 --- a/reference/residuals.logitr.html +++ b/reference/residuals.logitr.html @@ -1,9 +1,9 @@ -Extract Model Residuals — residuals.logitr • logitrExtract Model Residuals — residuals.logitr • logitr - +
- +
@@ -99,31 +99,31 @@

Extract Model Residuals

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 residuals(object, fitted = NULL, ...)

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
fitted
+
fitted

Fitted values for an object of class logitr to use in computing residuals. Defaults to NULL.

-
...
+
...

further arguments.

Value

- - -

A data frame of the obsID and the residuals (response minus fitted +

A data frame of the obsID and the residuals (response minus fitted values) extracted from object.

@@ -9806,15 +9806,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/runtimes.html b/reference/runtimes.html index 6e36e8c..2a2bbea 100644 --- a/reference/runtimes.html +++ b/reference/runtimes.html @@ -1,5 +1,5 @@ -Data frame of run times for logitr benchmark — runtimes • logitrData frame of run times for logitr benchmark — runtimes • logitr - +
- +
@@ -112,7 +112,7 @@

Data frame of run times for logitr benchmark

Format

- +
VariableDescription
packagePackage name.
time_secThe estimation time in seconds.
numDrawsThe number of random draws used during estimation.

Source

@@ -147,15 +147,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/se.html b/reference/se.html index 961df18..9d1a651 100644 --- a/reference/se.html +++ b/reference/se.html @@ -1,9 +1,9 @@ -Extract standard errors — se • logitrExtract standard errors — se • logitr - +
- +
@@ -104,12 +104,14 @@

Extract standard errors

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
...
+
...

further arguments.

@@ -126,15 +128,15 @@

Arguments

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/se.logitr.html b/reference/se.logitr.html index dff9f6c..6a1c1f1 100644 --- a/reference/se.logitr.html +++ b/reference/se.logitr.html @@ -1,9 +1,9 @@ -Extract standard errors — se.logitr • logitrExtract standard errors — se.logitr • logitr - +
- +
@@ -99,18 +99,20 @@

Extract standard errors

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 se(object, ...)

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
...
+
...

further arguments.

@@ -127,15 +129,15 @@

Arguments

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/simulateShares.html b/reference/simulateShares.html index 1022a8d..3b40ce9 100644 --- a/reference/simulateShares.html +++ b/reference/simulateShares.html @@ -1,10 +1,10 @@ -Simulate expected shares — simulateShares • logitrSimulate expected shares — simulateShares • logitr - +
- +
@@ -114,48 +114,48 @@

Simulate expected shares

Arguments

-
model
+ + +
model

The output of a model estimated model using the logitr() function.

-
alts
+
alts

A data frame of a set of alternatives for which to simulate shares. Each row is an alternative and each column an attribute corresponding to parameter names in the estimated model.

-
obsIDName
+
obsIDName

The name of the column that identifies each set of alternatives. Required if simulating results for more than one set of alternatives. Defaults to NULL (for a single set of alternatives).

-
priceName
+
priceName

The name of the parameter that identifies price. Only required for WTP space models. Defaults to NULL.

-
computeCI
+
computeCI

Should a confidence interval be computed? Defaults to TRUE.

-
alpha
+
alpha

The sensitivity of the computed confidence interval. Defaults to alpha = 0.025, reflecting a 95% CI.

-
numDraws
+
numDraws

The number of draws to use in simulating uncertainty for the computed confidence interval.

Value

- - -

A data frame with the estimated shares for each alternative in +

A data frame with the estimated shares for each alternative in alts.

@@ -171,15 +171,15 @@

Value

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/statusCodes.html b/reference/statusCodes.html index 2d58bda..330bd47 100644 --- a/reference/statusCodes.html +++ b/reference/statusCodes.html @@ -1,9 +1,9 @@ -View a description the nloptr status codes — statusCodes • logitrView a description the nloptr status codes — statusCodes • logitr - +
- +
@@ -104,9 +104,7 @@

View a description the nloptr status codes

Value

- - -

No return value; prints a summary of the nloptr status codes to +

No return value; prints a summary of the nloptr status codes to the console.

@@ -139,15 +137,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/summary.logitr.html b/reference/summary.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/summary.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/terms.logitr.html b/reference/terms.logitr.html new file mode 100644 index 0000000..49e525e --- /dev/null +++ b/reference/terms.logitr.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/tidy.html b/reference/tidy.html new file mode 100644 index 0000000..a60098e --- /dev/null +++ b/reference/tidy.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/reference/tidy.logitr.html b/reference/tidy.logitr.html index 394f2ca..e6f3d7a 100644 --- a/reference/tidy.logitr.html +++ b/reference/tidy.logitr.html @@ -1,9 +1,9 @@ -Tidy a logitr class object — tidy.logitr • logitrTidy a logitr class object — tidy.logitr • logitr - +
- +
@@ -99,37 +99,37 @@

Tidy a logitr class object

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 tidy(x, conf.int = FALSE, conf.level = 0.95, ...)

Arguments

-
x
+ + +
x

is an object of class logitr.

-
conf.int
+
conf.int

Logical indicating whether or not to include a confidence interval in the tidied output. Defaults to FALSE.

-
conf.level
+
conf.level

The confidence level to use for the confidence interval if conf.int = TRUE. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.

-
...
+
...

Unused, included for generic consistency only.

Value

- - -

A tidy tibble::tibble() summarizing component-level +

A tidy tibble::tibble() summarizing component-level information about the model

@@ -165,9 +165,9 @@

Examples

#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 brandhiland -3.72 0.145 -25.6 0 -4.00 -3.43 #> 2 brandweight -0.641 0.0545 -11.8 0 -0.749 -0.534 -#> 3 brandyoplait 0.735 0.0806 9.11 0 0.575 0.892 -#> 4 feat 0.491 0.120 4.09 0.0000425 0.254 0.729 -#> 5 price -0.367 0.0244 -15.0 0 -0.414 -0.318 +#> 3 brandyoplait 0.735 0.0806 9.11 0 0.578 0.891 +#> 4 feat 0.491 0.120 4.09 0.0000425 0.260 0.725 +#> 5 price -0.367 0.0244 -15.0 0 -0.414 -0.319
@@ -183,15 +183,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/vcov.logitr.html b/reference/vcov.logitr.html index b3065b7..aa681e0 100644 --- a/reference/vcov.logitr.html +++ b/reference/vcov.logitr.html @@ -1,10 +1,10 @@ -Calculate the variance-covariance matrix — vcov.logitr • logitrCalculate the variance-covariance matrix — vcov.logitr • logitr - +
- +
@@ -101,18 +101,20 @@

Calculate the variance-covariance matrix

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 vcov(object, ...)

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
...
+
...

further arguments.

@@ -129,15 +131,15 @@

Arguments

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/wtp.html b/reference/wtp.html index 1c5b198..a4efbfa 100644 --- a/reference/wtp.html +++ b/reference/wtp.html @@ -1,9 +1,9 @@ -Get WTP estimates a preference space model — wtp • logitrGet WTP estimates a preference space model — wtp • logitr - +
- +
@@ -104,12 +104,14 @@

Get WTP estimates a preference space model

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
scalePar
+
scalePar

The name of the column that identifies the scale variable, which is typically "price" for WTP space models, but could be any continuous variable, such as "time".

@@ -117,9 +119,7 @@

Arguments

Value

- - -

A data frame of the WTP estimates.

+

A data frame of the WTP estimates.

Details

@@ -146,11 +146,11 @@

Examples

# Compute the WTP implied from the preference space model wtp(mnl_pref, scalePar = "price") #> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.366555 0.024383 15.0330 < 2.2e-16 *** -#> feat 1.340699 0.359390 3.7305 0.0001911 *** -#> brandhiland -10.136219 0.584836 -17.3317 < 2.2e-16 *** -#> brandweight -1.749094 0.181226 -9.6514 < 2.2e-16 *** -#> brandyoplait 2.003848 0.143034 14.0096 < 2.2e-16 *** +#> scalePar 0.366555 0.024343 15.0576 < 2.2e-16 *** +#> feat 1.340699 0.358207 3.7428 0.000182 *** +#> brandhiland -10.136219 0.585260 -17.3192 < 2.2e-16 *** +#> brandweight -1.749094 0.181626 -9.6302 < 2.2e-16 *** +#> brandyoplait 2.003848 0.143168 13.9965 < 2.2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
@@ -167,15 +167,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/wtp.logitr.html b/reference/wtp.logitr.html index 920e835..c9c0d37 100644 --- a/reference/wtp.logitr.html +++ b/reference/wtp.logitr.html @@ -1,9 +1,9 @@ -Get WTP estimates a preference space model — wtp.logitr • logitrGet WTP estimates a preference space model — wtp.logitr • logitr - +
- +
@@ -99,18 +99,20 @@

Get WTP estimates a preference space model

-
# S3 method for logitr
+    
# S3 method for class 'logitr'
 wtp(object, scalePar)

Arguments

-
object
+ + +
object

is an object of class logitr (a model estimated using the 'logitr()` function).

-
scalePar
+
scalePar

The name of the column that identifies the scale variable, which is typically "price" for WTP space models, but could be any continuous variable, such as "time".

@@ -118,9 +120,7 @@

Arguments

Value

- - -

A data frame of the WTP estimates.

+

A data frame of the WTP estimates.

Details

@@ -147,11 +147,11 @@

Examples

# Compute the WTP implied from the preference space model wtp(mnl_pref, scalePar = "price") #> Estimate Std. Error z-value Pr(>|z|) -#> scalePar 0.366555 0.024353 15.0519 < 2.2e-16 *** -#> feat 1.340699 0.358907 3.7355 0.0001873 *** -#> brandhiland -10.136219 0.583648 -17.3670 < 2.2e-16 *** -#> brandweight -1.749094 0.181450 -9.6396 < 2.2e-16 *** -#> brandyoplait 2.003848 0.143667 13.9479 < 2.2e-16 *** +#> scalePar 0.366555 0.024295 15.0876 < 2.2e-16 *** +#> feat 1.340699 0.358961 3.7349 0.0001878 *** +#> brandhiland -10.136219 0.583346 -17.3760 < 2.2e-16 *** +#> brandweight -1.749094 0.181780 -9.6221 < 2.2e-16 *** +#> brandyoplait 2.003848 0.143439 13.9700 < 2.2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
@@ -168,15 +168,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/wtpCompare.html b/reference/wtpCompare.html index 544133c..242a548 100644 --- a/reference/wtpCompare.html +++ b/reference/wtpCompare.html @@ -1,10 +1,10 @@ -Compare WTP from preference and WTP space models — wtpCompare • logitrCompare WTP from preference and WTP space models — wtpCompare • logitr - +
- +
@@ -106,17 +106,19 @@

Compare WTP from preference and WTP space models

Arguments

-
model_pref
+ + +
model_pref

The output of a "preference space" model estimated using the logitr() function.

-
model_wtp
+
model_wtp

The output of a "willingness to pay space" model estimated using the logitr() function.

-
scalePar
+
scalePar

The name of the column that identifies the scale variable, which is typically "price" for WTP space models, but could be any continuous variable, such as "time".

@@ -124,9 +126,7 @@

Arguments

Value

- - -

A data frame comparing the WTP estimates from preference space and +

A data frame comparing the WTP estimates from preference space and WTP space models.

@@ -170,13 +170,13 @@

Examples

# Compare the WTP between the two spaces wtpCompare(mnl_pref, mnl_wtp, scalePar = "price") -#> pref wtp difference -#> scalePar 0.3665546 0.366589 0.00003448 -#> feat 1.3406987 1.340815 0.00011655 -#> brandhiland -10.1362190 -10.135947 0.00027163 -#> brandweight -1.7490940 -1.749231 -0.00013707 -#> brandyoplait 2.0038476 2.003530 -0.00031745 -#> logLik -2656.8878790 -2656.887881 -0.00000180 +#> pref wtp difference +#> scalePar 0.3665546 0.3665849 0.00003030 +#> feat 1.3406987 1.3405656 -0.00013309 +#> brandhiland -10.1362190 -10.1357075 0.00051155 +#> brandweight -1.7490940 -1.7490664 0.00002759 +#> brandyoplait 2.0038476 2.0038243 -0.00002336 +#> logLik -2656.8878790 -2656.8878779 0.00000106
@@ -191,15 +191,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/reference/yogurt.html b/reference/yogurt.html index c230652..bff6f30 100644 --- a/reference/yogurt.html +++ b/reference/yogurt.html @@ -1,5 +1,5 @@ -Choice observations of yogurt purchases by 100 households — yogurt • logitr - +
- +
@@ -118,7 +118,7 @@

Choice observations of yogurt purchases by 100 households

Format

- +
VariableDescription
idindividual identifiers
obsIDidentifier for unique choice observation
altalternative in each choice observation
choicedummy code for choice (1 or 0)
priceprice of yogurt
featdummy for whether a newspaper advertisement was shown to the customer (1 or 0)
brandyogurt brand: "yoplait", "dannon", "hiland", or "weight" (for weight watcher)

Source

@@ -159,15 +159,15 @@

Examples

-

Site built with pkgdown 2.0.7.

+

Site built with pkgdown 2.1.0.

- - + + diff --git a/sitemap.xml b/sitemap.xml index 0676d03..2071d38 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1,159 +1,55 @@ - - - - https://jhelvy.github.io/logitr/404.html - - - https://jhelvy.github.io/logitr/LICENSE-text.html - - - https://jhelvy.github.io/logitr/LICENSE.html - - - https://jhelvy.github.io/logitr/articles/basic_usage.html - - - https://jhelvy.github.io/logitr/articles/benchmark.html - - - https://jhelvy.github.io/logitr/articles/convergence.html - - - https://jhelvy.github.io/logitr/articles/data_formatting.html - - - https://jhelvy.github.io/logitr/articles/index.html - - - https://jhelvy.github.io/logitr/articles/interactions.html - - - https://jhelvy.github.io/logitr/articles/mnl_models.html - - - https://jhelvy.github.io/logitr/articles/mnl_models_weighted.html - - - https://jhelvy.github.io/logitr/articles/mxl_models.html - - - https://jhelvy.github.io/logitr/articles/predict.html - - - https://jhelvy.github.io/logitr/articles/summarizing_results.html - - - https://jhelvy.github.io/logitr/articles/utility_models.html - - - https://jhelvy.github.io/logitr/authors.html - - - https://jhelvy.github.io/logitr/index.html - - - https://jhelvy.github.io/logitr/news/index.html - - - https://jhelvy.github.io/logitr/reference/apolloModeChoiceData.html - - - https://jhelvy.github.io/logitr/reference/augment.logitr.html - - - https://jhelvy.github.io/logitr/reference/cars_china.html - - - https://jhelvy.github.io/logitr/reference/cars_us.html - - - https://jhelvy.github.io/logitr/reference/ci.html - - - https://jhelvy.github.io/logitr/reference/confint.logitr.html - - - https://jhelvy.github.io/logitr/reference/dummyCode.html - - - https://jhelvy.github.io/logitr/reference/electricity.html - - - https://jhelvy.github.io/logitr/reference/fitted.logitr.html - - - https://jhelvy.github.io/logitr/reference/fquantile.html - - - https://jhelvy.github.io/logitr/reference/glance.logitr.html - - - https://jhelvy.github.io/logitr/reference/index.html - - - https://jhelvy.github.io/logitr/reference/logit_probs.html - - - https://jhelvy.github.io/logitr/reference/logitr.html - - - https://jhelvy.github.io/logitr/reference/miscmethods.logitr.html - - - https://jhelvy.github.io/logitr/reference/model.frame.logitr.html - - - https://jhelvy.github.io/logitr/reference/model.matrix.logitr.html - - - https://jhelvy.github.io/logitr/reference/predict.logitr.html - - - https://jhelvy.github.io/logitr/reference/predictChoices.html - - - https://jhelvy.github.io/logitr/reference/predictProbs.html - - - https://jhelvy.github.io/logitr/reference/recodeData.html - - - https://jhelvy.github.io/logitr/reference/reexports.html - - - https://jhelvy.github.io/logitr/reference/residuals.logitr.html - - - https://jhelvy.github.io/logitr/reference/runtimes.html - - - https://jhelvy.github.io/logitr/reference/se.html - - - https://jhelvy.github.io/logitr/reference/se.logitr.html - - - https://jhelvy.github.io/logitr/reference/simulateShares.html - - - https://jhelvy.github.io/logitr/reference/statusCodes.html - - - https://jhelvy.github.io/logitr/reference/tidy.logitr.html - - - https://jhelvy.github.io/logitr/reference/vcov.logitr.html - - - https://jhelvy.github.io/logitr/reference/wtp.html - - - https://jhelvy.github.io/logitr/reference/wtp.logitr.html - - - https://jhelvy.github.io/logitr/reference/wtpCompare.html - - - https://jhelvy.github.io/logitr/reference/yogurt.html - + +https://jhelvy.github.io/logitr/404.html +https://jhelvy.github.io/logitr/LICENSE-text.html +https://jhelvy.github.io/logitr/LICENSE.html +https://jhelvy.github.io/logitr/articles/basic_usage.html +https://jhelvy.github.io/logitr/articles/benchmark.html +https://jhelvy.github.io/logitr/articles/convergence.html +https://jhelvy.github.io/logitr/articles/data_formatting.html +https://jhelvy.github.io/logitr/articles/index.html +https://jhelvy.github.io/logitr/articles/interactions.html +https://jhelvy.github.io/logitr/articles/mnl_models.html +https://jhelvy.github.io/logitr/articles/mnl_models_weighted.html +https://jhelvy.github.io/logitr/articles/mxl_models.html +https://jhelvy.github.io/logitr/articles/predict.html +https://jhelvy.github.io/logitr/articles/summarizing_results.html +https://jhelvy.github.io/logitr/articles/utility_models.html +https://jhelvy.github.io/logitr/authors.html +https://jhelvy.github.io/logitr/index.html +https://jhelvy.github.io/logitr/news/index.html +https://jhelvy.github.io/logitr/reference/apolloModeChoiceData.html +https://jhelvy.github.io/logitr/reference/augment.logitr.html +https://jhelvy.github.io/logitr/reference/cars_china.html +https://jhelvy.github.io/logitr/reference/cars_us.html +https://jhelvy.github.io/logitr/reference/ci.html +https://jhelvy.github.io/logitr/reference/confint.logitr.html +https://jhelvy.github.io/logitr/reference/dummyCode.html +https://jhelvy.github.io/logitr/reference/electricity.html +https://jhelvy.github.io/logitr/reference/fitted.logitr.html +https://jhelvy.github.io/logitr/reference/fquantile.html +https://jhelvy.github.io/logitr/reference/glance.logitr.html +https://jhelvy.github.io/logitr/reference/index.html +https://jhelvy.github.io/logitr/reference/logit_probs.html +https://jhelvy.github.io/logitr/reference/logitr.html +https://jhelvy.github.io/logitr/reference/miscmethods.logitr.html +https://jhelvy.github.io/logitr/reference/model.frame.logitr.html +https://jhelvy.github.io/logitr/reference/model.matrix.logitr.html +https://jhelvy.github.io/logitr/reference/predict.logitr.html +https://jhelvy.github.io/logitr/reference/predictChoices.html +https://jhelvy.github.io/logitr/reference/predictProbs.html +https://jhelvy.github.io/logitr/reference/recodeData.html +https://jhelvy.github.io/logitr/reference/reexports.html +https://jhelvy.github.io/logitr/reference/residuals.logitr.html +https://jhelvy.github.io/logitr/reference/runtimes.html +https://jhelvy.github.io/logitr/reference/se.html +https://jhelvy.github.io/logitr/reference/se.logitr.html +https://jhelvy.github.io/logitr/reference/simulateShares.html +https://jhelvy.github.io/logitr/reference/statusCodes.html +https://jhelvy.github.io/logitr/reference/tidy.logitr.html +https://jhelvy.github.io/logitr/reference/vcov.logitr.html +https://jhelvy.github.io/logitr/reference/wtp.html +https://jhelvy.github.io/logitr/reference/wtp.logitr.html +https://jhelvy.github.io/logitr/reference/wtpCompare.html +https://jhelvy.github.io/logitr/reference/yogurt.html +