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]

Re: st: problem with nlsur quaids


From   Jorge Eduardo Pérez Pérez <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: problem with nlsur quaids
Date   Tue, 4 Oct 2011 15:02:42 -0400

You have to write your own code to calculate the elasticities. You can
calculate them for mean values of expenditure and use -nlcom- to get
their standard errors after estimating the system via nlsur.
Alternatively, you can calculate elasticities for each household using
-predictnl-
This is a quick example of the first approach on a 7 good system.
First I define mean price indexes and additional variables such as the
sums of a and g, then i calculate the elasticities. "lgastotal" is log
total expenditure, "lprecio" is log price, "elasgasto" is expenditure
elasticity.
----
* Share means and price means
quietly {
foreach x of varlist share* lprecio* lgastototal {
sum `x'
scalar `x'mean=r(mean)
}
* Price indexes
glo asum "_b[a1]*lprecio1mean"
forv i=2(1)7 {
glo asum "${asum} + _b[a`i']*lprecio`i'mean"
}
glo gsum ""
forv i=1(1)7 {
forv j=1(1)7 {
glo gsum "${gsum} + 0.5*_b[g`i'`j']*lprecio`i'mean*lprecio`j'mean"
}
}
glo ap "4.7 + ${asum} ${gsum}"
glo bp "_b[b1]*lprecio1mean"
forv i=2(1)7 {
glo bp "${bp} + _b[b`i']*lprecio`i'mean"
}
glo bp "(exp(${bp}))"
* Mus
forv i=1(1)7 {
glo mu`i' "_b[b`i'] + 2*_b[l`i']/${bp}*(lgastototalmean-(${ap}))"
}
forv j=1(1)7 {
glo gsum2`j' ""
forv k=1(1)7 {
glo gsum2`j' "${gsum2`j'} + _b[g`j'`k']*lprecio`k'mean"
}
}
}
forv i=1(1)7 {
forv j=1(1)7 {
glo delta=cond(`i'==`j',1,0)
glo mu`i'`j' "_b[g`i'`j'] - ${mu`i'}*(_b[a`j'] ${gsum2`j'})
-_b[l`i']*_b[b`j']/${bp}*(lgastototalmean - (${ap}))^2"
* If expression is too long, split it
cap nlcom (elasgasto`i': ${mu`i'}/share`i'mean + 1) (mu`i'`j':
${mu`i'`j'}), post noheader
if _rc {
qui nlcom (elasgasto`i': ${mu`i'}/share`i'mean + 1) (mu`i'`j'f:
(1e+2)*(${mu`i'`j'})), post noheader
qui nlcom (elasgasto`i': _b[elasgasto`i']) (mu`i'`j':
_b[mu`i'`j'f]/(1e+2)), post noheader
}
* Uncompensated price elasticity
nlcom (elasgasto`i': _b[elasgasto`i']) (elpnc`i'`j':
_b[mu`i'`j']/share`i'mean - ${delta})  , post noheader
* Compensated price elasticity
nlcom (elpc`i'`j': _b[elpnc`i'`j'] + _b[elasgasto`i']*share`j'mean), noheader
qui est restore quaidsc
}
}

As for the elasticity for each household, you can use code similar to
this inside a loop over equations after defining mu:

predictnl elasgasto`i'= (${mu`i'})/share`i' + 1 , se(seelasgasto`i')


Hope this helps,
_______________________
Jorge Eduardo Pérez Pérez



On Tue, Oct 4, 2011 at 11:01 AM, Nick Cox <[email protected]> wrote:
>
> Nothing from me on elasticities.
>
> Nick
> [email protected]
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Mintewab Bezabih
> Sent: 04 October 2011 15:56
> To: [email protected]
> Subject: SV: st: problem with nlsur quaids
>
> Thanks so much Nick. I folowed your tips and managed to run it now. My next problem is how to generate the elasticities. I presume I have to write my own code for that... do you or anybodyelse in the forum have any suggestions on that?
>
> thanks once again
> minti
>
> ________________________________________
> Från: [email protected] [[email protected]] f&#246;r Nick Cox [[email protected]]
> Skickat: den 2 oktober 2011 02:39
> Till: [email protected]
> Ämne: Re: st: problem with nlsur quaids
>
> `lnp12'' with two '' occurs twice more.
>
> In a text editor supporting regular expressions I temporarily deleted
> matches for  `[a-z]*[0-9]*'  -- which made it easier to find these
> others.
>
> On Sun, Oct 2, 2011 at 1:16 AM, Nick Cox <[email protected]> wrote:
> > In the line
> >
> >     scalar `l13' = -`l1' - `l2' - `l3'- `l4'- `l5'- `l6'- `l7'- `l8'-
> > `l9'- `l10'- `l11-`l12'
> >
> > you have omitted an ' and in the line
> >
> >                 replace `w9' = `a9' + `g91'*`lnp1' + `g92'*`lnp2' +
> > `g93'*`lnp3' +   ///
> >                               `g94'*`lnp4' + `g95'*`lnp5'+
> > `g96'*`lnp6'+ `g97'*`lnp7' + ///
> >                               `g98'*`lnp8' + `g99'*`lnp9'+
> > `g910'*`lnp10'+ `g911'*`lnp11' + ///
> >                               `g912'*`lnp12''+ `g913'*`lnp13'+
> > `b9'*(`lnexp'-`lnpindex')+
> > `l9'/`bofp'*(`lnexp' - `lnpindex')^2
> >
> > you have one too many.
> >
> > There are I think other such problems in your file: see -hexdump- for
> > a command that counts characters such as ` and '.
> >
> > Your naming practices could bite you. Does 113 mean 11,3 or 1,13? If
> > you have indexes >9 it is best to use 11_3 and 1_13 to distinguish.
> >
> > Nick
> >
> >
> > On Sat, Oct 1, 2011 at 10:23 PM, minti <[email protected]> wrote:
> >>
> >> I am having problems estimating a quaids system with 13 goods (12 equations)
> >> and I cannot pinpoint where I went wrong. I keep on getting the messsage
> >> nlsurquaids returned 198. Below are my codes for the nlsur and quaids.
> >> Many thanks in advance.
> >> minti
> >>
> >
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>


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


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