jeffgortmaker / pyblp

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

Questions on how to run simulation with different product attributes to different agents #149

Closed LichaoChen331 closed 8 months ago

LichaoChen331 commented 8 months ago

Hi Jeff,

Thank you for the work of creating the package.

I am facing a simulation problem with only the demand side (I set iteration method to be 'return'), where different individual (agent) are facing the same product list but with different attributes (think about a subsidy policy which the subsidy amount depends on individual's income level). I am not sure how pyblp can cope with this (or cannot) since there is only one price for each row in the product data.

My current thought is with only the demand side, I can run the simulation separately for different groups of individuals who share the same prices and other attributes. Then intergrate it toghether to calculate the market predicted shares gievn the weight of each agent. I am not sure whether this is correct. Another thought is to include demographic dummy variables in X2 with different columns for prices for different groups of agents. But the dimensions is also not matched.

However, if I include the supply side as well, the price is determined through the FOC but the marginal cost for each agent is different). I cannot run the simulation separately with different groups of agent with the same attributes. I do not how to deal with this sepcific case of simulation.

Thank you very much for your help!

Best,

Louis

jeffgortmaker commented 8 months ago

You can use product-specific demographics! See the docs under agent_data. A typical example is distance from i to j, but you can also specify different prices faced by each consumer type i for the same product j.

Your approach of defining a "market" as an actual market-consumer type pair is also fine if you're just doing your own simulation. If you wanted to estimate the model, you might want mean qualities to be common across these markets for the same product, so this approach wouldn't work and you might want to resort to the above product-specific demographics.

One thing that won't work is a supply side with product-specific demographics, i.e. PyBLP doesn't support firms choosing different prices for the same product (with the same quality) in the same market for different consumer types.

Does that help?

LichaoChen331 commented 8 months ago

Hi Jeff,

Thanks for your helpful comments!

Just want to make sure that I understand everything after I checked the docs. I think the 'availability' part might be better fitted compare to the 'distance' example. What you are suggesting is that I create a product list for each consumer type in the product data with different prices. Then I only allow the products designed for a consumer type to be aviable to that type by setting the availbility dummy variables. Is that what you meant?

On the supply side, I just want the firm to set one price for each product, but the marginal costs varies with different consumer types (to mimic the subsidy situation). It there any possible way to deliver this exerice?

Many thanks!

Louis


