Skip to content

Commit e42828d

Browse files
committed
updated simulations vignette
1 parent 69a04d7 commit e42828d

15 files changed

+53
-27
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
## Summary of larger updates:
55

66
- Added support for auto creating interactions amongst variables
7+
- exported `getCoefTable()` function
78

89
## Summary of smaller updates:
910

README.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ knitr::opts_chunk$set(
1010
warning = FALSE,
1111
message = FALSE,
1212
comment = "#>",
13-
fig.path = "man/figures/",
13+
fig.path = "man/figs/",
1414
fig.retina = 3
1515
)
1616
```
1717

18-
# logitr <a href='https://jhelvy.github.io/logitr/'><img src='man/figures/logitr-hex.png' align="right" height="139" /></a>
18+
# logitr <a href='https://jhelvy.github.io/logitr/'><img src='man/figs/logitr-hex.png' align="right" height="139" /></a>
1919

2020
<!-- badges: start -->
2121
[![Lifecycle:

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
<!-- README.md is generated from README.Rmd. Please edit that file -->
33

4-
# logitr <a href='https://jhelvy.github.io/logitr/'><img src='man/figures/logitr-hex.png' align="right" height="139" /></a>
4+
# logitr <a href='https://jhelvy.github.io/logitr/'><img src='man/figs/logitr-hex.png' align="right" height="139" /></a>
55

66
<!-- badges: start -->
77

@@ -88,16 +88,16 @@ citation("logitr")
8888
#>
8989
#> To cite logitr in publications use:
9090
#>
91-
#> John Paul Helveston. logitr: Random utility logit models with
92-
#> preference and willingness to pay space parameterizations (2020)
91+
#> John Paul Helveston (2020). logitr: Random utility logit models with
92+
#> preference and willingness to pay space parameterizations.
9393
#>
9494
#> A BibTeX entry for LaTeX users is
9595
#>
9696
#> @Manual{,
9797
#> title = {logitr: Random utility logit models with preference and willingness to pay space parameterizations},
9898
#> author = {John Paul Helveston},
9999
#> year = {2020},
100-
#> note = {R package version 0.0.4},
100+
#> note = {R package version 0.0.5},
101101
#> url = {https://jhelvy.github.io/logitr/},
102102
#> }
103103
```

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ reference:
5454
contents:
5555
- summary.logitr
5656
- coef.logitr
57+
- getCoefTable
5758
- statusCodes
5859
- title: "Computing and Comparing WTP"
5960
desc: "Functions for computing and comparing WTP from estimated models."

inst/example/simulations.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ sim_mxl_pref
4949
sim_mxl_wtp <- simulateShares(mxl_wtp, alts, priceName = 'price')
5050
sim_mxl_wtp
5151

52-
# Plot simulation results from preference space MNL model:
53-
library(ggplot2)
54-
sim_mnl_pref$alt <- row.names(sim_mnl_pref)
55-
ggplot(sim_mnl_pref, aes(x = alt, y = share_mean)) +
56-
geom_bar(stat = 'identity', width = 0.7, fill = "dodgerblue") +
57-
geom_errorbar(aes(ymin = share_low, ymax = share_high), width = 0.2) +
58-
scale_y_continuous(limits = c(0, 1)) +
59-
labs(x = 'Alternative', y = 'Expected Share') +
60-
theme_bw()
61-
6252
# Save results
6353
saveRDS(sim_mnl_pref,
6454
here::here('inst', 'extdata', 'sim_mnl_pref.Rds'))
@@ -68,3 +58,19 @@ saveRDS(sim_mxl_pref,
6858
here::here('inst', 'extdata', 'sim_mxl_pref.Rds'))
6959
saveRDS(sim_mxl_wtp,
7060
here::here('inst', 'extdata', 'sim_mxl_wtp.Rds'))
61+
62+
# Plot simulation results from each model:
63+
library(ggplot2)
64+
65+
sims <- rbind(sim_mnl_pref, sim_mnl_wtp, sim_mxl_pref, sim_mxl_wtp)
66+
sims$model <- c(rep("mnl_pref", 4), rep("mnl_wtp", 4),
67+
rep("mxl_pref", 4), rep("mxl_wtp", 4))
68+
sims$alt <- rep(row.names(alts), 4)
69+
70+
ggplot(sims, aes(x = alt, y = share_mean, fill = model)) +
71+
geom_bar(stat = 'identity', width = 0.7, position = "dodge") +
72+
geom_errorbar(aes(ymin = share_low, ymax = share_high),
73+
width = 0.2, position = position_dodge(width = 0.7)) +
74+
scale_y_continuous(limits = c(0, 1)) +
75+
labs(x = 'Alternative', y = 'Expected Share') +
76+
theme_bw()

inst/extdata/sim_mnl_pref.Rds

-3 Bytes
Binary file not shown.

inst/extdata/sim_mnl_wtp.Rds

0 Bytes
Binary file not shown.

inst/extdata/sim_mxl_pref.Rds

1 Byte
Binary file not shown.

inst/extdata/sim_mxl_wtp.Rds

1 Byte
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)