This helper function creates demand curves
ec_demcurve_cond_dem(
ec_long,
focal_product,
rel_pricerange,
dem_fun,
draws,
epsilon_not = NULL
)
choice scenario (discrete or volumetric)
Logical vector picking the focal product for which to create a demand curve
Price range, relative to base case price; this is used to create demand curve
demand function (e.g., dd_prob
for HMNL or vd_dem_vdm
for volumetric demand). For discrete choice, use choice probabilities instead of choice predictions.
ec-draws object (e.g., output from dd_est_hmnl
or vd_est_vd
)
(optional) error realisatins (this helps make curves look smother for voumetric models)
List containing aggregate demand quantities for each scenario defined by rel_pricerange
ec_gen_err_normal()
to generate error realization from Normal distribution,
ec_gen_err_ev1()
to generate error realization from EV1 distribution
# \donttest{
data(icecream)
#run MCMC sampler (use way more draws for actual use)
icecream_est <- icecream %>% dplyr::filter(id<20) %>%
vd_est_vdm(R=2, keep=1)
#> Using 16 cores
#> MCMC in progress
#> MCMC complete
#> Total Time Elapsed: 0.00 minutes
#demand at different price points
conddem_scenarios<-
ec_demcurve_cond_dem(icecream%>% dplyr::filter(id<20),
icecream%>% dplyr::filter(id<20) %>% pull('Brand')=="Store",
c(.75,1),vd_dem_vdm,icecream_est)
#> Using 16 cores
#> New names:
#> • `x` -> `x...1`
#> • `Brand` -> `Brand...2`
#> • `Flavor` -> `Flavor...3`
#> • `Size` -> `Size...4`
#> • `x` -> `x...5`
#> • `Brand` -> `Brand...6`
#> • `Flavor` -> `Flavor...7`
#> • `Size` -> `Size...8`
#> • `x` -> `x...9`
#> • `Brand` -> `Brand...10`
#> • `Flavor` -> `Flavor...11`
#> • `Size` -> `Size...12`
#> • `x` -> `x...13`
#> • `Brand` -> `Brand...14`
#> • `Flavor` -> `Flavor...15`
#> • `Size` -> `Size...16`
#> • `x` -> `x...17`
#> • `Brand` -> `Brand...18`
#> • `Flavor` -> `Flavor...19`
#> • `Size` -> `Size...20`
#> • `x` -> `x...21`
#> • `Brand` -> `Brand...22`
#> • `Flavor` -> `Flavor...23`
#> • `Size` -> `Size...24`
#> • `x` -> `x...25`
#> • `Brand` -> `Brand...26`
#> • `Flavor` -> `Flavor...27`
#> • `Size` -> `Size...28`
#> • `x` -> `x...29`
#> • `Brand` -> `Brand...30`
#> • `Flavor` -> `Flavor...31`
#> • `Size` -> `Size...32`
#> • `x` -> `x...33`
#> • `Brand` -> `Brand...34`
#> • `Flavor` -> `Flavor...35`
#> • `Size` -> `Size...36`
#> • `x` -> `x...37`
#> • `Brand` -> `Brand...38`
#> • `Flavor` -> `Flavor...39`
#> • `Size` -> `Size...40`
#> • `x` -> `x...41`
#> • `Brand` -> `Brand...42`
#> • `Flavor` -> `Flavor...43`
#> • `Size` -> `Size...44`
#> • `x` -> `x...45`
#> • `Brand` -> `Brand...46`
#> • `Flavor` -> `Flavor...47`
#> • `Size` -> `Size...48`
#> • `x` -> `x...49`
#> • `Brand` -> `Brand...50`
#> • `Flavor` -> `Flavor...51`
#> • `Size` -> `Size...52`
#> • `x` -> `x...53`
#> • `Brand` -> `Brand...54`
#> • `Flavor` -> `Flavor...55`
#> • `Size` -> `Size...56`
#> • `x` -> `x...57`
#> • `Brand` -> `Brand...58`
#> • `Flavor` -> `Flavor...59`
#> • `Size` -> `Size...60`
#> • `x` -> `x...61`
#> • `Brand` -> `Brand...62`
#> • `Flavor` -> `Flavor...63`
#> • `Size` -> `Size...64`
#> • `x` -> `x...65`
#> • `Brand` -> `Brand...66`
#> • `Flavor` -> `Flavor...67`
#> • `Size` -> `Size...68`
#> • `x` -> `x...69`
#> • `Brand` -> `Brand...70`
#> • `Flavor` -> `Flavor...71`
#> • `Size` -> `Size...72`
#> • `x` -> `x...73`
#> • `Brand` -> `Brand...74`
#> • `Flavor` -> `Flavor...75`
#> • `Size` -> `Size...76`
#> • `x` -> `x...77`
#> • `Brand` -> `Brand...78`
#> • `Flavor` -> `Flavor...79`
#> • `Size` -> `Size...80`
#> • `x` -> `x...81`
#> • `Brand` -> `Brand...82`
#> • `Flavor` -> `Flavor...83`
#> • `Size` -> `Size...84`
#> • `x` -> `x...85`
#> • `Brand` -> `Brand...86`
#> • `Flavor` -> `Flavor...87`
#> • `Size` -> `Size...88`
#> • `x` -> `x...89`
#> • `Brand` -> `Brand...90`
#> • `Flavor` -> `Flavor...91`
#> • `Size` -> `Size...92`
#> • `x` -> `x...93`
#> • `Brand` -> `Brand...94`
#> • `Flavor` -> `Flavor...95`
#> • `Size` -> `Size...96`
#> • `x` -> `x...97`
#> • `Brand` -> `Brand...98`
#> • `Flavor` -> `Flavor...99`
#> • `Size` -> `Size...100`
#> • `x` -> `x...101`
#> • `Brand` -> `Brand...102`
#> • `Flavor` -> `Flavor...103`
#> • `Size` -> `Size...104`
#> • `x` -> `x...105`
#> • `Brand` -> `Brand...106`
#> • `Flavor` -> `Flavor...107`
#> • `Size` -> `Size...108`
#> • `x` -> `x...109`
#> • `Brand` -> `Brand...110`
#> • `Flavor` -> `Flavor...111`
#> • `Size` -> `Size...112`
#> • `x` -> `x...113`
#> • `Brand` -> `Brand...114`
#> • `Flavor` -> `Flavor...115`
#> • `Size` -> `Size...116`
#> • `x` -> `x...117`
#> • `Brand` -> `Brand...118`
#> • `Flavor` -> `Flavor...119`
#> • `Size` -> `Size...120`
#> • `x` -> `x...121`
#> • `Brand` -> `Brand...122`
#> • `Flavor` -> `Flavor...123`
#> • `Size` -> `Size...124`
#> • `x` -> `x...125`
#> • `Brand` -> `Brand...126`
#> • `Flavor` -> `Flavor...127`
#> • `Size` -> `Size...128`
#> • `x` -> `x...129`
#> • `Brand` -> `Brand...130`
#> • `Flavor` -> `Flavor...131`
#> • `Size` -> `Size...132`
#> • `x` -> `x...133`
#> • `Brand` -> `Brand...134`
#> • `Flavor` -> `Flavor...135`
#> • `Size` -> `Size...136`
#> • `x` -> `x...137`
#> • `Brand` -> `Brand...138`
#> • `Flavor` -> `Flavor...139`
#> • `Size` -> `Size...140`
#> • `x` -> `x...141`
#> • `Brand` -> `Brand...142`
#> • `Flavor` -> `Flavor...143`
#> • `Size` -> `Size...144`
#> • `x` -> `x...145`
#> • `Brand` -> `Brand...146`
#> • `Flavor` -> `Flavor...147`
#> • `Size` -> `Size...148`
#> • `x` -> `x...149`
#> • `Brand` -> `Brand...150`
#> • `Flavor` -> `Flavor...151`
#> • `Size` -> `Size...152`
#> • `x` -> `x...153`
#> • `Brand` -> `Brand...154`
#> • `Flavor` -> `Flavor...155`
#> • `Size` -> `Size...156`
#> • `x` -> `x...157`
#> • `Brand` -> `Brand...158`
#> • `Flavor` -> `Flavor...159`
#> • `Size` -> `Size...160`
#> • `x` -> `x...161`
#> • `Brand` -> `Brand...162`
#> • `Flavor` -> `Flavor...163`
#> • `Size` -> `Size...164`
#> • `x` -> `x...165`
#> • `Brand` -> `Brand...166`
#> • `Flavor` -> `Flavor...167`
#> • `Size` -> `Size...168`
#> • `x` -> `x...169`
#> • `Brand` -> `Brand...170`
#> • `Flavor` -> `Flavor...171`
#> • `Size` -> `Size...172`
#> • `x` -> `x...173`
#> • `Brand` -> `Brand...174`
#> • `Flavor` -> `Flavor...175`
#> • `Size` -> `Size...176`
#> • `x` -> `x...177`
#> • `Brand` -> `Brand...178`
#> • `Flavor` -> `Flavor...179`
#> • `Size` -> `Size...180`
#> • `x` -> `x...181`
#> • `Brand` -> `Brand...182`
#> • `Flavor` -> `Flavor...183`
#> • `Size` -> `Size...184`
#> • `x` -> `x...185`
#> • `Brand` -> `Brand...186`
#> • `Flavor` -> `Flavor...187`
#> • `Size` -> `Size...188`
#> • `x` -> `x...189`
#> • `Brand` -> `Brand...190`
#> • `Flavor` -> `Flavor...191`
#> • `Size` -> `Size...192`
#> • `x` -> `x...193`
#> • `Brand` -> `Brand...194`
#> • `Flavor` -> `Flavor...195`
#> • `Size` -> `Size...196`
#> • `x` -> `x...197`
#> • `Brand` -> `Brand...198`
#> • `Flavor` -> `Flavor...199`
#> • `Size` -> `Size...200`
#> • `x` -> `x...201`
#> • `Brand` -> `Brand...202`
#> • `Flavor` -> `Flavor...203`
#> • `Size` -> `Size...204`
#> • `condem` -> `condem...205`
#> • `condem` -> `condem...206`
#> • `condem` -> `condem...207`
#> • `condem` -> `condem...208`
#> • `condem` -> `condem...209`
#> • `condem` -> `condem...210`
#> • `condem` -> `condem...211`
#> • `condem` -> `condem...212`
#> • `condem` -> `condem...213`
#> • `condem` -> `condem...214`
#> • `condem` -> `condem...215`
#> • `condem` -> `condem...216`
#> • `condem` -> `condem...217`
#> • `condem` -> `condem...218`
#> • `condem` -> `condem...219`
#> • `condem` -> `condem...220`
#> • `condem` -> `condem...221`
#> • `condem` -> `condem...222`
#> • `condem` -> `condem...223`
#> • `condem` -> `condem...224`
#> • `condem` -> `condem...225`
#> • `condem` -> `condem...226`
#> • `condem` -> `condem...227`
#> • `condem` -> `condem...228`
#> • `condem` -> `condem...229`
#> • `condem` -> `condem...230`
#> • `condem` -> `condem...231`
#> • `condem` -> `condem...232`
#> • `condem` -> `condem...233`
#> • `condem` -> `condem...234`
#> • `condem` -> `condem...235`
#> • `condem` -> `condem...236`
#> • `condem` -> `condem...237`
#> • `condem` -> `condem...238`
#> • `condem` -> `condem...239`
#> • `condem` -> `condem...240`
#> • `condem` -> `condem...241`
#> • `condem` -> `condem...242`
#> • `condem` -> `condem...243`
#> • `condem` -> `condem...244`
#> • `condem` -> `condem...245`
#> • `condem` -> `condem...246`
#> • `condem` -> `condem...247`
#> • `condem` -> `condem...248`
#> • `condem` -> `condem...249`
#> • `condem` -> `condem...250`
#> • `condem` -> `condem...251`
#> • `condem` -> `condem...252`
#> • `condem` -> `condem...253`
#> • `condem` -> `condem...254`
#> • `condem` -> `condem...255`
#> Using 16 cores
#> New names:
#> • `x` -> `x...1`
#> • `Brand` -> `Brand...2`
#> • `Flavor` -> `Flavor...3`
#> • `Size` -> `Size...4`
#> • `x` -> `x...5`
#> • `Brand` -> `Brand...6`
#> • `Flavor` -> `Flavor...7`
#> • `Size` -> `Size...8`
#> • `x` -> `x...9`
#> • `Brand` -> `Brand...10`
#> • `Flavor` -> `Flavor...11`
#> • `Size` -> `Size...12`
#> • `x` -> `x...13`
#> • `Brand` -> `Brand...14`
#> • `Flavor` -> `Flavor...15`
#> • `Size` -> `Size...16`
#> • `x` -> `x...17`
#> • `Brand` -> `Brand...18`
#> • `Flavor` -> `Flavor...19`
#> • `Size` -> `Size...20`
#> • `x` -> `x...21`
#> • `Brand` -> `Brand...22`
#> • `Flavor` -> `Flavor...23`
#> • `Size` -> `Size...24`
#> • `x` -> `x...25`
#> • `Brand` -> `Brand...26`
#> • `Flavor` -> `Flavor...27`
#> • `Size` -> `Size...28`
#> • `x` -> `x...29`
#> • `Brand` -> `Brand...30`
#> • `Flavor` -> `Flavor...31`
#> • `Size` -> `Size...32`
#> • `x` -> `x...33`
#> • `Brand` -> `Brand...34`
#> • `Flavor` -> `Flavor...35`
#> • `Size` -> `Size...36`
#> • `x` -> `x...37`
#> • `Brand` -> `Brand...38`
#> • `Flavor` -> `Flavor...39`
#> • `Size` -> `Size...40`
#> • `x` -> `x...41`
#> • `Brand` -> `Brand...42`
#> • `Flavor` -> `Flavor...43`
#> • `Size` -> `Size...44`
#> • `x` -> `x...45`
#> • `Brand` -> `Brand...46`
#> • `Flavor` -> `Flavor...47`
#> • `Size` -> `Size...48`
#> • `x` -> `x...49`
#> • `Brand` -> `Brand...50`
#> • `Flavor` -> `Flavor...51`
#> • `Size` -> `Size...52`
#> • `x` -> `x...53`
#> • `Brand` -> `Brand...54`
#> • `Flavor` -> `Flavor...55`
#> • `Size` -> `Size...56`
#> • `x` -> `x...57`
#> • `Brand` -> `Brand...58`
#> • `Flavor` -> `Flavor...59`
#> • `Size` -> `Size...60`
#> • `x` -> `x...61`
#> • `Brand` -> `Brand...62`
#> • `Flavor` -> `Flavor...63`
#> • `Size` -> `Size...64`
#> • `x` -> `x...65`
#> • `Brand` -> `Brand...66`
#> • `Flavor` -> `Flavor...67`
#> • `Size` -> `Size...68`
#> • `x` -> `x...69`
#> • `Brand` -> `Brand...70`
#> • `Flavor` -> `Flavor...71`
#> • `Size` -> `Size...72`
#> • `x` -> `x...73`
#> • `Brand` -> `Brand...74`
#> • `Flavor` -> `Flavor...75`
#> • `Size` -> `Size...76`
#> • `x` -> `x...77`
#> • `Brand` -> `Brand...78`
#> • `Flavor` -> `Flavor...79`
#> • `Size` -> `Size...80`
#> • `x` -> `x...81`
#> • `Brand` -> `Brand...82`
#> • `Flavor` -> `Flavor...83`
#> • `Size` -> `Size...84`
#> • `x` -> `x...85`
#> • `Brand` -> `Brand...86`
#> • `Flavor` -> `Flavor...87`
#> • `Size` -> `Size...88`
#> • `x` -> `x...89`
#> • `Brand` -> `Brand...90`
#> • `Flavor` -> `Flavor...91`
#> • `Size` -> `Size...92`
#> • `x` -> `x...93`
#> • `Brand` -> `Brand...94`
#> • `Flavor` -> `Flavor...95`
#> • `Size` -> `Size...96`
#> • `x` -> `x...97`
#> • `Brand` -> `Brand...98`
#> • `Flavor` -> `Flavor...99`
#> • `Size` -> `Size...100`
#> • `x` -> `x...101`
#> • `Brand` -> `Brand...102`
#> • `Flavor` -> `Flavor...103`
#> • `Size` -> `Size...104`
#> • `x` -> `x...105`
#> • `Brand` -> `Brand...106`
#> • `Flavor` -> `Flavor...107`
#> • `Size` -> `Size...108`
#> • `x` -> `x...109`
#> • `Brand` -> `Brand...110`
#> • `Flavor` -> `Flavor...111`
#> • `Size` -> `Size...112`
#> • `x` -> `x...113`
#> • `Brand` -> `Brand...114`
#> • `Flavor` -> `Flavor...115`
#> • `Size` -> `Size...116`
#> • `x` -> `x...117`
#> • `Brand` -> `Brand...118`
#> • `Flavor` -> `Flavor...119`
#> • `Size` -> `Size...120`
#> • `x` -> `x...121`
#> • `Brand` -> `Brand...122`
#> • `Flavor` -> `Flavor...123`
#> • `Size` -> `Size...124`
#> • `x` -> `x...125`
#> • `Brand` -> `Brand...126`
#> • `Flavor` -> `Flavor...127`
#> • `Size` -> `Size...128`
#> • `x` -> `x...129`
#> • `Brand` -> `Brand...130`
#> • `Flavor` -> `Flavor...131`
#> • `Size` -> `Size...132`
#> • `x` -> `x...133`
#> • `Brand` -> `Brand...134`
#> • `Flavor` -> `Flavor...135`
#> • `Size` -> `Size...136`
#> • `x` -> `x...137`
#> • `Brand` -> `Brand...138`
#> • `Flavor` -> `Flavor...139`
#> • `Size` -> `Size...140`
#> • `x` -> `x...141`
#> • `Brand` -> `Brand...142`
#> • `Flavor` -> `Flavor...143`
#> • `Size` -> `Size...144`
#> • `x` -> `x...145`
#> • `Brand` -> `Brand...146`
#> • `Flavor` -> `Flavor...147`
#> • `Size` -> `Size...148`
#> • `x` -> `x...149`
#> • `Brand` -> `Brand...150`
#> • `Flavor` -> `Flavor...151`
#> • `Size` -> `Size...152`
#> • `x` -> `x...153`
#> • `Brand` -> `Brand...154`
#> • `Flavor` -> `Flavor...155`
#> • `Size` -> `Size...156`
#> • `x` -> `x...157`
#> • `Brand` -> `Brand...158`
#> • `Flavor` -> `Flavor...159`
#> • `Size` -> `Size...160`
#> • `x` -> `x...161`
#> • `Brand` -> `Brand...162`
#> • `Flavor` -> `Flavor...163`
#> • `Size` -> `Size...164`
#> • `x` -> `x...165`
#> • `Brand` -> `Brand...166`
#> • `Flavor` -> `Flavor...167`
#> • `Size` -> `Size...168`
#> • `x` -> `x...169`
#> • `Brand` -> `Brand...170`
#> • `Flavor` -> `Flavor...171`
#> • `Size` -> `Size...172`
#> • `x` -> `x...173`
#> • `Brand` -> `Brand...174`
#> • `Flavor` -> `Flavor...175`
#> • `Size` -> `Size...176`
#> • `x` -> `x...177`
#> • `Brand` -> `Brand...178`
#> • `Flavor` -> `Flavor...179`
#> • `Size` -> `Size...180`
#> • `x` -> `x...181`
#> • `Brand` -> `Brand...182`
#> • `Flavor` -> `Flavor...183`
#> • `Size` -> `Size...184`
#> • `x` -> `x...185`
#> • `Brand` -> `Brand...186`
#> • `Flavor` -> `Flavor...187`
#> • `Size` -> `Size...188`
#> • `x` -> `x...189`
#> • `Brand` -> `Brand...190`
#> • `Flavor` -> `Flavor...191`
#> • `Size` -> `Size...192`
#> • `x` -> `x...193`
#> • `Brand` -> `Brand...194`
#> • `Flavor` -> `Flavor...195`
#> • `Size` -> `Size...196`
#> • `x` -> `x...197`
#> • `Brand` -> `Brand...198`
#> • `Flavor` -> `Flavor...199`
#> • `Size` -> `Size...200`
#> • `x` -> `x...201`
#> • `Brand` -> `Brand...202`
#> • `Flavor` -> `Flavor...203`
#> • `Size` -> `Size...204`
#> • `condem` -> `condem...205`
#> • `condem` -> `condem...206`
#> • `condem` -> `condem...207`
#> • `condem` -> `condem...208`
#> • `condem` -> `condem...209`
#> • `condem` -> `condem...210`
#> • `condem` -> `condem...211`
#> • `condem` -> `condem...212`
#> • `condem` -> `condem...213`
#> • `condem` -> `condem...214`
#> • `condem` -> `condem...215`
#> • `condem` -> `condem...216`
#> • `condem` -> `condem...217`
#> • `condem` -> `condem...218`
#> • `condem` -> `condem...219`
#> • `condem` -> `condem...220`
#> • `condem` -> `condem...221`
#> • `condem` -> `condem...222`
#> • `condem` -> `condem...223`
#> • `condem` -> `condem...224`
#> • `condem` -> `condem...225`
#> • `condem` -> `condem...226`
#> • `condem` -> `condem...227`
#> • `condem` -> `condem...228`
#> • `condem` -> `condem...229`
#> • `condem` -> `condem...230`
#> • `condem` -> `condem...231`
#> • `condem` -> `condem...232`
#> • `condem` -> `condem...233`
#> • `condem` -> `condem...234`
#> • `condem` -> `condem...235`
#> • `condem` -> `condem...236`
#> • `condem` -> `condem...237`
#> • `condem` -> `condem...238`
#> • `condem` -> `condem...239`
#> • `condem` -> `condem...240`
#> • `condem` -> `condem...241`
#> • `condem` -> `condem...242`
#> • `condem` -> `condem...243`
#> • `condem` -> `condem...244`
#> • `condem` -> `condem...245`
#> • `condem` -> `condem...246`
#> • `condem` -> `condem...247`
#> • `condem` -> `condem...248`
#> • `condem` -> `condem...249`
#> • `condem` -> `condem...250`
#> • `condem` -> `condem...251`
#> • `condem` -> `condem...252`
#> • `condem` -> `condem...253`
#> • `condem` -> `condem...254`
#> • `condem` -> `condem...255`
# }