You are on page 1of 72

Demand Estimation Using Aggregate Data:

Static Discrete Choice Models


K. Sudhir
Yale School of Management
Quantitative Marketing and Structural Econometrics Workshop
Duke University
July 30 - August 1 2013
Agenda
Session 1
Why is BLP popular in marketing?
The BLP algorithm to estimate discrete choice random
coefficients logit model with aggregate data
Reviewing BLP code for a simple example
Session 2
Compare BLP algorithm with MPEC algorithm
Instruments
Identification
Adding micro moments
Adding supply moments
Why has BLP demand estimation
become popular in marketing?
Motivation: Demand estimation using aggregate data
Demand estimation is critical element of marketing
analysis
Value of demand estimation using aggregate data
Marketers often only have access to aggregate data
Even if HH data available, these are not fully representative
Two main challenges in using aggregate data
Heterogeneity: Marketers seek to differentiate products that
appeal differentially to different segments to reduce
competition and increase margins; need to account for this
Endogeneity: Researchers typically do not know (or have data)
all factors that firms offer and consumers value in a product at
a given time or market, firms account for this in setting
marketing mixthis creates a potential endogeneity problem
Why is BLP demand estimation popular in marketing?
Berry Levinsohn and Pakes (1995) addresses all three issues
estimates differentiated product demand systems with
aggregate data
uses discrete choice models with random coefficients
(heterogeneity)
accounts for researcher unobservables that affect consumer
choice, and firms marketing mix choices, (endogeneity)
BLP gained quick acceptance because demand modelers
using household scanner data
Immediately understood the importance of accounting for
heterogeneity with aggregate data soon after the first papers
in marketing were published (Sudhir 2001; Chintagunta 2001)
But it took a bit longer to accept the endogeneity issue
What data do we need for
estimation?
Canonical aggregate market level data
Aggregate Market Data
Longitudinal: one market/store across time (e.g., BLP Ecta
1995/Sudhir Mkt Sci 2001/Chintagunta Mkt Sci 2001)
Cross-sections: multiple markets/stores (e.g., Datta and
Sudhir 2011)
Panel: multiple markets/stores across time (Nevo Ecta 2001;
Chintagunta, Singh and Dube QME 2003)
Typical variables used in estimation
Aggregate quantity
Prices/attributes/instruments
Definition of market size
Distribution of demographics (sometimes)
Typical Data Structure
Product Quantity Price Attributes Instruments
Market/Time 1
Market/Time 2
Product Quantity Price Attributes Instruments
Market size (M) assumption needed to get shares
j
jt
t
q
s
M

0
1
1
J
t j
j
s s

Notation
Markets or Periods:
Product
Consumer makes choice in market t
Indirect Utility Function:
observed product characteristics
unobserved (to researcher) product characteristics
price
observable consumer demographics
unobserved consumer attributes
Indirect Utility Function:
1, , t T
= = 0 1 0 with the outside good , , , , j J j
0 1 { , , , } j J
i
x n q ( , , , , ; )
jt jt jt it it
U x p D
jt
x
x
jt
jt
p
n
it
it
D
a e b x = + + +
i i ijt jt jt jt ijt
x p u
Notation
Indirect Utility Function:

where
Convenient to split the indirect utility into two parts

n
n
a a
b b
q
q





= + P + S






= P S
2
1
( , )

Heterogeneity
Mean

i
i
i
i
i
D
d x q m n q e = + +
1 2
( , , ; ) ( , , , ; )
Mean HH Deviations from Mean

ijt jt jt jt jt jt i i ijt
u x p x p D
n
d b a x m = + + = P + S , and ( , )( )
i
jt jt jt jt ijt jt jt i
x p p x D
a e b x = + + +
i i ijt jt jt jt ijt
x p u
Key Challenges for Estimation with Market Level Data
Heterogeneity:
Recovering heterogeneity parameters without consumer
data
Not an issue with consumer level data, because we have
heterogeneity in choices across consumers
Endogeneity:
is potentially correlated with price (and other
marketing mix variables)
Contrary to earlier conventional wisdom this can be an
issue with even consumer level data
b a ( , )
i i
x ( , )
jt jt
Corr p
x
jt
Motivation for Addressing Endogeneity
Trajtenberg (JPE 1989)
famous analysis of
Body CT scanners
using nested logit
model
Positive coefficient on
priceupward sloping
demand curve
Attributed to omitted
quality variables
Special Cases: Homogeneous Logit
and Nested Logit
Homogeneous Logit Notation
Indirect Utility Function:

where
Convenient to split the indirect utility into two parts

b a x e = + + +
ijt jt i i jt jt ijt
u x p

n
n
a a
b b
q
q





= + P + S






= P S
2
1
( , )

Heterogeneity
Average

i
i
i
i
i
D
d x q m n q e = + +
1 2
( , , ; ) ( , , , ; )
Mean HH Deviations from Mean

