联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2024-03-31 06:26

ECO2404: Empirical Applications of Economic Theory

Homework Assignment

Overview

You will estimate demand and supply in a stylized model of the market for pay-TV services. You will use any programming language (Python/R/Matlab/Julia) to create your own fake data set for the industry and do some relatively simple estimation. Then, using the pyBLP package of Conlon and Gortmaker, you will estimate the model and perform some merger simulations. The pyBLP package has excellent documentation and a very helpful tutorial (which covers merger simulation), both easy to nd (https://pyblp.readthedocs.io/en/stable/). You may want to work through the tutorial notebooks available with the documentation (or on the Github page).

To install pyBLP you need to have Python 3 installed, I recommend Anaconda https://www. anaconda.com/distribution/. If you have python installed you simply need to type:

pip install pyblp

or

pip install git+https://github.com/jeffgortmaker/pyblp

Please submit a single printed document presenting your answers to the questions below, re- quested results, and code. Write this up cleanly with nice tables where appropriate. You may work in groups of up to 3 on the coding, but your write-up must be your own work and must indicate who your partners are.

You can do parts (2) and (3) in R, Matlab, Julia, or Python. Parts (4) and (5) use pyblp which you can run in R using reticulate if you really want.

1  Model

There are T markets, each with four inside goods j ∈ {1, 2, 3, 4} and an outside option. Goods 1 and 2 are satellite television services (e.g., Telus TV and Shaw Direct); goods 3 and 4 are wired television services (e.g., Rogers and Bell). The conditional indirect utility of consumer i for good j in market t is given by

uijt = β(1)xjt+ βsatellitejt+ βwiredjt+ αpjt+ ξjt+ ?ijt         j > 0

ui0t = ?i0t ,

where xjt  is a measure of good j's quality, pjt  is its price, satellitejt  is an indicator equal to 1 for the two satellite services, and wiredjt  is an indicator equal to 1 for the two wired services. The remaining notation is as usual in the class notes, including the i.i.d. type-1 extreme value ?ijt. Each consumer purchases the good giving them the highest conditional indirect utility.

Goods are produced by single-product rms. Firm j's (log) marginal cost in market t is

lnmcjt = γ0 + wjtγ1 + ωjt/8,

where wjt  is an observed cost shifter. Firms compete by simultaneously choosing prices in each market under complete information. Firm j has pro t

πjt =p(m)jt(a)x Mt(pjt? mcjt)sjt(pt).

2  Generate Fake Data

Feel free to use the software package of your choice

Generate a data set from the model above. Let

β(1)     =   1

βk)     ~  iid N (4, 1)  for k = 2, 3

α   =   ?2

γ (0)     =   1/2, γ(1) = 1/4.

1. Draw the exogenous product characteristic xjt  for T = 600 geographically de ned markets (e.g., cities). Assume each xjt  is equal to the absolute value of an iid standard normal draw, as is each wjt. Simulate demand and cost unobservables as well, specifying

( ωj(ξj)t(t)  )  N(( 0(0) ) , 0.25(1)   0.1(25) )) iid across j,t.

2. Solve for the equilibrium prices for each good j in each market t.

(a) Start by writing a procedure to approximate the derivatives of market shares with respect to prices. I.e., write a function that takes prices, shares, x, and demand parameters as inputs, and whose output is the derivative ?sjt/?pjt. To do so, the key steps are:

i. For each (j, t), write the choice probability sjt  as a weighted average (integral) of the (multinomial logit) choice probabilities conditional on the value of each consumer's random coe cients;

ii. Anticipating di erentiation under the integral sign, derive the analytical expression for the derivative of the integrand with respect to each pjt;

iii. Use the expression you obtained in (ii.) and simulation draws of the random coef-

cients to approximate the integral that corresponds to ?sjt/?pjt  for each j  (i.e., replace the integral with the mean over the values at each simulation draw).

iv. Experiment to see how many simulation draws you need to get precise approxima- tions and check this again at the equilibrium shares and prices you obtain below. (Hint: note that you do not want to take new simulation draws of the random coef- cients each time you call this procedure. This is because, if you did so, the attempt

to solve for equilibrium prices (below) may never converge due to  jittering  across iterations. So take your simulation draws only once, outside the procedure you write here.)

(b) To obtain equilibrium prices, use the supply side of the model. The FOC for  rm j's pro t maximization problem in market t is

