Learn R Programming

echoice2 (version 0.2.3)

ec_dem_aggregate: Aggregate posterior draws of demand

Description

Aggregate demand draws, e.g. from individual-choice occasion-alternative level to individual level. (using the new demand draw format)

Usage

ec_dem_aggregate(de,groupby)

Value

Aggregated demand predictions

Arguments

de

demand draws

groupby

groupby grouping variables (as (vector of) string(s))

Examples

Run this code
data(icecream)
#run MCMC sampler (use way more than 50 draws for actual use)
icecream_est <- icecream %>% dplyr::filter(id<20) %>% vd_est_vdm(R=10, keep=1)
#Generate demand predictions
icecream_predicted_demand=
 icecream %>% dplyr::filter(id<20) %>%   
   vd_dem_vdm(icecream_est)
#aggregate
brand_lvl_pred_demand <-
 icecream_predicted_demand %>% ec_dem_aggregate("Brand")

Run the code above in your browser using DataLab