ijt jt jt jt jt jt i i ijt
u x p x p D
n
d b a x m = + + = P + S , and ( , )( )
i
jt jt jt jt ijt jt jt i
x p p x D
Homogenous Logit with Aggregate Data
If we have market share data,
Normalize

With homogeneous logit, we can invert shares to get


mean utility
jt
s
d
d
=
=

0
exp{ }
exp{ }
jt
jt
J
kt
k
s
d b a x - = = + +
0
ln( ) ln( )
: Data

jt t jt jt jt jt
jt
s s x p
y
d
=
=

0
0
1
exp{ }
t
J
kt
k
s
d =
0
exp{ }
jt
jt
t
s
s
d ( )
jt
d =
0
0
t
Homogenous Logit with Aggregate Data: 2SLS

If no endogeneity, we can use OLS


Given endogeneity of price, one can instrument for price
and use 2SLS
d b a x - = = + +
0
ln( ) ln( )
: Data

jt t jt jt jt jt
jt
s s x p
y
Homogeneous Logit with aggregate data: GMM
Alternatively, Berry (1994) suggests a GMM approach
with a set of instruments Z
Step 1: Compute
Let where
Step 2: GMM with moment conditions:
where
We have a nice analytical solution
where
Start with or to get initial estimate
Re-compute for new estimate of
d = -
0

ln( ) ln( )
jt jt t
s s
Min ( )' ' ( )
q
x q x q ZWZ
x q d b a = - -

( )
jt jt jt jt
x p
q b a = ( , )
( ' ' ) ( ' ' ) q d
-
=
1
X ZWZ X X ZWZ
= [ ] X x p
= W I
q
q
-
=
' 1
( ) W Z Z
xx
-
=
' ' 1
( ( )} W E Z Z
xx
-
=
' ' 1
( ( )} W E Z Z
x q =
'
( ( ) ) 0 E Z
Why homogeneous logit not great as a demand system
Own Elasticity:
Cross Elasticity:
Bad Properties:
Own elasticities proportional to price, so conditional on
share more expensive products tend to be more price
elastic!!
BMW328 will be more price elastic than Ford Mustang.
Cross-elasticity of product j, w.r.t. price of product k, is
dependent only on product ks price and share
BMW328 and Toyota Corolla will have same cross price
elasticity with respect to Honda Civic!!
h a

= = -



(1 )
j j
j j j
j j
s s
p s
p p
h a

= =



j j
jk k k
k k
s s
p s
p p
Nested Logit with Aggregate Data: Applying GMM
Nested logit provides more flexible elasticity patterns
Where proxies for intra-group correlation in
preferences
Even if no price endogeneity,
we cannot avoid instruments
Additional moments are
needed to estimate
The GMM approach will still work, as long as we have
two or more instruments to create enough identifying
restrictionsone each for
d b a x r - = = + + +
0
ln( / ) ln( ) ln( )
jt t jt jt j jt Gt t jt
s s x s s p
and a r
The Canonical BLP Random
Coefficients model
The Canonical BLP Random Coefficients Logit Model
Indirect Utility Function:

where
Split the indirect utility into two parts

Analytical inversion of no longer feasible


b a x e = + + +
ijt jt i i jt jt ijt
u x p

n
n
a a
b b
q
q





= + P + S






= P S
2
1
( , )

Heterogeneity
Average

i
i
i
i
i
D
d x q m n q e = + +
1 2
( , , ; ) ( , , , ; )
Mean HH Deviations from Mean

ijt jt jt jt jt jt i i ijt
u x p x p D
n
d b a x m = + + = P + S , and ( , )( )
i
jt jt jt jt ijt jt jt i
x p p x D
d
jt
Elasticities with heterogeneity better demand system

Own Elasticity:
Cross Elasticity:
Good Properties
Higher priced products more likely purchased by low

customerscan have lower elasticities


Cross elasticities vary across productsprice cut on
Honda Civic induces more switching from Toyota Corolla
than from BMW 328
h a n

= = -




(1 ) ( , )
j j j
j i ij ij
j j j
p s s
s s dF D
p p s
h a n

= = -




( , )
j j
k
jk i ij ik
k k j
s s
p
s s dF D
p p s
n
d m n q
d q n q
d m n q
=
+
=
+

