Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Code-problem - calculating demand elasticities with a QUAIDS


From   <[email protected]>
To   <[email protected]>
Subject   st: Code-problem - calculating demand elasticities with a QUAIDS
Date   Fri, 22 Nov 2013 12:25:50 +0000

Dear Statalist-Users

I am trying to calculate budget and price elasticities for four meat products with a QUAIDS-model (using Swiss household data) (according to the method of Banks 1997 "Quadratic Engel Curves and Consumer Demand") and I have a problem with my code.

This is (part of) the code I am using:

quietly {
foreach x of varlist w* lnp* lnx1_4 {
sum `x'
scalar `x'mean=r(mean)
}

* Price indexes
global asum "_b[a1] * lnp1mean"
forv i=2(1)4 {
global asum "${asum} + _b[a`i'] * lnp`i'mean"
}
global gsum ""
forv i=1(1)4 {
forv j=1(1)4 {
global gsum "${gsum} + 0.5 * _b[g`i'_`j'] * lnp`i'mean * lnp`j'mean"
}
}
global lnaofp "5 + ${asum} ${gsum}" /* price index: ln a(p)*/

global bofp "lnp1mean*_b[b1]"
forv i=2(1)4 {
global bofp "${bofp} + lnp`i'mean*_b[b`i']" 
}
global bofp "(exp(${bofp}))" /* Cobb-Douglas price aggregator b(p) */

* My's (i: delta budget share/delta ln-expenditure and ij: delta budget sh./delta ln-price)
forv i=1(1)4 {
global my`i' "_b[b`i'] + ((2*_b[l`i'])/${bofp})*(lnx1_4mean - (${lnaofp}))"
}
forv j=1(1)4 {
global gsum2`j' ""
forv k=1(1)4 {
global gsum2`j' "${gsum2`j'} + _b[g`j'_`k'] * lnp`k'mean"
}
}

forv i=1(1)4 {
forv j=1(1)4 {
global delta=cond(`i'==`j',1,0) /* Kronecker delta */
global my`i'_`j' "_b[g`i'_`j'] - ${my`i'}*(_b[a`j']${gsum2`j'}) - ((_b[l`i']*_b[b`j'])/${bofp})*((lnx1_4mean - ${lnaofp})^2)"
*}
*}

capture nlcom (elx`i': ${my`i'}/ w`i'mean + 1) (my`i'_`j':  ${my`i'_`j'}), post noheader
if _rc { 
qui nlcom (elx`i': ${my`i'} / w`i'mean + 1) (my`i'_`j'f: (1e+2)*(${my`i'_`j'})), post noheader                
qui nlcom (elx`i': _b[elx`i']) (my`i'_`j':  _b[my`i'_`j'f]/(1e+2)), post noheader
}
}
}

* Uncompensated price elasticity
nlcom (elx`i': _b[elx`i'])   (elu`i'_`j': _b[my`i'_`j']/ w`i'mean - ${delta}), post noheader
* Compensated price elasticity
nlcom (elc`i'_`j': _b[elu`i'_`j'] + _b[elx`i']* w`j'mean), noheader
qui est restore quaidsc

}
end

The problem seems to be in the "capture nlcom (elx`i': ${my`i'}/ w`i'mean + 1) ."-line (not sure), because Stata gives me the result:

. do ""

. nlcom (elx`i': ${my`i'}/ w`i'mean + 1) (my`i'_`j':  ${my`i'_`j'}), post noheader
/wmean invalid name
r(198);

end of do-file

r(198);

I don't know, why it does not use the means of w1 to w4 (w1mean to w4mean) (w=budget share).

It would be also interesting for me to know if there is another possibility to write the code for the calculation of "elx`i'".

Thanks a lot,
Franziska


Franziska Götze, M. Sc.
Doktorandin

Eidgenössisches Departement für
Wirtschaft, Bildung und Forschung WBF
Forschungsanstalt Agroscope Reckenholz-Tänikon ART
Sozioökonomie

Tänikon, CH-8356 Ettenhausen
Tel. +41 52 36 83225
Fax +41 52 36 51190
[email protected]
www.agroscope.ch


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index