plloydsmith / rmdcev

Implement MDCEV model in R using Stan
Other
11 stars 5 forks source link

Changing Product Observables #6

Closed rawls238 closed 3 years ago

rawls238 commented 3 years ago

Hi,

I am estimating the following model using the package: mdcev_est <- mdcev( ~ num_calories, data = data_rec, psi_ascs = 0, random_parameters="fixed", model = "alpha", algorithm = "Bayes", n_iterations = 500)

I want to estimate numerically the elasticities w.r.t. num_calories for each product. So, for instance, one way of doing this would be to estimate baseline demand using the estimates and then for each product consider the change in demand for num_calories + \epsilon. It does not appear to be possible to do something like this using the policies. I was considering whether I could directly change something in PrepareSimulationData but wanted to check if I was missing something first

plloydsmith commented 3 years ago

Hi, Yes for sure. Changes to the psi variables can be made after the initial policies object has been created. The key is to set the price_change_only option to FALSE so that the data_psi_p`` is included in thepolicies``` object and can be modified as desired.

policies <- CreateBlankPolicies(npols = npols,  
                     model = mdcev_est,  
                     price_change_only = FALSE) # set to false to include data_psi_p variables

For the first policy (if there are more than one), the first variable in psi can be changed by adding epsilon as below. Note that this will add an epsilon to every good so if you want to assess changes in demand for each good individually, you will need to create unique policies for each scenario.

policies$dat_psi_p[[1]][, 1] <- policies$dat_psi_p[[1]][, 1] + \epsilon

Hope that helps and let me know if you have any other questions.