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: Separability Restrictions Nlsur Quaids


From   Guilherme Travassos <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Separability Restrictions Nlsur Quaids
Date   Fri, 8 Nov 2013 15:59:20 +0000

Jorge Perez, thank you for your reply.

- I checked my independent variables and I don't have missing values on that. Using Brian Poi code, I already have the irrestrict model, so I think that teh problem isn't on the variables but on the restrict model code.

- I understand when you sad about change the initial values such that they imply that the initial `a3' + `b3' and `a5' + `b5' are not zero, but I don't know how to do this on Brian's code. Can you help me?

- I need to estimating the restrict model. I intend to use the Likelihood Ratio Test to test the weak separability restrictions on the restrict model against de irrestric model. The literature recommend it. Like I sad, I already have the irrestrict model.

- I didn't know the Brian Poi's recent quaids - command. Could you show me?

Anyway, I am sending my code with the specific restrictions. Maybe it could help.


program nlsurquaids

version 10

syntax varlist(min=33 max=33) if, at(name)
tokenize `varlist'

args w1 w2 w3 w4 w5 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnexp lnpindex urban norte nordeste sudeste centro_oeste anosestudo mulherchefe crian_adolesc idoso lnMr_est fe1 fe2 fe3 fe4 fe5 F1 F2 F3 F4 F5


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


tempname b1 b2 b3 b4 b5 b6 					
					
scalar `b1'	= `at'[1, 6]
scalar `b2'	= `at'[1, 7]
scalar `b3'	= `at'[1, 8]
scalar `b4'	= `at'[1, 9]
scalar `b5'	= `at'[1, 10]
scalar `b6'	= - `b1' - `b2' - `b3' - `b4' - `b5'


tempname g11 g12 g13 g14 g15 g16

tempname g21 g22 g23 g24 g25 g26

tempname g31 g32 g33 g34 g35 g36

tempname g41 g42 g43 g44 g45 g46

tempname g51 g52 g53 g54 g55 g56 

tempname g61 g62 g63 g64 g65 g66


scalar `g11' = `at'[1, 11]	
scalar `g12' = `at'[1, 12]	
scalar `g13' = `at'[1, 13]	
scalar `g14' = `at'[1, 14]	
scalar `g15' = `at'[1, 15]	
scalar `g16' = - `g11' - `g12' - `g13' - `g14' - `g15'


scalar `g21' = `g12'					
scalar `g22' = `at'[1, 16]
scalar `g23' = `at'[1, 17]
scalar `g24' = `at'[1, 18]
scalar `g25' = `at'[1, 19]
scalar `g26' = - `g21' - `g22' - `g23' - `g24' - `g25'


scalar `g31' = `g13'
scalar `g32' = `g23'					
scalar `g33' = `at'[1, 20]	
scalar `g34' = `at'[1, 21]	
scalar `g35' = `at'[1, 22]		
scalar `g36' = - `g31' - `g32' - `g33' - `g34' - `g35'


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


scalar `g51' = `g15'						
scalar `g52' = `g25'						
scalar `g53' = `g35'						
scalar `g54' = `g45'						
scalar `g55' = `at'[1, 25]		
scalar `g56' = - `g51' - `g52' - `g53' - `g54' - `g55'


scalar `g61' = `g16'						
scalar `g62' = `g26'						
scalar `g63' = `g36'						
scalar `g64' = `g46'						
scalar `g65' = `g56'							
scalar `g66' = - `g61' - `g62' - `g63' - `g64' - `g65'


tempname g14 g16

scalar `g14' = ((`a4' + `b4')/(`a3' + `b3'))*(`g13' + `a1'*`a3') - `a1'*`a4'	
scalar `g16' = ((`a6' + `b6')/(`a5' + `b5'))*(`g15' + `a1'*`a5') - `a1'*`a6'

tempname g24 g26

scalar `g24' = ((`a4' + `b4')/(`a3' + `b3'))*(`g23' + `a2'*`a3') - `a2'*`a4'
scalar `g26' = ((`a6' + `b6')/(`a5' + `b5'))*(`g25' + `a2'*`a5') - `a2'*`a6'

tempname g34 g36

scalar `g34' = ((`a4' + `b4')/(`a3' + `b3'))*(`g33' + `a3'*`a3') - `a3'*`a4'			
scalar `g36' = ((`a6' + `b6')/(`a5' + `b5'))*(`g35' + `a3'*`a5') - `a3'*`a6'

