BLP type Random Coefficients Logit Model
1 view (last 30 days)
Show older comments
I am working on a project- where I interact my price with a policy dummy zero- one, i.e. Policy_Var= price*policy_dum. So, the variable of interest is not price (I don't have price in the mean utility but price interaction with a zero-one dummy), but it is Policy_Var.
I have a question for you: in calculating elasticities of the RCM model- I know I need to subtract the price effect from mean utility. Since I have Policy_var=price*policy_dum, I need to subtract price and policy_dum from my mean utility- then calculate the mu and individual price sensitivity, alphai's.
I am puzzled about the fact that how can I add these two effects back into my mean utility and re-calculate its exponential? How can I add policy_var back into the mean utility?
I would appreciate your help very much.
global ns cdid cdindex x1 x2 schoolid theti thetj v
load ps2
load delta
load theta_final
load schoolid
ns = 300;
%constant, income, sex, race, momedu, dadedu
theta2w= [ -0.0080 0 0 0 0 0 ; %constant
-0.0023 -0.0153 0 -0.1505 0 0 ]; %Policy_Var
[theti, thetj, theta2]=find(theta2w);
%mval = meanval(theta2); %mean utility levels%
mval = delta; %mean utility levels%
theta2w = full(sparse(theti,thetj,theta2));
policy_price = x1(:,4); %price*LSD
policy_var =x1(:,2); %LSD=1
[n k] = size(x2);
j = size(theta2w,2)-1;
c_pre = schoolid;
load v
%compute the exp of everything but the price effects (will be used below)
mvall = mval - policy_price*theta1(4)-policy_var*theta1(2);
%mvall = mval - policy_cdr2*theta1(4);
mu = zeros(n,ns);
for i = 1:ns
vfull1 = v(cdid,i:ns:k*ns);
vfull1 = vfull1(:,[1 3:k]);
dfull1 = demogr(cdid,i:ns:j*ns);
mu(:,i) = (x2(:,[1 3:k]).*vfull1*theta2w([1 3:k],1))+x2(:,[1 3:k]).*(dfull1*theta2w([1 3:k],2:j+1)')*ones(k-1,1);
%mu(:,i) = (x2(:,[1 3:k]).*vfull1*theta2w([1 3:k],1)); % this eliminates demographic variables
end
expall = exp(mu + kron(ones(1,ns),mvall));
%clear mu vfull1 dfull1
%compute individual price sensitivity, alphai (will be used below)
v_long = reshape(v(:,ns+1:2*ns)',size(cdindex,1)*ns,1);
%clear v
%compute individual price sensitivity, alphai (will be used below)
v_long = reshape(v(:,ns+1:2*ns)',size(cdindex,1)*ns,1);
for i=1:j %this is the case with demographic variables
d_long(:,i) = reshape(demogr(:,(i-1)*ns+1:i*ns)',size(cdindex,1)*ns,1);
end %this is the case with demographic variables
%Case when alphai is the coefficeint on price plus the nonlinear random taste component of utility
alphai = theta1(4) + theta1(2)+ [v_long d_long]*theta2w(2,:)' ; %Keep this like that.WHY? Not so sure?
alphai = reshape(alphai,ns,size(cdindex,1))';
%%%%%%%
%Question: How to add back policy_price and policy_var back here?
eg = expall.*exp(policy_price*ones(1,ns).*(alphai(cdid,:))); %How to add back policy_var here?
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!