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: nlsuraids need help with AIDS model error please


From   "Brian P. Poi" <[email protected]>
To   [email protected]
Subject   Re: st: nlsuraids need help with AIDS model error please
Date   Wed, 11 Jul 2012 08:50:33 -0500

On 07/11/2012 04:31 AM, Liu, Pei Chun wrote:
Thank you so much Brian. It's working like a charm now!!! If I may ask another question, is the below code right if I want to calculate the AIDS with stone price index instead of translog price index?

#delimit ;
program nlsuraidstones;
         version 11.2;

   syntax varlist(min=6 max=6) if , at(name);
         tokenize `varlist';
         args w1 w2 lnp1 lnp2 lnp3 lnm;
         tempname a1 a2 a3;
         scalar `a1' = `at'[1,1];
         scalar `a2' = `at'[1,2];
         scalar `a3' = 1 - `a1' - `a2';

         tempname b1 b2;
         scalar `b1' = `at'[1,3];
         scalar `b2' = `at'[1,4];

         tempname g11 g12 g13;
         tempname g21 g22 g23;
         tempname g31 g32 g33;

         scalar `g11' = `at'[1,5];
         scalar `g12' = `at'[1,6];
         scalar `g13' =-`g11'-`g12';


         scalar `g21' = `g12';
         scalar `g22' = `at'[1,7];
         scalar `g23' = -`g21'-`g22';


         scalar `g31' = `g13';
         scalar `g32' = `g23';
         scalar `g33' = -`g13'-`g23';

          quietly {;
                 tempvar lnpindex;
                 gen double `lnpindex' = w1*`lnp1' + w2*`lnp2' +
                                         w3*`lnp3';

                 replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' +
                         `g13'*`lnp3'+ `b1'*(`lnm' - `lnpindex');
                 replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' +
                         `g23'*`lnp3'+ `b2'*(`lnm' - `lnpindex');
         };
end;
nlsur aidstones @ w1 w2 lnp1 lnp2 lnp3 lnm, parameters(a1 a2 b1 b2 g11 g12 g22) neq(2) ifgnls;

Pei



Pei,

Your program will work fine for computing the "LA/AIDS" model with Stone's price index.

Notice that Stone's price index doesn't depend on the model parameters, so you could generate a new variable containing the price index before you even call -nlsur-.  Then inside your program you wouldn't need to keep recreating the temporary `lnpindex' variable.  Also, by using Stone's price index, the equations are in fact linear, so you could in principle use -sureg- instead of -nlsur-.  But, like I said, your program will work fine as it is written, so I wouldn't bother changing things up.

   -- Brian Poi
   -- [email protected]
*
*   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