tempname g44 g46

scalar `g44' = ((`a4' + `b4')/(`a3' + `b3'))*(`g43' + `a4'*`a3') - `a4'*`a4'
scalar `g46' = ((`a6' + `b6')/(`a5' + `b5'))*(`g45' + `a4'*`a5') - `a4'*`a6'

tempname g56

scalar `g56' = ((`a6' + `b6')/(`a5' + `b5'))*(`g55' + `a5'*`a5') - `a5'*`a6'


tempname l1 l2 l3 l4 l5 l6						
						
scalar `l1'	= `at'[1, 26]	
scalar `l2'	= `at'[1, 27]	
scalar `l3'	= `at'[1, 28]	
scalar `l4'	= `at'[1, 29]	
scalar `l5'	= `at'[1, 30]		
scalar `l6'	= - `l1' - `l2' - `l3' - `l4' - `l5'


tempname r11 r12 r13 r14 r15 r16 r17 r18 r19

tempname r21 r22 r23 r24 r25 r26 r27 r28 r29

tempname r31 r32 r33 r34 r35 r36 r37 r38 r39

tempname r41 r42 r43 r44 r45 r46 r47 r48 r49

tempname r51 r52 r53 r54 r55 r56 r57 r58 r59

scalar `r11' = `at'[1, 31]
scalar `r12' = `at'[1, 32]
scalar `r13' = `at'[1, 33]
scalar `r14' = `at'[1, 34]
scalar `r15' = `at'[1, 35]
scalar `r16' = `at'[1, 36]
scalar `r17' = `at'[1, 37]
scalar `r18' = `at'[1, 38]
scalar `r19' = `at'[1, 39]

scalar `r21' = `at'[1, 40]
scalar `r22' = `at'[1, 41]
scalar `r23' = `at'[1, 42]
scalar `r24' = `at'[1, 43]
scalar `r25' = `at'[1, 44]
scalar `r26' = `at'[1, 45]
scalar `r27' = `at'[1, 46]
scalar `r28' = `at'[1, 47]
scalar `r29' = `at'[1, 48]

scalar `r31' = `at'[1, 49]
scalar `r32' = `at'[1, 50]
scalar `r33' = `at'[1, 51]
scalar `r34' = `at'[1, 52]
scalar `r35' = `at'[1, 53]
scalar `r36' = `at'[1, 54]
scalar `r37' = `at'[1, 55]
scalar `r38' = `at'[1, 56]
scalar `r39' = `at'[1, 57]

scalar `r41' = `at'[1, 58]
scalar `r42' = `at'[1, 59]
scalar `r43' = `at'[1, 60]
scalar `r44' = `at'[1, 61]
scalar `r45' = `at'[1, 62]
scalar `r46' = `at'[1, 63]
scalar `r47' = `at'[1, 64]
scalar `r48' = `at'[1, 65]
scalar `r49' = `at'[1, 66]

scalar `r51' = `at'[1, 67]
scalar `r52' = `at'[1, 68]
scalar `r53' = `at'[1, 69]
scalar `r54' = `at'[1, 70]
scalar `r55' = `at'[1, 71]
scalar `r56' = `at'[1, 72]
scalar `r57' = `at'[1, 73]
scalar `r58' = `at'[1, 74]
scalar `r59' = `at'[1, 75]


tempname u1 u2 u3 u4 u5					
					
scalar `u1'	= `at'[1, 76]
scalar `u2'	= `at'[1, 77]
scalar `u3'	= `at'[1, 78]
scalar `u4'	= `at'[1, 79]
scalar `u5'	= `at'[1, 80]


tempname d1 d2 d3 d4 d5					
					
scalar `d1'	= `at'[1, 81]
scalar `d2'	= `at'[1, 82]
scalar `d3'	= `at'[1, 83]
scalar `d4'	= `at'[1, 84]
scalar `d5'	= `at'[1, 85]


	  
quietly {
        * The b(p) term in the QUAIDS model:
        tempvar bofp
        gen double `bofp' = 0
        forvalues i = 1/6 {
            replace `bofp' = `bofp' + `lnp`i''*`b`i''
        }
        replace `bofp' = exp(`bofp')
        // Finally, the expenditure shares for 5 of the 6
        // goods (the equation 6 is dropped to avoid singularity)
		
		
   replace `w1' = [`a1' + `g11'*`lnp1' + `g12'*`lnp2' +`g13'*`lnp3' + `g14'*`lnp4' + `g15'*`lnp5' + `g16'*`lnp6' + `b1'*(`lnexp' - `lnpindex') + `l1'/`bofp'*(`lnexp' - `lnpindex')^2 + `r11'*`urban' + `r12'*`norte' + `r13'*`nordeste' + `r14'*`sudeste' + `r15'*`centro_oeste' + `r16'*`anosestudo' + `r17'*`mulherchefe' + `r18'*`crian_adolesc' + `r19'*`idoso' + `u1'*`lnMr_est']*`F1' + `d1'*`fe1'   

   replace `w2' = [`a2' + `g21'*`lnp1' + `g22'*`lnp2' +`g23'*`lnp3' + `g24'*`lnp4' + `g25'*`lnp5' + `g26'*`lnp6' + `b2'*(`lnexp' - `lnpindex') + `l2'/`bofp'*(`lnexp' - `lnpindex')^2 + `r21'*`urban' + `r22'*`norte' + `r23'*`nordeste' + `r24'*`sudeste' + `r25'*`centro_oeste' + `r26'*`anosestudo' + `r27'*`mulherchefe' + `r28'*`crian_adolesc' + `r29'*`idoso' + `u2'*`lnMr_est']*`F2' + `d2'*`fe2'
   
   replace `w3' = [`a3' + `g31'*`lnp1' + `g32'*`lnp2' +`g33'*`lnp3' + `g34'*`lnp4' + `g35'*`lnp5' + `g36'*`lnp6' + `b3'*(`lnexp' - `lnpindex') + `l3'/`bofp'*(`lnexp' - `lnpindex')^2 + `r31'*`urban' + `r32'*`norte' + `r33'*`nordeste' + `r34'*`sudeste' + `r35'*`centro_oeste' + `r36'*`anosestudo' + `r37'*`mulherchefe' + `r38'*`crian_adolesc' + `r39'*`idoso' + `u3'*`lnMr_est']*`F3' + `d3'*`fe3'
   
   replace `w4' = [`a4' + `g41'*`lnp1' + `g42'*`lnp2' +`g43'*`lnp3' + `g44'*`lnp4' + `g45'*`lnp5' + `g46'*`lnp6' + `b4'*(`lnexp' - `lnpindex') + `l4'/`bofp'*(`lnexp' - `lnpindex')^2 + `r41'*`urban' + `r42'*`norte' + `r43'*`nordeste' + `r44'*`sudeste' + `r45'*`centro_oeste' + `r46'*`anosestudo' + `r47'*`mulherchefe' + `r48'*`crian_adolesc' + `r49'*`idoso' + `u4'*`lnMr_est']*`F4' + `d4'*`fe4'
   
   replace `w5' = [`a5' + `g51'*`lnp1' + `g52'*`lnp2' +`g53'*`lnp3' + `g54'*`lnp4' + `g55'*`lnp5' + `g56'*`lnp6' + `b5'*(`lnexp' - `lnpindex') + `l5'/`bofp'*(`lnexp' - `lnpindex')^2 + `r51'*`urban' + `r52'*`norte' + `r53'*`nordeste' + `r54'*`sudeste' + `r55'*`centro_oeste' + `r56'*`anosestudo' + `r57'*`mulherchefe' + `r58'*`crian_adolesc' + `r59'*`idoso' + `u5'*`lnMr_est']*`F5' + `d5'*`fe5'
   
}
end


