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: RE: Problem with nlsur/QUAIDS


From   Aepli Matteo <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: Problem with nlsur/QUAIDS
Date   Wed, 7 Aug 2013 12:47:39 +0000

Dear STATA users,

I just found the problem. Two + were missing.
Thanks anyway :-)

Kind regards,

Matteo

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Aepli Matteo
Sent: Wednesday, August 07, 2013 11:31 AM
To: '[email protected]'
Subject: st: Problem with nlsur/QUAIDS

Dear STATA users,

I'm trying to estimate a QUAIDS (without demographic variables). 
STATA always returns:

nlsurquaids returned 198
verify that nlsurquaids is a function evaluator program

After verifying several times my code I'm not able to find the problem.

Could anybody help me?

Sincerely,

MA



*QUAIDS for 5 goods
capture program drop nlsurquaids
program nlsurquaids 

        version 12.1 
        
        syntax varlist(min=10 max=10) if, at(name) 
        tokenize `varlist' 
        args w1 w2 w3 w4 lnp1 lnp2 lnp3 lnp4 lnp5 lnexp 



       tempname a1 a2 a3 a4 a5 
        scalar `a1' = `at'[1,1] 
        scalar `a2' = `at'[1,2] 
        scalar `a3' = `at'[1,3] 
        scalar `a4' = `at'[1,4] 
        scalar `a5' = 1 - `a1' - `a2' - `a3' - `a4'        
         

        tempname b1 b2 b3 b4 b5 
        scalar `b1' = `at'[1,5] 
        scalar `b2' = `at'[1,6] 
        scalar `b3' = `at'[1,7] 
        scalar `b4' = `at'[1,8] 
        scalar `b5' = - `b1' - `b2' - `b3' - `b4'                
         
       
                    tempname g11 g12 g13 g14 g15    
        tempname g21 g22 g23 g24 g25 
        tempname g31 g32 g33 g34 g35 
        tempname g41 g42 g43 g44 g45 
        tempname g51 g52 g53 g54 g55 


        scalar `g11' = `at'[1,9] 
        scalar `g12' = `at'[1,10] 
        scalar `g13' = `at'[1,11] 
        scalar `g14' = `at'[1,12] 
        scalar `g15' = - `g11' - `g12' - `g13' - `g14'                
       

        scalar `g21' = `g12' 
        scalar `g22' = `at'[1,13] 
        scalar `g23' = `at'[1,14] 
        scalar `g24' = `at'[1,15] 
        scalar `g25' = - `g21' - `g22' - `g23' - `g24'
              
       
        scalar `g31' = `g13' 
        scalar `g32' = `g23' 
        scalar `g33' = `at'[1,16] 
        scalar `g34' = `at'[1,17] 
        scalar `g35' = - `g31' - `g32' - `g33' - `g34'                
         

        scalar `g41' = `g14' 
        scalar `g42' = `g24' 
        scalar `g43' = `g34' 
        scalar `g44' = `at'[1,18] 
        scalar `g45' = - `g41' - `g42' - `g43' - `g44' 
 

        scalar `g51' = `g15' 
        scalar `g52' = `g25' 
        scalar `g53' = `g35' 
        scalar `g54' = `g45' 
        scalar `g55' = - `g51' - `g52' - `g53' - `g54'  
               
       
        tempname l1 l2 l3 l4 l5 
        scalar `l1' = `at'[1,19] 
        scalar `l2' = `at'[1,20] 
        scalar `l3' = `at'[1,21] 
        scalar `l4' = `at'[1,22] 
        scalar `l5' = - `l1' - `l2' - `l3' - `l4'                            
    


        quietly { 
                *price index 
                *I set a_0 = 5 
                tempvar lnpindex 
                gen double `lnpindex' = 5 + `a1'*`lnp1' + `a2'*`lnp2' + `a3'*`lnp3' + `a4'*`lnp4' + `a5'*`lnp5'                    
             

            forvalues i = 1/5 { 
                        forvalues j = 1/5 { 
                                replace `lnpindex' = `lnpindex' + /// 
                                        0.5*`g`i'`j''*`lnp`i''*`lnp`j'' 
                        } 
                } 
                *b(p) term in the QUAIDS model: 
                tempvar bofp 
                gen double `bofp' = 0 
                forvalues i = 1/5 { 
                        replace `bofp' = `bofp' + `lnp`i''*`b`i'' 
                } 
                replace `bofp' = exp(`bofp') 
                


*the expenditure shares for 4 of the 5 goods 
                
                                                                
                replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' + `g14'*`lnp4' + `g15'*`lnp5'                  ///
                               +  `b1'*(`lnexp' - `lnpindex') + `l1'/`bofp'*(`lnexp' - `lnpindex')^2                          
     

            replace `w2' = `a2' + `g21'*`lnp1' + `g22'*`lnp2' + `g23'*`lnp3' + `g24'*`lnp4' + `g25'*`lnp5'                  ///
                + `b2'*(`lnexp' - `lnpindex') + `l2'/`bofp'*(`lnexp' - `lnpindex')^2                      
             


            replace `w3' = `a3' + `g31'*`lnp1' + `g32'*`lnp2' + `g33'*`lnp3' + `g34'*`lnp4' + `g35'*`lnp5'                  ///
                 `b3'*(`lnexp' - `lnpindex') + `l3'/`bofp'*(`lnexp' - `lnpindex')^2
             

            replace `w4' = `a4' + `g41'*`lnp1' + `g42'*`lnp2' + `g43'*`lnp3' + `g44'*`lnp4' + `g45'*`lnp5'                  ///
                `b4'*(`lnexp' - `lnpindex') + `l4'/`bofp'*(`lnexp' - `lnpindex')^2
               
            
} 
        
end 

nlsur quaids @ w1 w2 w3 w4 lnp1 lnp2 lnp3 lnp4 lnp5 lnexp, ifgnls nequations(4) param(a1 a2 a3 a4 b1 b2 b3 b4 g11 g12 g13 g14 g22 g23 g24 g33 g34 g44 l1 l2 l3 l4) 







*
*   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/

*
*   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