发件人: Jeff Gortmaker @.> 发送时间: 2023年10月17日 17:32 收件人: jeffgortmaker/pyblp @.> 抄送: Chen, Lichao @.>; Author @.> 主题: Re: [jeffgortmaker/pyblp] Questions on how to run simulation with different product attributes to different agents (Issue #149)

⚠ Caution: External sender

You can use product-specific demographics! See the docshttps://pyblp.readthedocs.io/en/stable/_api/pyblp.Problem.html under agent_data. A typical example is distance from i to j, but you can also specify different prices faced by each consumer type i for the same product j.

Your approach of defining a "market" as an actual market-consumer type pair is also fine if you're just doing your own simulation. If you wanted to estimate the model, you might want mean qualities to be common across these markets for the same product, so this approach wouldn't work and you might want to resort to the above product-specific demographics.

One thing that won't work is a supply side with product-specific demographics, i.e. PyBLP doesn't support firms choosing different prices for the same product (with the same quality) in the same market for different consumer types.

Does that help?

— Reply to this email directly, view it on GitHubhttps://github.com/jeffgortmaker/pyblp/issues/149#issuecomment-1766774738, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWWRDUTXPW5DWLS42Z7K7XLX72XLPAVCNFSM6AAAAAA6EEGIGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWG43TINZTHA. You are receiving this because you authored the thread.Message ID: @.***>

jeffgortmaker commented 8 months ago

So before clarifying, just to be clear from my end, are you doing any estimation? Or just a simulation?

LichaoChen331 commented 8 months ago

it is just the simulation.


发件人: Jeff Gortmaker @.> 发送时间: 2023年10月17日 18:24 收件人: jeffgortmaker/pyblp @.> 抄送: Chen, Lichao @.>; Author @.> 主题: Re: [jeffgortmaker/pyblp] Questions on how to run simulation with different product attributes to different agents (Issue #149)

⚠ Caution: External sender

So before clarifying, just to be clear from my end, are you doing any estimation? Or just a simulation?

— Reply to this email directly, view it on GitHubhttps://github.com/jeffgortmaker/pyblp/issues/149#issuecomment-1766855663, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWWRDUUVPUPSGEUEZNPFBNLX725L7AVCNFSM6AAAAAA6EEGIGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWHA2TKNRWGM. You are receiving this because you authored the thread.Message ID: @.***>

jeffgortmaker commented 8 months ago

Ah okay, that's easier. So I think with just the demand side, you can accomplish what you want (different attributes facing different consumers) with product-specific demographics, consumer-specific availability, or just having a different "market" for each group of consumers that you want to face different attributes. Probably the simplest is just the different "market" approach, since you'll just be extending your product_data and don't need to create a complicated agent_data.

The difficulty is with the supply side. The only endogenous variable that PyBLP supports adding to your marginal cost function is market shares (which you can scale by market size to get quantity). So just using PyBLP, you won't be able to have, say, marginal costs differ endogenously by how many of each type of consumer are purchasing the product.

I think your best option (if I'm understanding this correctly) might be to use the different "market" approach and code up your own custom function for solving for pricing equilibria in this setting. Without a custom function and with the different "market" approach, firms will be setting a different price for each product-consumer type pair. What you want to do is find the vector of prices for all products in an actual market that satisfy their profit-maximizing FOCs.

I think this is the same problem that @fpinter has in his paper on electric vehicles. Just replace his "region" with "consumer type", "regulatory credits" with "subsidy", and "national pricing" with "one price for each product." The relevant FOCs are equation (3) on page 24.

LichaoChen331 commented 8 months ago

Thanks Jeff. This is really helpful, espcially the supply side suggestions.

Best,

Louis


发件人: Jeff Gortmaker @.> 发送时间: 2023年10月17日 18:52 收件人: jeffgortmaker/pyblp @.> 抄送: Chen, Lichao @.>; Author @.> 主题: Re: [jeffgortmaker/pyblp] Questions on how to run simulation with different product attributes to different agents (Issue #149)

⚠ Caution: External sender

Ah okay, that's easier. So I think with just the demand side, you can accomplish what you want (different attributes facing different consumers) with product-specific demographics, consumer-specific availability, or just having a different "market" for each group of consumers that you want to face different attributes. Probably the simplest is just the different "market" approach, since you'll just be extending your product_data and don't need to create a complicated agent_data.

The difficulty is with the supply side. The only endogenous variable that PyBLP supports adding to your marginal cost function is market shares (which you can scale by market size to get quantity). So just using PyBLP, you won't be able to have, say, marginal costs differ endogenously by how many of each type of consumer are purchasing the product.

I think your best option (if I'm understanding this correctly) might be to use the different "market" approach and code up your own custom function for solving for pricing equilibria in this setting. Without a custom function and with the different "market" approach, firms will be setting a different price for each product-consumer type pair. What you want to do is find the vector of prices for all products in an actual market that satisfy their profit-maximizing FOCs.

I think this is the same problem that @fpinterhttps://github.com/fpinter has in his paperhttps://www.frankpinter.com/Pinter_JMP.pdf on electric vehicles. Just replace his "region" with "consumer type", "regulatory credits" with "subsidy", and "national pricing" with "one price for each product." The relevant FOCs are equation (3) on page 24.

— Reply to this email directly, view it on GitHubhttps://github.com/jeffgortmaker/pyblp/issues/149#issuecomment-1766893547, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWWRDUX72HX7MI6H2FDLB2LX73AWJAVCNFSM6AAAAAA6EEGIGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWHA4TGNJUG4. You are receiving this because you authored the thread.Message ID: @.***>

jeffgortmaker commented 8 months ago

For sure, happy to help! I'm going to close this for now, but please re-open/keep commenting if something else comes up.

LichaoChen331 commented 8 months ago

Hi jeff,

Sorry to reopen the issue.

I have a new idea to deal with the supply side where firms only set one price per product but consumers are facing different subsidies according their type. My idea is to first add subsidies for each consumer group as separate columns in the product data, then incorporate all the columns into the nonlinear variable X2. Also, I created consumer type dummies on the demographics and interacted with incomes. Now, the elements of the interactive matrix Pi between subsidies and type dummies (with potential incomes) are non-zero only when the subsidy is designed for that specific type. And the number of the non-zero element is the same as the estimated price/income coefficient. Does this works in this specific context where only one price is set but consumer's are facing different prices? I understand that for multi-pricing situation, rewriting the equilibra is inevitable. Am I miss something here especially on the zeta contraction part if I am using the technique above.

Best,

Louis

jeffgortmaker commented 8 months ago

Yes, that should absolutely work! This won't allow you to have different marginal costs for different consumer types, but it will allow you to have consumers that face different fixed subsidy amounts for the same product. Given this, the zeta contraction in PyBLP should work fine.

LichaoChen331 commented 8 months ago

Cool, thank you so much!


发件人: Jeff Gortmaker @.> 发送时间: 2023年10月19日 18:08 收件人: jeffgortmaker/pyblp @.> 抄送: Chen, Lichao @.>; Author @.> 主题: Re: [jeffgortmaker/pyblp] Questions on how to run simulation with different product attributes to different agents (Issue #149)

⚠ Caution: External sender

Yes, that should absolutely work! This won't allow you to have different marginal costs for different consumer types, but it will allow you to have consumers that face different fixed subsidy amounts for the same product. Given this, the zeta contraction in PyBLP should work fine.

— Reply to this email directly, view it on GitHubhttps://github.com/jeffgortmaker/pyblp/issues/149#issuecomment-1771395018, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWWRDUTO5YZI2Z44G6KKLDDYAFNA5AVCNFSM6AAAAAA6EEGIGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZRGM4TKMBRHA. You are receiving this because you authored the thread.Message ID: @.***>