R/echoice2.R
vd_dem_vdm_screen.Rd
Generating demand predictions for volumetric demand model with attribute-based screening.
Reminder: there is no closed-form solution for demand, thus we need to integrate not only over the posterior distribution of parameters and the error distribution.
The function outputs a tibble containing id, task, alt, p, attributes, draws from the posterior of demand.
Eerror realisations can be pre-supplied to the epsilon_not
. This helps create smooth demand curves or conduct optimization.
vd_dem_vdm_screen(vd, est, epsilon_not = NULL, error_dist = NULL, cores = NULL)
data
ec-model draws
(optional) error realizations
(optional) A string defining the error term distribution (default: 'EV1')
(optional) cores
Draws of expected demand
prep_newprediction()
to match vd
's factor levels,
ec_gen_err_normal()
for pre-generating error realizations and
vd_est_vdm_screen()
for estimating the corresponding model
data(icecream)
#run MCMC sampler (use way more than 20 draws for actual use)
icecream_est <- icecream %>% dplyr::filter(id<20) %>% vd_est_vdm_screen(R=20, keep=1, cores=2)
#> Using 2 cores
#> MCMC in progress
#> MCMC complete
#> Total Time Elapsed: 0.00 minutes
#Generate demand predictions
icecream_predicted_demand=
icecream %>% dplyr::filter(id<20) %>%
vd_dem_vdm_screen(icecream_est, cores=2)
#> Using 2 cores
#column .demdraws contains draws from posterior of predicted demand