(pjt? mcjt)? t) + sjt = 0

=? pjt? mcjt = ? ( ? t))?1 sjt                                       (1)

Substituting in your approximation of each ( ?t(p)t)), solve the system of equations (1)

(J equations per market) for the equilibrium prices in each market.

i. To do this, you will need to solve a system of J nonlinear equations in J unknowns, pt.  Make sure to check the exit  ag for each market to make sure you have a solution.

3. Calculate  observed  shares for your fake data set using your parameters, your draws of x,w,βi,ω,ξ, and your equilibrium prices.

3  Estimate Some Mis-speci ed Models

Feel free to use the software package of your choice

4. Estimate the plain multinomial logit model of demand by OLS (ignoring the endogeneity of prices).

5. Re-estimate the multinomial logit model of demand by two-stage least squares, instrumenting for prices with the exogenous demand shifters x and excluded cost shifters w. Discuss how the results di er from those obtained by OLS.

6. Provide two tables showing the true matrix of diversion ratios and the diversion ratios implied by your estimates in (5.). Discuss how those tables di er.

(Hint: See the de nition, and the formula, of the diversion ratios in Section 6.)

4  Estimate the Correctly Speci ed Model

7. Use the pyBLP package to estimate the correctly speci ed model. Report a table with the estimates of the demand parameters and standard errors. Do this three times:

(a) once when you estimate demand alone,

(b) then again when you estimate demand jointly with supply; and

(c) again when you estimate demand alone but now with the optimal IV.

Allow pyBLP to construct approximations to the optimal instruments, using the exogenous demand shifters and exogenous cost shifters.

8. Using your preferred estimates from the prior step (explain your preference), provide a table comparing the estimated own-price elasticities to the true own-price elasticities.

9. Provide two additional tables showing the true matrix of diversion ratios and the diversion ratios implied by your estimates.

5  Merger Simulation

10. Suppose two of the four  rms were to merge. Give a brief intuition for what theory tells us is likely to happen to the equilibrium prices of each good j.

11. Suppose  rms 1 and 2 are proposing to merge. Use the pyBLP merger simulation procedure to provide a prediction of the post-merger equilibrium prices.

12. Now suppose instead that  rms 1 and 3 are the ones to merge. Re-run the merger simula- tion. Provide a table comparing the (average across markets) predicted merger-induced price changes for this merger and that in part 11. Interpret the di erences between the predictions for the two mergers.

13. Thus far you have assumed that there are no e  ciencies (reduction in costs) resulting from the merger. Explain brie y why a merger-speci c reduction in marginal cost could mean that a merger is welfare-enhancing.

14. Consider the merger between rms 1 and 2, and suppose the rms demonstrate that by merging they would reduce marginal cost of each of their products by 15%. Furthermore, suppose that they demonstrate that this cost reduction could not be achieved without merging. Using the pyBLP software, re-run the merger simulation with the 15% cost saving. Show the predicted post-merger price changes (again, for each product, averaged across markets). What is the predicted impact of the merger on consumer welfare, assuming that the total measure of consumers Mt  is the same in each market t?

15. Explain why this additional assumption (or data on the correct values of Mt) is needed here, whereas up to this point it was without loss to assume Mt  = 1. What is the predicted impact of the merger on total welfare?

6  Coding Tips and Some Formulas

? Mixed-Logit Derivatives and Elasticities. In the mixed-logit model, the derivative of the choice probability of consumer i for product j , sij, with respect to the price of j , pj, and with repspect to price of k , pk, are, respectively,

 = βi · sij  · (1 ? sij),

pk(sij) = βi · sij  · sik .

Integrating them across consumers, we obtain the derivatives of the market shares:

?p(?s)j(j) = l pj(sij) dFi = l β· sij  · (1 ? sij)dFi ,

?p(?s)k(j) = l pk(sij) dFi = l β· sij  · sikdFi.

The substitution patterns (i.e., the own-price and cross-price elasticities) are therefore:

?sj,pj   = p(s)j(j) · s(p)j(j) = s(p)j(j) · l pj(sij) dFi =s(p)j(j) l β· sij  · (1 ? sij)dFi ,

?sj,pk   = p(s)k(j) · s(p)j(k) = s(p)j(k) · l?p(?si)k(j) dFi = ? s(p)j(k) l β· sij  · sikdFi.