nlsur quaids @ w1 w2 w3 w4 w5 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnexp lnpindex urban norte nordeste sudeste centro_oeste anosestudo mulherchefe crian_adolesc idoso lnMr_est fe1 fe2 fe3 fe4 fe5 F1 F2 F3 F4 F5, ifgnls nequations(5) param(a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 g11 g12 g13 g15 g22 g23 g25 g33 g35 g45 g55 l1 l2 l3 l4 l5 r11 r12 r13 r14 r15 r16 r17 r18 r19 r21 r22 r23 r24 r25 r26 r27 r28 r29 r31 r32 r33 r34 r35 r36 r37 r38 r39 r41 r42 r43 r44 r45 r46 r47 r48 r49 r51 r52 r53 r54 r55 r56 r57 r58 r59 u1 u2 u3 u4 u5 d1 d2 d3 d4 d5) nolog
     

Thank you again Jorge Perez and Statalisters.

Guilherme Travassos
----------------------------------------
> From: [email protected]
> Date: Thu, 7 Nov 2013 20:27:51 -0500
> Subject: Re: st: Separability Restrictions Nlsur Quaids
> To: [email protected]
>
> - Have you checked your independent variables for missing values? From
> the error message, that may be the problem.
> - If that is not the problem, change your initial values such that
> they imply that the initial `a3' + `b3' and `a5' + `b5' are not zero,
> since you are dividing by those terms.
> - If your purpose is only testing without actual estimation of the
> restricted model, keep in mind that you could just test the
> restrictions from the unrestricted model using -nlcom-
> - Is your estimation something you can not do using Brian Poi's recent
> -quaids- command?
>
> Hope this helps,
>
> Jorge Pérez.
>
>
>
>
> --------------------------------------------
> Jorge Eduardo Pérez Pérez
> Graduate Student
> Department of Economics
> Brown University
>
>
> On Thu, Nov 7, 2013 at 10:27 AM, Guilherme Travassos
> <[email protected]> wrote:
>> Dear Statalisters,
>>
>> I'm using nlsur Quaids from Brian Poi (2008) to estimate a six group demand system for meat products. But I want to test the system for weak separability too.
>>
>> My routine is:
>>
>> nlsur quaids @ w1 w2 w3 w4 w5 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnexp lnpindex urban norte nordeste sudeste centro_oeste anosestudo mulherchefe crian_adolesc idoso lnMr_est fe1 fe2 fe3 fe4 fe5 F1 F2 F3 F4 F5, ifgnls nequations(5) param(a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 g11 g12 g13 g14 g15 g22 g23 g24 g25 g33 g34 g35 g44 g45 g55 l1 l2 l3 l4 l5 r11 r12 r13 r14 r15 r16 r17 r18 r19 r21 r22 r23 r24 r25 r26 r27 r28 r29 r31 r32 r33 r34 r35 r36 r37 r38 r39 r41 r42 r43 r44 r45 r46 r47 r48 r49 r51 r52 r53 r54 r55 r56 r57 r58 r59 u1 u2 u3 u4 u5 d1 d2 d3 d4 d5) nolog
>>
>> I'm trying to compare two models: unrestricted model and restricted model. The unrestricted model is fine, but I don't know how to alter the Brian's code to test the weak separability restrictions.
>>
>> My restriction is something like this:
>>
>> scalar `g14' = ((`a4' + `b4')/(`a3' + `b3'))*(`g13' + `a1'*`a3') - `a1'*`a4'
>> scalar `g16' = ((`a6' + `b6')/(`a5' + `b5'))*(`g15' + `a1'*`a5') - `a1'*`a6'
>> scalar `g24' = ((`a4' + `b4')/(`a3' + `b3'))*(`g23' + `a2'*`a3') - `a2'*`a4'
>> scalar `g26' = ((`a6' + `b6')/(`a5' + `b5'))*(`g25' + `a2'*`a5') - `a2'*`a6'
>> scalar `g34' = ((`a4' + `b4')/(`a3' + `b3'))*(`g33' + `a3'*`a3') - `a3'*`a4'
>> scalar `g36' = ((`a6' + `b6')/(`a5' + `b5'))*(`g35' + `a3'*`a5') - `a3'*`a6'
>> scalar `g44' = ((`a4' + `b4')/(`a3' + `b3'))*(`g43' + `a4'*`a3') - `a4'*`a4'
>> scalar `g46' = ((`a6' + `b6')/(`a5' + `b5'))*(`g45' + `a4'*`a5') - `a4'*`a6'
>> scalar `g56' = ((`a6' + `b6')/(`a5' + `b5'))*(`g55' + `a5'*`a5') - `a5'*`a6'
>>
>> When I start the model, the stata send me this message:
>>
>> could not evaluate equation 1
>> starting values invalid or some RHS variables have missing values
>> r(480);
>>
>> Can anyone help me?
>> I really appreciate it!
>>
>> *
>> * 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/ 		 	   		  
*
*   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