Dear All
I would really appreciate some help on this. I am using Stata 13. I need to run quaids model manually using nlsur for a four good model to estimate income and price elasticity. Following is how I ran my codes to estimate QUAIDS model, compute expenditure elasticities from it and own price elasticity for good1. The expenditure elasiticities matches exactly with the outputs when using POI’s built-in quaids suite, but the own price elasticity does not (slight mismatch on second decimal figure). Can anyone help me with this? Thanks a lot.
Sami
#delimit;
* lnexptot= ln of total expenditure on the four goods;
*lnprice= ln of prices;
*w = expenditure shares;
scalar a_0 = 5;
nlsur quaids @ w1 w2 w3 lnprice1-lnprice4 lnexptot, ifgnls nequations(3) param(a1 a2 a3 b1 b2 b3 g11 g12 g13 g22 g23 g33 l1 l2 l3) nolog;
matrix B = e(b)';
matrix list B;
nlcom (a1:_b[/a1]) (a2:_b[/a2]) (a3:_b[/a3])
(a4:1-_b[/a1]-_b[/a2]-_b[/a3])
(b1:_b[/b1]) (b2:_b[/b2]) (b3:_b[/b3])
(b4:-_b[/b1]-_b[/b2]-_b[/b3])
(g11:_b[/g11]) (g12:_b[/g12]) (g13:_b[/g13])
(g14:-_b[/g11]-_b[/g12]-_b[/g13])
(g22:_b[/g22]) (g23:_b[/g23])
(g24:-_b[/g12]-_b[/g22]-_b[/g23])
(g33:_b[/g33]) (g34:-_b[/g13]-_b[/g23]-_b[/g33])
(g44:-(_b[/g11]-_b[/g12]-_b[/g13]) -
(_b[/g12]-_b[/g22]-_b[/g23]) -
(_b[/g13]-_b[/g23]-_b[/g33]))
(l1:_b[/l1]) (l2:_b[/l2]) (l3:_b[/l3])
(l4:-_b[/l1]-_b[/l2]-_b[/l3]);
/* Scalars for parameter estimates */;
scalar a1 = _b[/a1];
scalar a2 = _b[/a2];
scalar a3 = _b[/a3];
scalar a4 = 1 - a1 - a2 - a3;
scalar b1 = _b[/b1];
scalar b2 = _b[/b2];
scalar b3 = _b[/b3];
scalar b4 = 0 - b1 - b2 - b3;
scalar g11 = _b[/g11];
scalar g12 = _b[/g12];
scalar g13 = _b[/g13];
scalar g14 = 0 - (g11 + g12 + g13);
scalar g21 = g12;
scalar g22 = _b[/g22];
scalar g23 = _b[/g23];
scalar g24 = 0 - (g12 + g22 + g23);
scalar g31 = g13;
scalar g32 = g23;
scalar g33 = _b[/g33];
scalar g34 = 0 - (g13 + g23 + g33);
scalar g41 = g14;
scalar g42 = g24;
scalar g43 = g34;
scalar g44 = 0 - (g14 + g24 + g34);
scalar l1 = _b[/l1];
scalar l2 = _b[/l2];
scalar l3 = _b[/l3];
scalar l4 = 0 - (l1 + l2 + l3);
predict eshare*
/* This produces the same estimates tan those obtained by running the
aforementioned quaids command */;
* FOR ELASTICITIES;
* Preliminaries;
gen lnb = b1*lnprice1 + b2*lnprice2 + b3*lnprice3 + b4*lnprice4;
gen bindex = exp(lnb);
gen lna = a_0 + a1*lnprice1 + a2*lnprice2 + a3*lnprice3 + a4*lnprice4 +
(1/2)*(g11*lnprice1*lnprice1 + g12*lnprice1*lnprice2 + g13*lnprice1*lnprice3 + g14*lnprice1*lnprice4 +
g21*lnprice2*lnprice1 + g22*lnprice2*lnprice2 + g23*lnprice2*lnprice3 + g24*lnprice2*lnprice4 +
g31*lnprice3*lnprice1 + g32*lnprice3*lnprice2 + g33*lnprice3*lnprice3 + g34*lnprice3*lnprice4 +
g41*lnprice4*lnprice1 + g42*lnprice4*lnprice2 + g43*lnprice4*lnprice3 + g44*lnprice4*lnprice4);
gen aindex = exp(lna);
/* INCOME ELASTICITIES */
gen mu1 = b1 + ((l1*2)/bindex)*(lnexptot - lna);
gen mu2 = b2 +((l2*2)/bindex)*(lnexptot - lna);
gen mu3 = b3 + ((l3*2)/bindex)*(lnexptot - lna);
gen mu4 = b4 + ((l4*2)/bindex)*(lnexptot - lna);
gen em1 = (mu1/w1) + 1;
gen em2 = (mu2/w2) + 1;
gen em3 = (mu3/w3) + 1;
gen em4 = (mu4/w4) + 1;
sum em*;
*calculating own price elasticity for "good 1";
gen muu1=((l1*b1)/bindex)*(lnexptot - lna)^2;
gen mm1=a1+(g23*lnprice2)+(g33*lnprice3);
gen pe1= g11-((b1+mu1)*mm1)-muu1;
gen ope1=-1+(pe1/w1);
sum ope1;
#delimit cr
exit
I would really appreciate some help on this. I am using Stata 13. I need to run quaids model manually using nlsur for a four good model to estimate income and price elasticity. Following is how I ran my codes to estimate QUAIDS model, compute expenditure elasticities from it and own price elasticity for good1. The expenditure elasiticities matches exactly with the outputs when using POI’s built-in quaids suite, but the own price elasticity does not (slight mismatch on second decimal figure). Can anyone help me with this? Thanks a lot.
Sami
#delimit;
* lnexptot= ln of total expenditure on the four goods;
*lnprice= ln of prices;
*w = expenditure shares;
scalar a_0 = 5;
nlsur quaids @ w1 w2 w3 lnprice1-lnprice4 lnexptot, ifgnls nequations(3) param(a1 a2 a3 b1 b2 b3 g11 g12 g13 g22 g23 g33 l1 l2 l3) nolog;
matrix B = e(b)';
matrix list B;
nlcom (a1:_b[/a1]) (a2:_b[/a2]) (a3:_b[/a3])
(a4:1-_b[/a1]-_b[/a2]-_b[/a3])
(b1:_b[/b1]) (b2:_b[/b2]) (b3:_b[/b3])
(b4:-_b[/b1]-_b[/b2]-_b[/b3])
(g11:_b[/g11]) (g12:_b[/g12]) (g13:_b[/g13])
(g14:-_b[/g11]-_b[/g12]-_b[/g13])
(g22:_b[/g22]) (g23:_b[/g23])
(g24:-_b[/g12]-_b[/g22]-_b[/g23])
(g33:_b[/g33]) (g34:-_b[/g13]-_b[/g23]-_b[/g33])
(g44:-(_b[/g11]-_b[/g12]-_b[/g13]) -
(_b[/g12]-_b[/g22]-_b[/g23]) -
(_b[/g13]-_b[/g23]-_b[/g33]))
(l1:_b[/l1]) (l2:_b[/l2]) (l3:_b[/l3])
(l4:-_b[/l1]-_b[/l2]-_b[/l3]);
/* Scalars for parameter estimates */;
scalar a1 = _b[/a1];
scalar a2 = _b[/a2];
scalar a3 = _b[/a3];
scalar a4 = 1 - a1 - a2 - a3;
scalar b1 = _b[/b1];
scalar b2 = _b[/b2];
scalar b3 = _b[/b3];
scalar b4 = 0 - b1 - b2 - b3;
scalar g11 = _b[/g11];
scalar g12 = _b[/g12];
scalar g13 = _b[/g13];
scalar g14 = 0 - (g11 + g12 + g13);
scalar g21 = g12;
scalar g22 = _b[/g22];
scalar g23 = _b[/g23];
scalar g24 = 0 - (g12 + g22 + g23);
scalar g31 = g13;
scalar g32 = g23;
scalar g33 = _b[/g33];
scalar g34 = 0 - (g13 + g23 + g33);
scalar g41 = g14;
scalar g42 = g24;
scalar g43 = g34;
scalar g44 = 0 - (g14 + g24 + g34);
scalar l1 = _b[/l1];
scalar l2 = _b[/l2];
scalar l3 = _b[/l3];
scalar l4 = 0 - (l1 + l2 + l3);
predict eshare*
/* This produces the same estimates tan those obtained by running the
aforementioned quaids command */;
* FOR ELASTICITIES;
* Preliminaries;
gen lnb = b1*lnprice1 + b2*lnprice2 + b3*lnprice3 + b4*lnprice4;
gen bindex = exp(lnb);
gen lna = a_0 + a1*lnprice1 + a2*lnprice2 + a3*lnprice3 + a4*lnprice4 +
(1/2)*(g11*lnprice1*lnprice1 + g12*lnprice1*lnprice2 + g13*lnprice1*lnprice3 + g14*lnprice1*lnprice4 +
g21*lnprice2*lnprice1 + g22*lnprice2*lnprice2 + g23*lnprice2*lnprice3 + g24*lnprice2*lnprice4 +
g31*lnprice3*lnprice1 + g32*lnprice3*lnprice2 + g33*lnprice3*lnprice3 + g34*lnprice3*lnprice4 +
g41*lnprice4*lnprice1 + g42*lnprice4*lnprice2 + g43*lnprice4*lnprice3 + g44*lnprice4*lnprice4);
gen aindex = exp(lna);
/* INCOME ELASTICITIES */
gen mu1 = b1 + ((l1*2)/bindex)*(lnexptot - lna);
gen mu2 = b2 +((l2*2)/bindex)*(lnexptot - lna);
gen mu3 = b3 + ((l3*2)/bindex)*(lnexptot - lna);
gen mu4 = b4 + ((l4*2)/bindex)*(lnexptot - lna);
gen em1 = (mu1/w1) + 1;
gen em2 = (mu2/w2) + 1;
gen em3 = (mu3/w3) + 1;
gen em4 = (mu4/w4) + 1;
sum em*;
*calculating own price elasticity for "good 1";
gen muu1=((l1*b1)/bindex)*(lnexptot - lna)^2;
gen mm1=a1+(g23*lnprice2)+(g33*lnprice3);
gen pe1= g11-((b1+mu1)*mm1)-muu1;
gen ope1=-1+(pe1/w1);
sum ope1;
#delimit cr
exit
Comment