2
2 2
,
2
0
exp{ ( , ; )}
( , ) ( , ; )
exp{ ( , ; )}
i i
jt ijt i i
jt t i i
J
D
kt ikt i i
k
D
s dF D
D
Logit vs RC logit: the value of heterogeneity (BLP)
With logit, outside
good captures all
effects of price
increase due to IIA
With RC logit, IIA
problem reduced
Expensive cars
have less
substitution to
outside good
Estimation using market level data: BLP algorithm
1. Draw (and if needed) for a set of (say NS=50)
consumers. Compute initial based on homogeneous logit.
2. Predicted shares
For given compute the HH deviations from mean utility
For given mean utility ( ) & ,compute predicted shares,
3. Contraction Mapping : Given nonlinear parameters ,
search for such that
4. From , estimate the linear parameters using an analytical
formula. Then form the GMM obj function
5. Minimize over with Steps 2-4 nested for every trial
q
2
s q
t
, x , p
2
( ; )
j t t
d
q
2
s q =
t
, x , p
2
( ; )
jt j t t
s d
d
t
i
n
i
D
m n q
2
( , , , ; )
jt jt i i
x p D
q
2
d
t
d
t
q
1
( ) q
2
Q
q
2
( ) q
2
Q
jt
d
q
2
An illustrative problem
Code and Data
Data provided in data.csv
Matlab code: Agglogit.m (main program) calls
AgglogitGMM.m (the function to be minimized)
Problem Definition
J=2 (brands), T=76 (periods)
Variables: price, advertising, 3 quarterly dummies
Cost instruments: 3 for each brand
Heterogeneity only on the 2 brand intercepts and price
Covariance:
s s
s s
s


S =






11 12
21 22
33
0
0
0 0






1
2 3
4
0 0
0
0 0
b
L b b
b
Step 1: Simulating HH draws
%Fix these draws outside
the estimation
w1=randn(NObs1,NCons);
w2=randn(NObs1,NCons);
wp=randn(NObs1,NCons);
%Convert to multivariate
draws within nonlinear
parameter estimation
aw1=b(1)*w1+b(2)*w2;
aw2=b(3)*w1;
aw2=b(3)*w1;
Cholesky Decomposition
'
n
S =
i
LL






1
2 3
4
0 0
0
0 0
b
L b b
b
Step 2: Computing market shares based on model
For logit and nested logit, can use analytic formulas
For random coefficients logit, integrate over the
heterogeneity by simulation

Where v

and

, i = 1, , NS are draws from F

(:) and F

()
that are drawn and fixed over optimization
Simulation variance reduction (see Train Ch. 9)
Importance sampling: BLP oversamples on draws leading to auto
purchases, relative to no purchase
Halton draws (100 Halton draws found better than 1000 random
draws for mixed logit estimation; Train 2002)
d n
s
d n
=
=
+ P +
=
+ P +

1
0
exp{ ( )( )}
1
exp{ ( )( )}

NS
jt jt jt i i
jt
J
i
kt kt kt i i
k
p x D
NS
p x D
Step 3: Contraction Mapping to get mean utility (
t
)
For logit and nested logit, you can get mean utility
analytically
For random coefficients, logit, you need a contraction
mapping, where you iterate till convergence
(i.e.,
t
h+1
t
h
< Tolerance)
d d s d q
+
= + - = x , p
1
2
1 ln( ) ln( ( , ; ), ,...,
h h h
t t t j t t t NS
s F h H ,
d d b a x - = - = + +
0 0
ln( ) ln( )
jt t jt t jt jt jt
s s x p
d d b a x r - = - = + + +
0 0
ln( ) ln ln ( ) ) ( /
jt t jt t j jt t t t jt j G
s s s s x p
Steps 2&3:Market Shares and Contraction Mapping
while (Err >= Tol)
de=de1;
sh=zeros(NObs1,1);
psh=zeros(NObs1,1);
%Integrating over consumer heterogeneity
for i=1:1:NCons;
psh=exp(aw(:,i)+awp(:,i)+de); psh=reshape(psh',2,NObs)';
spsh=sum(psh')';
psh(:,1)=psh(:,1)./(1+spsh); psh(:,2)=psh(:,2)./(1+spsh);
sh=sh+reshape(psh',NObs1,1);
end;
%Predicted Share
sh=sh/NCons;
%Adjust delta_jt
de1=de+log(s)-log(sh);
Err=max(abs(de1-de));
end;
delta=de1;
Step 4: Estimate parameters in two steps
A. Given , estimate and compute
B. Minimize the GMM Objective:
Where W is the GMM weight matrix
But W is based on . Start with weighting matrix W=I
and iterate on W, based on new estimates. In practice, I
start with W based on homogeneous logit, when
estimating random coefficients logit
( ) d q
2 t
( ) x q d b a = - -
2 jt jt jt jt
x p
x
jt
q
1
( ' ' ) ( ' ' ) q d
-
=
1
1
X ZWZ X X ZWZ
Min ( )' ' ( )
q
x q x q
2
ZWZ
( )
(( ( )' )'( ' ( ))) x q x q
-1
E Z Z
Step 4: Linear parameters and GMM objective function
% Analytically estimating linear parameters
blin=inv(xlin'*z*W*z'*xlin)*(xlin'*z*W*z'*delta);
% GMM Objective function over nonlinear parameters
er=delta-xlin*blin;
f=er'*z*W*z'*er;
Step 5: Optimizing over
2
Use a nonlinear optimizer to minimize the GMM
objective function in Step 4
The main file with data setup, homogeneous logit OLS,
homogeneous logit IV, and calling the nonlinear
optimizer are in file AggLogit.m
The GMM objective function nesting steps 2-4 are in the
file AggLogitGMM.m
% Calling the optimizer with appropriate options
[b, fval,exitflag,output,grad,hessian] = fminunc('AgglogitGMM',b0,options);
Standard errors should be computed by standard GMM
formula (Hansen 1982)
Summary
Why is BLP popular?
Handles aggregate data, heterogeneity and endogeneity
Reviewed estimation algorithms
Homogenous and nested logit reduces to a linear model
and can be estimated using an analytical formula
Random coefficients logit requires a nested algorithm
Reviewed an illustrative coding example
Summary: Key elements in programming BLP
BLP illustrative example code:
Simulation to integrate over random coefficients
distribution
Drawing from a multivariate distribution
Contraction mapping
Linearization of the mean utility to facilitate IV
Generalized Method of Moments
We numerically optimize only over the nonlinear parameters,
while estimating the linear parameters affecting mean utility
through an analytical formula (as with homogenous logit)
Session 2
Session 2: Agenda
Contrasting the contraction mapping algorithm with
the MPEC approach
Instruments
Identification
Improving identification and precision
Adding micro moments
Adding supply moments
Recall: The BLP Random Coefficients Logit Model
Indirect Utility Function: (Ignore income effects)

where
Split the indirect utility into two parts

b a x e = + + +
ijt jt i i jt jt ijt
u x p


Heterogeneity
Average
n
n
a a
b b
q
q





= + P + S






= P S
2
1
( , )

i
i
i
i
i
D
Mean HH Deviations from Mean
d x q m n q e = + +
1 2
( , , ; ) ( , , , ; )

ijt jt jt jt jt jt i i ijt
u x p x p D
n
d b a x m = + + = P + S , and ( , )( )
i
jt jt jt jt ijt jt jt i
x p p x D
Estimation using market level data: BLP algorithm
1. Draw (and if needed) for a set of (say NS=50)
consumers. Compute initial based on homogeneous logit.
2. Predicted shares
For given compute the HH deviations from mean utility
For given mean utility ( ) & ,compute predicted shares,
3. Contraction Mapping : Given nonlinear parameters ,
search for such that
4. From , estimate the linear parameters using an analytical
formula. Then form the GMM obj function
5. Minimize over with Steps 2-4 nested for every trial
q
2
s q
t
, x , p
2
( ; )
j t t
d
q
2
s q =
t
, x , p
2
( ; )
jt j t t
s d
d
t
i
n
i
D
m n q
2
( , , , ; )
jt jt i i
x p D
q
2
d
t
d
t
q
1
( ) q
2
Q
q
2
( ) q
2
Q
jt
d
q
2
Problem with BLP Contraction Mapping
BLP: Nesting a Contraction mapping for each trial of
Problems:
Can be slow: For each trial of , we have to do a
contraction mapping to obtain . This can be really slow
if we have poor trial values of
Unstable if the tolerance levels used in the nesting is too
high (suggested 10
-12
)
An alternative approach is to use the MPEC approach
that avoids the contraction mapping
Min
' '
( ) ( )
q
x q x q ZWZ
d
t
MPEC Approach (Dube, Fox and Su, Ecta 2011)
MPEC: Mathematical Programming with Equilibrium
Constraints
Reduce to a constrained nonlinear programming problem
You have to search over both
With J brands and T periods(markets),JT parameters
But no contraction mapping for each trial of 0
Nonlinear optimizers can do this effectively for small JT, but
convergence can be tricky as JT becomes large
Min
subject to:
' '
,
( , , )
q x
x x
s x q = , x, p
j ns
ZWZ
F S
Contrast MPEC with BLP Contraction Mapping
MPEC (Dube, Fox and Su 2011)
BLP: Nesting a contraction mapping for each trial of
Min
' '
( ) ( )
q
x q x q ZWZ
Min
subject to:
' '
,
( , )
q x
x x
s x = , x, p
j ns j
ZWZ
F S
Choosing Instruments
Choosing instruments
The BLP (and MPEC) estimation procedure is based
on instruments Z that satisfy the moment condition
IVs are needed for:
Moment conditions to identify (heterogeneity)
Recall nested logit needed instruments even if price were not
endogenous
Correcting for price (and other marketing mix)
endogeneity
IV should be correlated with price but not with
]t
( | ) x = 0
jt
E Z
q
2
Common Instruments: (1) Product Characteristics
Own product characteristics (Almost all papers)
These can just identify the linear parameters associated with these
characteristics in the mean utility
Other product characteristics (BLP)
Sum of characteristics of other products produced by firm
Sum of characteristics of competitor products
Sudhir (2001) use sums by product group
Intuition for instrument validity: other product characteristics
have no direct impact on consumer utility for product, but
through competition impacts prices
Key assumption: Characteristics are chosen before
]t
known
Widely used because it is generally available
Common Instruments (2): Cost Shifters
Characteristics entering cost, but not demand
Generally hard to find
BLP use scale economies argument to use total
production as a cost instrument
Input factor prices
Affects costs and thus price, but not directly demand
Often used to explain price differentials across time, but
often does not vary across brands (e.g., market wages)
If we know production is in different states or countries, we
can get brand specific variation in factor costs (e.g., Sudhir,
Chintagunta and Kadiyali (Mkt Sci 2005) use US and
Japanese factor costs for Kodak and Fuji respectively.
Common Instruments (3): Prices in other markets
Prices of products in other markets (Nevo 2001; Hausman
1996)
If there are common cost shocks across markets, then price in
other markets can be a valid instrument
But how to justify no common demand shocks? (e.g., national
advertising; seasonality)
Common Instruments (4): Lagged Characteristics
When current characteristics are simultaneously related to the
unobservables, one may motivate use of lagged characteristics
similar to the dynamic panel data literature
Example: Sweeting (Ecta, 2012) assumes an AR(1) process on
the unobservables , where
to justify the moment condition
Can lagged prices be a valid instrument?
Not if last weeks promotions drives this weeks unobservable
(e.g., due to stockpiling, which is unobserved)!!
( | )
jt jt t
E x x rx
- -
- =
1 1
0
x rx h
-
= +
1 jt jt jt
( | )
jt t
E x h
-
=
1
0
Importance of IV Correction: BLP
Identification
Step back: suppose we have consumer choice data
Step 1: Estimate by Simulated ML
Assuming iid double exponential for
Note, , i.e., heterogeneity is identified off differences in
household choices for same - not available in market data
Step 2: Estimate
identified based on cross market/time variations
Correction for endogeneity needed even with consumer data
d q
2
( , )
q
1
d b a x = + +

jt jt jt jt
x p
n
d n
n
d n
=
+ P +
=
+ P +

0
exp{ ( ) }
( )
exp{ ( ) }
i
jt jt jt i i
ijt i
J
kt kt kt i i
k
p x D
P dF
p x D
e
ijt
q
1
n
q = P S
2
( , )
i
( )
jt jt
p x
Variation in aggregate data that allows identification
Some of the identification is due to functional form
But we also need enough variation in product
characteristics and prices and see shares changing in
response across different demographics for identification
Across markets, variation in
demographics , choice sets (possibly)
Across time, variation in
choice sets (possibly), demographics (possibly)
To help further in identification
add micro data
add supply model
Variation in some familiar papers
BLP (1995)
National market over time (10 years)
Demographics hardly changes, but choice sets
(characteristics and prices) change
Identification due to changes in shares due to choice sets
Nevo (2001)
Many local markets, over many weeks
Demographics different across markets, product
characteristics virtually identical, except prices
Identification comes from changes in shares across
choice sets and across demographics
Caveats about cross-sectional variation across markets
Selection Problem: Is
]m
affected by market
characteristics?
E.g., less fresh vegetables sold at lower prices in poor
neighborhoods
May need to model selection
Can distribution of be systematically different across markets?
If richer cities have better cycling paths for bikes (a market
unobservable), distribution of random coefficients for bike
characteristics may differ across markets (by income)
allowing for heterogeneity in distributions across markets may be
necessary.
Caution: identification of heterogeneity is tough with
aggregate data, so we should not get carried away in
demanding more complexity in modeling
n
i
Two other ways to improve identification and precision
Add micro data based moments
Add supply moments
Identification:
Adding Micro Moments
Aggregate data may be augmented with micro data
Consumer Level Data
panel of consumer choice data (Chintagunta and Dube JMR
2005)
cross-sections of consumer choice
second choice data on cars (BLP, JPE 2004)
Survey of consideration sets (theater, dvd) (Luan and Sudhir, WP
2006)
Segment Summaries
Quantity/share by demographic groups (Petrin, JPE 2002)
Average demographics of purchasers of good j (Petrin JPE
2002)
Consideration set size distributions (Albuquerque et al. Mkt
Sci 2009)
Augmenting market data with micro data (e.g., Petrin)
Examples of micro-moments added by Petrin (2002)
Set 1: Price Sensitivity
Set 2: Choice and demographics (Family Size, Age)
<
< <
>
1
1 2
2
purchases new vehicle|{
purchases new vehicle|{
purchases new vehicle|{
[{ }]
[{ }]
[{ }]
i
i
i
E i y y
E i y y y
E i y y
| purchases a minivan
| purchases a station wagon
| purchases a SUV
| purchases a fullsize van
[{ }]
[{ }]
[{ }]
[{ }]
i
i
i
i
E fs i
E fs i
E fs i
E fs i
Importance of micro data (Petrin 2002)
Importance of micro data (Petrin 2002)
Identification:
Adding Supply Moments
Adding a Supply Equation
Adding a supply equation can increase precision of demand
side estimates
A Bertrand pricing assumption is usually used (BLP); using FOC
Where O is the ownership matrix where O
ij
=1, if i and j are
owned by the same firm
Even if Bertrand assumption is incorrect (supply equation is mis-
specified, say due to dynamics), demand estimates tend to be
consistent in characteristics based models as
(1) characteristics based price regressions (hedonics) tend to have good R
2
(2) link between margins and elasticity (own and cross) is generally right.
...
... ... ... ... ... . * ...
...
-


= +








1 1
1
1
1
1 1 1
J
J J
J
ds ds
dp dp
ds ds
J J J
dp dp
p c s
O
p c s
Adding a Supply Equation (contd)

Construct the supply errors as


One can create and stack supply moments using these
supply errors with cost based instruments (see BLP
1995; Sudhir 2001)
...
... ... ... ... ... . * ...
...
t t
t Jt
Jt Jt
t Jt
ds ds
dp dp
t t t
t
ds ds
Jt Jt Jt
dp dp
c p s
O
c p s
-



= -











1 1
1
1
1
1 1 1
Margin ( ) m
jt

jt jt jt jt
jt
p m wW
c
w - = +

( )
jt jt jt jt
p m W w q w = - -
Adding a supply equation (contd)
Supply errors:
Supply moments based on cost side instruments (Z
c
):
Stack the supply moments over the demand moments:
Since there is a pricing equation for each product
in effect, we double the number of observations (of
course correlation between equations),
at the expense of estimating few more cost parameters
This helps improve the precision of estimates
( )
jt jt jt jt
p m W w q w = - -
( | ) w = 0
jt c
E Z
( ) |
( , ) |
x q
w q w


=



0
jt
jt c
Z
E
Z
Where to modify earlier code for supply equation
while (Err >= Tol)
de=de1;
sh=zeros(NObs1,1);
psh=zeros(NObs1,1);
%Integrating over consumer heterogeneity
for i=1:1:NCons;
psh=exp(aw(:,i)+awp(:,i)+de); psh=reshape(psh',2,NObs)';
spsh=sum(psh')';
psh(:,1)=psh(:,1)./(1+spsh); psh(:,2)=psh(:,2)./(1+spsh);
sh=sh+reshape(psh',NObs1,1);
end;
%Predicted Share
sh=sh/NCons;
%Adjust delta_jt
de1=de+log(s)-log(sh);
Err=max(abs(de1-de));
end;
delta=de1;
1. Compute own and cross price
elasticity (see next slide for
formula) for each household
along with shares
2. Use these to construct
margins along with delta
Recall: Elasticities with heterogeneity
Own Elasticity:
Cross Elasticity:
h a n

= = -




(1 ) ( , )
j j j
j i ij ij
j j j
p s s
s s dF D
p p s
h a n

= = -




( , )
j j
k
jk i ij ik
k k j
s s
p
s s dF D
p p s
Where to modify earlier code for supply equation
% Analytically estimating linear parameters
blin=inv(xlin'*z*W*z'*xlin)*(xlin'*z*W*z'*delta);
% GMM Objective function over nonlinear parameters
er=delta-xlin*blin;
f=er'*z*W*z'*er;
3. Estimate the linear cost
parameters
4. Construct the supply error
5. Stack the supply moments
with appropriate weighting
matrix in constructing the
GMM objective function
Exercises
Estimate the model with supply side moments added
Compute the standard errors for the estimated demand
side parameters
See Appendix to these slides on computing standard
errors.
Summary
Session 1:
Why is BLP so popular in marketing?
Handles heterogeneity and endogeneity in estimating demand systems with easily
available aggregate data
The BLP algorithm and illustrative code
Simulation based integration, contraction mapping for mean utility, analytical
formula for linear parameters, numerical optimization for the nonlinear parameters
Session 2
MPEC versus BLP Contraction mapping (Nested Fixed Point)
Instruments
Identification
Improving precision through
Micro data based moments
Supply moments
8/ 2/ 13 7: 24 AM C: \ User s\ sk389\ Dr opbox\ Duke\ AggLogi t . m 1 of 2
%Sampl e code t o i l l ust r at e est i mat i on of BLP r andomcoef f i ent s model
%wi t h aggr egat e dat a
%Wr i t t en by K. Sudhi r , Yal e SOM
%For t he Quant i t at i ve Mar ket i ng and St r uct ur al Economet r i cs Wor kshop
%at Duke Uni ver si t y- 2013

%Var i abl es f or demand equat i on ( y, x) and t he i nst r ument s ( z)
y=l og_s_s0;
x=[ i nt p ad qt r ] ;
z=[ i nt cost l ad qt r ] ;

%Homogeneous l ogi t wi t hout endogenei t y f i x
bOLS=i nv( x' *x) *x' *y;
bOLS

%Homogeneous l ogi t wi t h endogenei t y f i x ( W=I )
W=eye( si ze( z, 2) , si ze( z, 2) ) ;
bI V1=i nv( x' *z*W*z' *x) *x' *z*W*z' *y;
bI V1

%Homogeneous l ogi t wi t h endogenei t y f i x ( W=i nv( z' *z) ) bet t er t han W=I , when
%di f f er ent i nst r ument s have ver y di f f er ent numer i cal magni t udes; t hi s
%equal i zes t he r el at i ve wei ght s of t he i nst r ument s i n GMM
W=i nv( z' *z) ;
bI V2=i nv( x' *z*W*z' *x) *x' *z*W*z' *y;
bI V2

%Homogeneous l ogi t wi t h endogenei t y f i x ( W=i nv( E( z' ksi *ksi ' *z) ) )
der r =y- x*bI V2;
zder r =z;
f or i =1: 1: si ze( z, 2) ;
zder r ( : , i ) =z( : , i ) . *der r ;
end;
W=i nv( ( zder r ) ' *( zder r ) ) ;
bI V3=i nv( x' *z*W*z' *x) *x' *z*W*z' *y;
bI V3

%Het er ogeneous l ogi t wi t h endogenei t y f i x
%Not e I dr aw di f f er ent 50 i ndi vi dual s f or t he di f f er ent mar ket s ( t i me per i ods) f r omt he
%same di st r i but i on. Wi t h mar ket s, t hi s i s per f ect l y l ogi cal .
%Wi t h t i me, one coul d ar gue we need t he same 50 i ndi vi dual s acr oss
%mar ket s. However , si nce t her e i s no panel st r uct ur e i n choi ces acr oss t i me,
%di f f er ent i ndi vi dual s acr oss t i me i s al so cor r ect .
%The advant age I see wi t h di f f er ent i ndi vi dual s i s t hat you sampl e acr oss
%a wi der set of househol ds f r omt he di st r i but i on

NCons=50;
xl i n=[ i nt p ad qt r ] ;
w1=r andn( NObs1, NCons) ;
w2=r andn( NObs1, NCons) ;
wp=r andn( NObs, NCons) ;
8/ 2/ 13 7: 24 AM C: \ User s\ sk389\ Dr opbox\ Duke\ AggLogi t . m 2 of 2
wp=( r eshape( [ wp' ; wp' ] , NCons, NObs1) ) ' ;
b0=ones( 4, 1) ;

bl i n=bI V3;

opt i ons=opt i mset ( ' Di spl ay' , ' i t er ' , ' Tol Fun' , 1e- 12, ' Tol X' , 1e- 12, ' MaxI t er ' , 2500,
' MaxFunEval s' , 5000, ' Lar geScal e' , ' of f ' , ' HessUpdat e' , ' df p' ) ;
[ b, f val , exi t f l ag, out put , gr ad, hessi an] = f mi nunc( ' Aggl ogi t GMM' , b0, opt i ons) ;


%Compar i ng t he l i near par amet er s acr oss t he di f f er ent met hods
bResul t s=[ bOLS bI V1 bI V2 bI V3 bl i n]
%For mat t ed Repor t i ng of t he same par amet er s
hor z= [ ' bOLS' ' bI V- W=I ' ' bI V- W=zz ' ' bI V- W- ksi *z' ' bl i n- het er o' ] ;
ver t =[ ' I nt 1 ' ; ' I nt 2 ' ; ' Pr i ce' ; ' Ad ' ; ' Q1 ' ; ' Q2 ' ; ' Q3 ' ] ;
di sp( hor z)
f or i = 1: 1: si ze( ver t ) ;
di sp( ver t ( i , : ) )
di sp( bResul t s( i , : ) )
end;
%The RC Logi t Model est i mat es wi t h bot h l i near ( bl i n) and nonl i near ( b) par amet er s
bResul t s1=[ bl i n; b] ;

%For mat t ed Repor t i ng of t he same par amet er s
hor z= [ ' bFul l - het er o ' ] ;
ver t =[ ' I nt 1 ' ; ' I nt 2 ' ; ' Pr i ce' ; ' Ad ' ; ' Q1 ' ; ' Q2 ' ; ' Q3 ' ; ' L11 ' ; ' L12
' ; ' L22 ' ; ' Si gp ' ; ] ;
di sp( hor z)
f or i = 1: 1: si ze( ver t ) ;
di sp( ver t ( i , : ) )
di sp( bResul t s1( i , : ) )
end;

8/ 2/ 13 7: 15 AM C: \ User s\ sk389\ Dr opbox\ Duke\ Aggl ogi t GMM. m 1 of 1
%Sampl e code t o i l l ust r at e est i mat i on of BLP r andomcoef f i ent s model
%Wr i t t en by K. Sudhi r , Yal e SOM
%For Quant i t at i ve Mar ket i ng & St r uct ur al Economet r i cs Wor kshop @Duke- 2013
%Thi s i s code f or t he GMM obj ect i ve f unct i on t hat needs t o mi ni mi zed
f unct i on f =Aggl ogi t GMM( b)
gl obal w1 w2 wp x y z NCons NObs NObs1 xl i n bl i n Wz s bl i n l og_s_s0;
%St ep 1: Mul t i pl yi ng f i xed St andar d Nor mal dr aws by l ower t r i angul ar Chol esky mat r i x
%par amet er s t o get t he mul t i var i at e het er ogenei t y dr aws on i nt er cept s and
%pr i ces
aw=w1;
awp=wp;
aw1=b( 1) *w1+b( 2) *w2;
aw2=b( 3) *w1;
%St ep 2: Const r uct i ng t he nonl i near par t of t he shar e equat i on ( mu)
%usi ng t he het er ogenei t y dr aws on i nt er cept s and pr i ce coef f
f or i =1: 1: si ze( w1, 2) ;
aw( : , i ) =aw1( : , i ) . *x( : , 1) +aw2( : , i ) . *x( : , 2) ;
awp( : , i ) =b( 4) *x( : , 3) . *wp( : , i ) ;
end;
del t a=l og_s_s0;
Er r =100;
Tol =1e- 12;
de1=del t a;
%St ep 3: Cont r act i on Mappi ng t o get t he del t a_j t unt i l Tol er ance l evel met
whi l e ( Er r >= Tol )
de=de1;
sh=zer os( NObs1, 1) ;
psh=zer os( NObs1, 1) ;
%Obt ai ni ng t he pr edi ct ed shar es based on model
f or i =1: 1: NCons;
psh=exp( aw( : , i ) +awp( : , i ) +de) ;
psh=r eshape( psh' , 2, NObs) ' ;
spsh=sum( psh' ) ' ;
psh( : , 1) =psh( : , 1) . / ( 1+spsh) ;
psh( : , 2) =psh( : , 2) . / ( 1+spsh) ;
sh=sh+r eshape( psh' , NObs1, 1) ;
end;
sh=sh/ NCons;
%Updat i ng del t a_j t based on di f f er ence bet ween act ual shar e and
%pr edi ct ed shar es
de1=de+l og( s) - l og( sh) ;
Er r =max( abs( de1- de) ) ;
end;
del t a=de1;
%St ep 4: Get t i ng t he l i near par amet er s and set t i ng up t he obj ect i ve f n
bl i n=i nv( xl i n' *z*W*z' *xl i n) *( xl i n' *z*W*z' *del t a) ;
ksi =del t a- xl i n*bl i n;
%The GMM obj ect i ve f unct i on t hat wi l l be opt i mi zed over t o get
%nonl i near par amet er s
f =ksi ' *z*W*z' *ksi ;

Estimating Standard Errors for a BLP Model
K. Sudhir, Yale School of Management
Prepared for the Quantitative Marketing and Structural Econometrics Conference
Duke University-2013
The asymptotic covariance matrix for the GMM estimator is given by (See Cameron and Trivedi,
2005; or any standard textbook which discusses GMM).
GMM
V N DZWZ D DZWSZ D DZWZ D b
- -
=
1 1 ' ' ' ' ' '

( ) [ ] [ ][ ]
Where =
1. D X
q
d q =
2
2

[ ( ( )] , where D is the Jacobian of the moment conditions with respect to q .


For the linear parameters q
1
, this reduces to the corresponding variables X, while we need
to take the derivatives with respect to q
2

2.
N
i i i i
i
S Z Z
N
x x
=
=

1
1
' '


3. W is the weighting matrix used in the GMM estimation
q
d q
2
2

( ( ) needs to be computed as an integral over the consumer heterogeneity, and therefore


needs to be embedded in the code where the simulated shares are calculated. Since these gradients
are not needed in the estimation, it should be computed outside the estimation loops.
t t t t t t
L L L
Jt Jt Jt Jt Jt Jt
L L L
s s s s
t
s s s s
D
d d
q q d d q q
q
d d
q q d d q q
d q d
-








= = =




1 1 1 1 1 1
21 2 21 2 21 2
2
21 2 21 2 21 2
1
2



.

( ( )


NS
jt
jti jti
i
jt
NS
jt
jti kti
i
kt
NS J
jt l l l
i jti jt kt kti
i k
l
s
s s
NS
s
s s
NS
s
s x x s
NS
d
d
n
q
=
=
= =

= -



= -


1
1
1 1
2
1
1
1
1
( )

Standard errors are obtained from the square root of the diagonal of
GMM
V b

( ) .

You might also like