jeffgortmaker / pyblp

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

Question - Is there a way to incorporate FEs in Simulation? #150

Closed simonijain closed 10 months ago

simonijain commented 11 months ago

I am trying to run a simulation to compute the profits for all markets and products, even if some products are not being offered in some markets currently, for entry and exit with mergers analysis.

jeffgortmaker commented 11 months ago

Yes -- if you've incorporated FEs into estimation by absorbing them, you should add ProblemResults.xi_fe to ProblemResults.xi when initializing the simulation's xi. Is that what you meant?

jeffgortmaker commented 10 months ago

I'm going to close this for now, but feel free to re-open/keep commenting if you still have a question!

kenneth-rios commented 10 months ago

In previous versions of pyblp, I recall having to manually multiply pyblp.build_matrix(pyblp.Formulation('linear_product_formula'), product_data) with ProblemResults.beta and then subtract the matrix product from ProblemResults.compute_delta() in order to recover the full contribution of $\xi{jt}$ to $\delta{jt}$ (inclusive of absorbed fixed effects). It seems that we can now separably extract the contribution of the absorbed fixed effects (ProblemResults.xi_fe) from the contribution of the residualized unobserved product heterogeneity $\Delta\xi_{jt}$ (ProblemResults.xi). Their sum gives you the net contribution.

jeffgortmaker commented 10 months ago

Yes, exactly! I don't remember exactly when I added ProblemResults.xi_fe, but it's definitely a relatively new attribute that I added precisely to make this type of thing easier.