Estimating Logit Models using Household Level and Aggregate Data K. Sudhir MGT 756 Spring 2014 Yale University
Three Estimation Models Individual Level Models Guadagni and Little (1983) Heterogeneity Modeled exponential smoothing measure Kamakura and Russell (1994) Unobserved Heterogeneity using discrete segment approach Gonul and Srinivasan (1993) Unobserved Heterogeneity using continuous distribution approach We will discuss the first two models Aggregate Level Models Sudhir (2001) Chintagunta (2001) paper for its discussion on how without attributes, it uses a covariance matrix of the intercepts to model attribute similarities.
Guadagni and Little (1983) Utility Model Loyalty Normalization Likelihood function Optimization and computing Standard Errors
Loyalty Variable %Constructing Loyalty Variable BrLoy=ones(NObs,NProd); for i = 1:1:NCons; BrLoy(PIDSt(i),:)=1/NProd; for j=PIDSt(i)+1:1:PIDSt(i+1)-1; BrLoy(j,:)= alph*BrLoy(j-1,:)+(1-alph)*Ch(j,:); end;
Normalization %Subtracting out the normalized product's variables for i=1:1:NProd; Price1(:,i)=Price(:,i)-Price(:,NProd); Feat1(:,i)=Feat(:,i)-Feat(:,NProd); Disp1(:,i)=Disp(:,i)-Disp(:,NProd); BrLoy1(:,i)=BrLoy(:,i)-BrLoy(:,NProd); end;
Likelihood function function f= GLNegLogLik(x) %Global Variables made available from the main function global Price1 Feat1 Disp1 BrLoy1 Ch NObs NProd; expU=ones(NObs,NProd); for i=1:1:NProd-1; expU(:,i)=exp(x(i)+x(NProd)*Price1(:,i)+x(NProd+1)*Feat1(:,i)+x(NProd+2)*Disp1(:,i) +x(NProd+3)*BrLoy1(:,i)); end; expU(:,NProd)=1; SU=(sum(expU'))'; Prob=expU./[SU SU SU SU]; f = -sum(sum(Ch.*log(Prob)));
Maximizing Likelihood, Computing SEs options=optimset('Display','iter','TolFun',1e-4,'TolX', 1e-4,'MaxIter',25, 'MaxFunEvals',560, 'LargeScale','off', 'HessUpdate', ‘bfgs’); [x, fval,exitflag,output,grad,hessian] = fminunc('GLNegLogLik',x0,options); se=sqrt(diag(inv(hessian))); tstat=x./se;
Exercise Estimate the model without the loyalty variable Report the estimates Compute U2 Compute the U2 for the model with the loyalty variable as here.
Kamakura and Russell (1989) Utility Model Discrete Heterogeneity Normalization Likelihood function Optimization and computing Standard Errors
expU=ones(NObs,NProd*NSeg); SU=ones(NObs,1); Prob=ones(NObs,NSeg); Lik=ones(NCons,NSeg);
Computing Event Likelihood for Each Segment for j=1:1:NSeg; for i=1:1:NProd-1; expU(:,(j-1)*NProd+i)=exp(x((j-1)*(NProd+NVar-1)+i) +x((j-1)*(NProd+NVar-1)+NProd)*Price1(:,i) +x((j-1)*(NProd+NVar-1)+NProd+1)*Feat1(:,i) +x((j-1)*(NProd+NVar-1)+NProd+2)*Disp1(:,i)); end; expU(:,j*NProd)=1; SU=(sum(expU(:,(j-1)*NProd+1:j*NProd)'))'; Temp=(expU(:,(j-1)*NProd+1:j*NProd)./[SU SU SU SU]).^Ch; Prob(:,j)=prod(Temp')';
Likelihood of each person’s purchase string for i=1:1:NCons; Lik(i,:)=prod(Prob(freq(i):freq(i+1)-1,:)); end;
Computing the Overall Log-Likelihood siz=exp(x((NProd-1+NVar)*NSeg+1:(NProd-1+NVar)*NSeg+NSeg-1)); siz=[siz; 1]; siz=siz/sum(siz); LLik=Lik*siz; f=-sum(log(LLik));
Computing Standard Errors %To get standard errors when we use transformed variables Nx=size(x,1) A=eye(Nx); A(Nx-1,Nx-1)=(exp(x(NSeg*(NProd+NVar-1)+1))* (1+exp(x(NSeg*(NProd+NVar1)+2))))/ ((1+exp(x(NSeg*(NProd+NVar-1)+1))+exp(x(NSeg*(NProd+NVar-1)+2))))^2; A(Nx,Nx)=(exp(x(NSeg*(NProd+NVar-1)+2))* (1+exp(x(NSeg*(NProd+NVar-1)+1))))/ ((1+exp(x(NSeg*(NProd+NVar-1)+1))+exp(x(NSeg*(NProd+NVar-1)+2))))^2; se=sqrt(diag(A*inv(hessian)*A'));
Exercise Estimate the model with only preference heterogeneity Estimate the optimal number of segments using the AIC or BIC criterion. Report the estimates and standard errors Estimate the model with both preference and response heterogeneity as in the code
Using Aggregate Data to Estimate Random Coefficients Logit Model Several Issues Simulation to integrate over random coefficients distribution Drawing from a multivariate distribution Endogeneity Use of IV Estimation Linearization of the mean utility to facilitate IV by using contraction mapping Generalized Method of Moments Two part approach to estimate linear and nonlinear parameters
Drawing multivariate normals w1=randn(NObs1,NCons); w2=randn(NObs1,NCons); aw1=b(1)*w1+b(2)*w2; aw2=b(3)*w1;
Contraction Mapping; Simulation based Integration while (k >= km) de=de1; sh=zeros(NObs1,1); psh=zeros(NObs1,1); 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; sh=sh/NCons; de1=de+log(s)-log(sh); k=max(abs(de1-de));
Analytically estimating the linear parameters; Optimizing over nonlinear parameters blin=inv(xlin'*z*W*z'*xlin)*(xlin'*z*W*z'*d); er=d-xlin*blin; f=er'*z*W*z'*er;
Exercise Compute the standard errors for the estimates in the code using approach suggested in Greene Optional Exercise: Add a supply side equation assuming Bertrand pricing by the two firms