? Diverison Ratios. The diversion ratio for products j and k is the fraction of consumers who leave product j after a price increase and switch to product k. Theoretically, it is expressed as the ratio of demand derivatives. Taking a matrix of diversion ratios, D, with respect to prices, p, the value in row j and column k  j is

Djk  = ?  .

Diversion ratios for the outside good are reported on diagonals:

Djj  = ?  .

? Generating Random Draws from a Normal Distribution. You can draw from a multivariate nor-

mal with variance Σ by drawing independent standard normal random variables and using the

Cholesky decomposition of Σ (the latter obtained with cholin Matlab or numpy.linalg.cholesky in Python).

Speci cally, the Cholesky decomposition factors a symmetric, positive-de nite matrix into the product of a lower triangular matrix and its conjugate transpose. For a covariance matrix Σ, Cholesky decomposition expresses Σ as Σ = LLT, where L is a lower triangular matrix with real and positive diagonal entries.

To generate samples from a multivariate normal distribution, g = (g1 ,...,gk) ~ N(μ,Σ):

1. Perform the Cholesky decomposition on Σ to obtain L.

2. Generate a vector 从 with each element drawn from a standard normal distribution, 从 = (1,...,从k) ~ N(0, Ik).

3. Transform. 从 using L through matrix multiplication: g = μ + L从, where 从 is one vector drawn from the multivariate normal distribution N(0, Ik).

? Data Migration. To migrate your data from Matlab/R/Julia to Python, try exporting and importing a csv (i.e., comma separated)  le. To export the data to a csv  le, look into the writematrix or writetable functions in Matlab.  To import the csv  le, look into pandas.read_csv in Python.

? Instruments.  When you estimate the logit model, you will have to choose which func- tions of the exogenous variables to use as instruments. One option would be to use all of them  the exogenous demand shifters (own and competing products) and the exogenous cost shifters. Alternatively, you might want to use something more like the BLP approximation of the optimal instruments. For example, for good j in market t, the instruments might be ①jt , wjt, satellitejt,山iTedjt , the quality index summed over competing goods ?j in market t. The pyBLP package gives some convenient built-in functionspyblp.build_blp_instruments() and pyblp.build_differentiation_instruments().

Of course, you do not need to feed an approximation of the optimal IV into pyBLP if you are going to have pyBLP compute a (better) approximation of the optimal instruments. Though the quality of the approximation depends on the initial set of instruments.

? Average Prices. To display the average prices, use the following (where changed_prices is the output of compute_prices as in Post-Estimation Tutorial of pyBLP).

T, J= 600, 4

print(changed_prices.reshape((T, J)).mean(axis= 0))

? Average Elasticities and Diversion Ratios. To display the average elasticities and diversion rations, use the following (where elasticities, for example, is the output of the command compute_elasticities in Post-Estimation Tutorial of pyBLP).

T, J= 600, 4

print(elasticities.reshape((T, J, J)).mean(axis= 0))

(These resemble what one would write in Matlab, but there are subtle issues behind it, in- cluding row-major order (Python) vs column-major order (Matlab).)

? Cost Reduction. To apply 15% cost reduction by the merged rms, use the following.

merger_costs= costs.copy()

merger_costs[product_data.merger_ids== 1]= 0.85*merger_costs[product_data.merger_ids== 1]

where costs and merger_ids areas in Post-Estimation Tutorial of pyBLP. (Using merger_costs= costs instead of using copy could lead to an unexpected behavior.)

? Welfare Formula. The consumer surplus for individual i is given by

ln 

??Vi1t

 ln exp(Vijt) ,

where Vijt = β(1)xjt+ βsatellitejt+ βwiredjt+ αpjt+ ξjt.

The average consumer surplus in market t is then

CSt = l CSit dFi.

Note that the numerator of CSit  is given by the expected consumer surplus for consumer i, where the expectation is taken over the idiosyncratic shock when it follows an extreme value distribution of type 1. I.e., when εit ~ EV (1), then

E (CSit)   =   E (mj(a)x{Vijt+ εijt})

=   ln exp(Vijt) .

Note also that p1t(Vi1)t   in the denominator of CSit  is the derivative of utility for the rst product

with respect to its price. The  rst product is chosen arbitrarily because this method assumes that there are no nonlinear income e ects, which implies that this derivative is the same for all products. (The computed consumer surpluses will likely be incorrect if prices are formulated in a nonlinear fashion like log(prices).)


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp