jeffgortmaker / pyblp

BLP Demand Estimation with Python
https://pyblp.readthedocs.io
MIT License
240 stars 83 forks source link

Boostrap the change in consumer surplus under a counterfactual scenario #144

Closed whuxuan closed 1 year ago

whuxuan commented 1 year ago

Hi Jeff and Chris,

Thank you so much for your work on this fantastic package!

I am now trying to get the standard error for the change in consumer surplus under a relatively complicated counterfactual scenario, which is similar to what you did for the removal of minivan. I saw you mentioned at the end of the turorial that you bootstrapped the whole procedure. To confirm I understand it correctly, does it mean that you: (1) get a number of draws from the estimated parameters; (2) input one draw of these parameters into a simulation class; (3) solve the simulation problem and calculate the CS change; and (4) repeat this whole process. Is this the correct understanding? If not, could you please provide any suggestions on doing this maybe using some of the existing functions in this package? I was also wondering whether there has already been a function of creating the draws of estimated parameters in the package.

Thank you in advance for your time! Please let me know if anything is not clear here.

jeffgortmaker commented 1 year ago

Yes! That's precisely what we did.

You can use ProblemResults.bootstrap to draw from an estimate of the (asymptotic) distribution of your parameter estimates. You should probably follow the note on that page in the docs, setting draws=1 in a loop.

If your counterfactual is fairly complicated/time-consuming, I'd also recommend breaking down the loop and putting each draw into a separate job on a grid, if you have access to a grid.

whuxuan commented 1 year ago

Thank you so much for your quick reply. This is very helpful. I will try it.

jeffgortmaker commented 1 year ago

Great, I'll close this for now, but please keep commenting/re-open the issue if anything else on this comes up.