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   Thu, 21 Nov 2013 23:35:43 +0000

Sorry Jorge Perez. I don't see your last reply with your suggestions.

I try to do what you suggest but nothing happened. The Stata send me the classic message:

nlsurquaids returned 198
verify that nlsurquaids is a function evaluator program

These days, I used new codes for the restrict model. The dofile become like this (I am using seven products now, not just six):

program nlsurquaids

version 10

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

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


tempname a1 a2 a3 a4 a5 a6 a7					
					
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' = `at'[1, 6]
scalar `a7' = 1 - `a1' - `a2' - `a3' - `a4' - `a5' - `a6'	


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


tempname g11 g12 g13 g14 g15 g16 g17

tempname g21 g22 g23 g24 g25 g26 g27

tempname g31 g32 g33 g34 g35 g36 g37

tempname g41 g42 g43 g44 g45 g46 g47

tempname g51 g52 g53 g54 g55 g56 g57

tempname g61 g62 g63 g64 g65 g66 g67

tempname g71 g72 g73 g74 g75 g76 g77


scalar `g11' = `at'[1, 13]	
scalar `g12' = `at'[1, 14]	
scalar `g13' = `at'[1, 15]	
scalar `g14' = `at'[1, 16]	
scalar `g15' = `at'[1, 17]	
scalar `g16' = `at'[1, 18]
scalar `g17' = - `g11' - `g12' - `g13' - `g14' - `g15' - `g16'


scalar `g21' = `g12'					
scalar `g22' = `at'[1, 19]
scalar `g23' = `at'[1, 20]
scalar `g24' = `at'[1, 21]
scalar `g25' = `at'[1, 22]
scalar `g26' = `at'[1, 23]
scalar `g27' = - `g21' - `g22' - `g23' - `g24' - `g25' - `g26'


scalar `g31' = `g13'
scalar `g32' = `g23'					
scalar `g33' = `at'[1, 24]	
scalar `g34' = `at'[1, 25]	
scalar `g35' = `at'[1, 26]		
scalar `g36' = `at'[1, 27]
scalar `g37' = - `g31' - `g32' - `g33' - `g34' - `g35' - `g36'


scalar `g41' = `g14'
scalar `g42' = `g24'
scalar `g43' = `g34'	
scalar `g44' = `at'[1, 28]
scalar `g45' = `at'[1, 29]
scalar `g46' = `at'[1, 30]
scalar `g47' = - `g41' - `g42' - `g43' - `g44' - `g45' - `g46'


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


scalar `g61' = `g16'						
scalar `g62' = `g26'						
scalar `g63' = `g36'						
scalar `g64' = `g46'						
scalar `g65' = `g56'							
scalar `g66' = `at'[1, 33]
scalar `g67' = - `g61' - `g62' - `g63' - `g64' - `g65' - `g66'


scalar `g71' = `g17'						
scalar `g72' = `g27'						
scalar `g73' = `g37'						
scalar `g74' = `g47'						
scalar `g75' = `g57'							
scalar `g76' = `g67'
scalar `g77' = - `g71' - `g72' - `g73' - `g74' - `g75' - `g76'



tempname g17

scalar `g17' = ((`a1' + `b1')/(`a6' + `b6'))*(`g67' + `a6'*`a7') - `a1'*`a7'


tempname g27 

scalar `g27' = ((`a2' + `b2')/(`a6' + `b6'))*(`g67' + `a6'*`a7') - `a2'*`a7'


tempname g37
			
scalar `g37' = ((`a3' + `b3')/(`a6' + `b6'))*(`g67' + `a6'*`a7') - `a3'*`a7'


tempname g47

scalar `g47' = ((`a4' + `b4')/(`a6' + `b6'))*(`g67' + `a6'*`a7') - `a4'*`a7'


tempname g57

scalar `g57' = ((`a5' + `b5')/(`a6' + `b6'))*(`g67' + `a6'*`a7') - `a5'*`a7'



tempname l1 l2 l3 l4 l5 l6 l7						
						
scalar `l1'	= `at'[1, 34]	
scalar `l2'	= `at'[1, 35]	
scalar `l3'	= `at'[1, 36]	
scalar `l4'	= `at'[1, 37]	
scalar `l5'	= `at'[1, 38]		
scalar `l6'	= `at'[1, 39]
scalar `l7'	= - `l1' - `l2' - `l3' - `l4' - `l5' - `l6'



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

tempname r61 r62 r63 r64 r65 r66 r67 r68 r69

scalar `r11' = `at'[1, 40]
scalar `r12' = `at'[1, 41]
scalar `r13' = `at'[1, 42]
scalar `r14' = `at'[1, 43]
scalar `r15' = `at'[1, 44]
scalar `r16' = `at'[1, 45]
scalar `r17' = `at'[1, 46]
scalar `r18' = `at'[1, 47]
scalar `r19' = `at'[1, 48]

scalar `r21' = `at'[1, 49]
scalar `r22' = `at'[1, 50]
scalar `r23' = `at'[1, 51]
scalar `r24' = `at'[1, 52]
scalar `r25' = `at'[1, 53]
scalar `r26' = `at'[1, 54]
scalar `r27' = `at'[1, 55]
scalar `r28' = `at'[1, 56]
scalar `r29' = `at'[1, 57]

scalar `r31' = `at'[1, 58]
scalar `r32' = `at'[1, 59]
scalar `r33' = `at'[1, 60]
scalar `r34' = `at'[1, 61]
scalar `r35' = `at'[1, 62]
scalar `r36' = `at'[1, 63]
scalar `r37' = `at'[1, 64]
scalar `r38' = `at'[1, 65]
scalar `r39' = `at'[1, 66]

scalar `r41' = `at'[1, 67]
scalar `r42' = `at'[1, 68]
scalar `r43' = `at'[1, 69]
scalar `r44' = `at'[1, 70]
scalar `r45' = `at'[1, 71]
scalar `r46' = `at'[1, 72]
scalar `r47' = `at'[1, 73]
scalar `r48' = `at'[1, 74]
scalar `r49' = `at'[1, 75]

scalar `r51' = `at'[1, 76]
scalar `r52' = `at'[1, 77]
scalar `r53' = `at'[1, 78]
scalar `r54' = `at'[1, 79]
scalar `r55' = `at'[1, 80]
scalar `r56' = `at'[1, 81]
scalar `r57' = `at'[1, 82]
scalar `r58' = `at'[1, 83]
scalar `r59' = `at'[1, 84]

scalar `r61' = `at'[1, 85]
scalar `r62' = `at'[1, 86]
scalar `r63' = `at'[1, 87]
scalar `r64' = `at'[1, 88]
scalar `r65' = `at'[1, 89]
scalar `r66' = `at'[1, 90]
scalar `r67' = `at'[1, 91]
scalar `r68' = `at'[1, 92]
scalar `r69' = `at'[1, 93]


****Endogeneidade do Dispêndio

tempname u1 u2 u3 u4 u5	u6				
					
scalar `u1'	= `at'[1, 94]
scalar `u2'	= `at'[1, 95]
scalar `u3'	= `at'[1, 96]
scalar `u4'	= `at'[1, 97]
scalar `u5'	= `at'[1, 98]
scalar `u6'	= `at'[1, 99]



tempname d1 d2 d3 d4 d5	d6				
					
scalar `d1'	= `at'[1, 100]
scalar `d2'	= `at'[1, 101]
scalar `d3'	= `at'[1, 102]
scalar `d4'	= `at'[1, 103]
scalar `d5'	= `at'[1, 104]
scalar `d6'	= `at'[1, 105]

	  
quietly {
        * The b(p) term in the QUAIDS model:
        tempvar bofp
        gen double `bofp' = 0
        forvalues i = 1/7 {
            replace `bofp' = `bofp' + `lnp`i''*`b`i''
        }
        replace `bofp' = exp(`bofp')
        // Finally, the expenditure shares for 6 of the 7
        // goods (the equation 7 is dropped to avoid singularity)
		
		
   replace `w1' = [`a1' + `g11'*`lnp1' + `g12'*`lnp2' +`g13'*`lnp3' + `g14'*`lnp4' + `g15'*`lnp5' + `g16'*`lnp6' + `g17'*`lnp7' + `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'*`lnMa_est']*`F1' + `d1'*`fe1'   

   replace `w2' = [`a2' + `g21'*`lnp1' + `g22'*`lnp2' +`g23'*`lnp3' + `g24'*`lnp4' + `g25'*`lnp5' + `g26'*`lnp6' + `g27'*`lnp7' + `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'*`lnMa_est']*`F2' + `d2'*`fe2'
   
   replace `w3' = [`a3' + `g31'*`lnp1' + `g32'*`lnp2' +`g33'*`lnp3' + `g34'*`lnp4' + `g35'*`lnp5' + `g36'*`lnp6' + `g37'*`lnp7' + `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'*`lnMa_est']*`F3' + `d3'*`fe3'
   
   replace `w4' = [`a4' + `g41'*`lnp1' + `g42'*`lnp2' +`g43'*`lnp3' + `g44'*`lnp4' + `g45'*`lnp5' + `g46'*`lnp6' + `g47'*`lnp7' + `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'*`lnMa_est']*`F4' + `d4'*`fe4'
   
   replace `w5' = [`a5' + `g51'*`lnp1' + `g52'*`lnp2' +`g53'*`lnp3' + `g54'*`lnp4' + `g55'*`lnp5' + `g56'*`lnp6' + `g57'*`lnp7' + `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'*`lnMa_est']*`F5' + `d5'*`fe5'
  
   replace `w6' = [`a6' + `g61'*`lnp1' + `g62'*`lnp2' +`g63'*`lnp3' + `g64'*`lnp4' + `g65'*`lnp5' + `g66'*`lnp6' + `g67'*`lnp7' + `b6'*(`lnexp' - `lnpindex') + `l6'/`bofp'*(`lnexp' - `lnpindex')^2 + `r61'*`urban' + `r62'*`norte' + `r63'*`nordeste' + `r64'*`sudeste' + `r65'*`centro_oeste' + `r66'*`anosestudo' + `r67'*`mulherchefe' + `r68'*`crian_adolesc' + `r69'*`idoso' + `u6'*`lnMa_est']*`F6' + `d6'*`fe6'

}
end


matrix ivals = J(1, 105, 0)

matrix ivals[1,1] = 0.1

matrix ivals[1,2] = 0.1

matrix ivals[1,3] = 0.1

matrix ivals[1,4] = 0.1

matrix ivals[1,5] = 0.1

matrix ivals[1,6] = 0.1
use "85_Variaveis_QUAIDS.dta"



nlsur quaids @ w1 w2 w3 w4 w5 w6 lnp1 lnp2 lnp3 lnp4 lnp5 lnp6 lnp7 lnexp lnpindex urban norte nordeste sudeste centro_oeste anosestudo mulherchefe crian_adolesc idoso lnMa_est fe1 fe2 fe3 fe4 fe5 fe6 F1 F2 F3 F4 F5 F6, init(ivals) ifgnls nequations(6) param(a1 a2 a3 a4 a5 a6 b1 b2 b3 b4 b5 b6 g11 g12 g13 g14 g15 g16 g22 g23 g24 g25 g26 g33 g34 g35 g36 g44 g45 g46 g55 g56 g66 l1 l2 l3 l4 l5 l6 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 r61 r62 r63 r64 r65 r66 r67 r68 r69 u1 u2 u3 u4 u5 u6 d1 d2 d3 d4 d5 d6)


After I estimate the restric model and the irrestrict model, I used the Likelihood Ratio Test to know if the restrict model was the best. But when I use the lrtest command, stata return me this sentence:


lrtest m1 m2
df(unrestricted) = df (restricted) = 105

It seems that the restrictions are not making a difference. I think that the problem could be only on the database or in the restrict model dofile. I think that the database is all right, so the irrestrict model is fine.

Thank you for helping, Jorge Perez. If you need my database tell me that I send to your email.  


> From: [email protected]
> Date: Thu, 21 Nov 2013 17:23:34 -0500
> Subject: Re: st: Separability Restrictions Nlsur Quaids
> To: [email protected]
> 
> You never told us whether my suggestions to fix the code worked ...
> --------------------------------------------
> Jorge Eduardo Pérez Pérez
> Graduate Student
> Department of Economics
> Brown University
> 
> 
> On Thu, Nov 21, 2013 at 4:01 PM, Guilherme Travassos
> <[email protected]> wrote:
>> Hi Statalisters,
>>
>> Has anyone worked with weak separability using the Brian's Poi code (2008)?
>>
>> I need some help.
>>
>> Thank you again.
>>
>> Guilherme Travassos
>>
>>> From: [email protected]
>>> Date: Mon, 11 Nov 2013 15:50:56 -0500
>>> Subject: Re: st: Separability Restrictions Nlsur Quaids
>>> To: [email protected]
>>>
>>> I am sorry, I thought the FE and fe terms were coefficients, I now
>>> realized they are variables and their corresponding coefficients are
>>> already being called by the "d" terms. Please ignore my advice
>>> regarding those.
>>>
>>>
>>> --------------------------------------------
>>> Jorge Eduardo Pérez Pérez
>>> Graduate Student
>>> Department of Economics
>>> Brown University
>>>
>>>
>>> On Mon, Nov 11, 2013 at 3:43 PM, Jorge Eduardo Pérez Pérez
>>> <[email protected]> wrote:
>>>> You are defining g14, g16, g24, g26, g34, g44, g46 and g56 twice in
>>>> your code. First you define them along all the other g terms
>>>>
>>>> tempname g21 g22 g23 g24 g25 g26
>>>> ...
>>>>
>>>> and then you define them again
>>>>
>>>> tempname g14 g16
>>>> ....
>>>>
>>>> Try to define these only once. To do this, supress the initial
>>>> definitions and leave only the definitions due to the restricted
>>>> model.
>>>>
>>>> scalar `g11' = `at'[1, 11]
>>>> * Do not define g12
>>>> scalar `g13' = `at'[1, 13]
>>>> scalar `g14' = `at'[1, 14]
>>>> scalar `g15' = `at'[1, 15]
>>>> * Do not define g16
>>>>
>>>> Do the same for the remaining terms.
>>>>
>>>> Also, you need to make tempname calls for the "fe" and "FE" terms in
>>>> your model and add them to your "at" vector
>>>>
>>>> tempname fe1 fe2 ...
>>>> scalar `fe1' = `at'[1, ...
>>>>
>>>> tempname FE1 FE2 ...
>>>> scalar `FE1' = `at'[1,...
>>>>
>>>> If this doesn't work, send me a piece of your dataset privately
>>>> (Attachments are forbidden in Statalist) and I will look again.
>>>>
>>>> Jorge Perez.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --------------------------------------------
>>>> Jorge Eduardo Pérez Pérez
>>>> Graduate Student
>>>> Department of Economics
>>>> Brown University
>>>>
>>>>
>>>> On Mon, Nov 11, 2013 at 11:20 AM, Guilherme Travassos
>>>> <[email protected]> wrote:
>>>>> Thank you again for your help, Jorge Perez.
>>>>>
>>>>> I try to do what you sad, but nothing changes.
>>>>>
>>>>> If you had some other ideia that could help me, I would be grateful. I don't know what to do anymore.
>>>>>
>>>>>
>>>>>> From: [email protected]
>>>>>> Date: Mon, 11 Nov 2013 09:30:51 -0500
>>>>>> Subject: Re: st: Separability Restrictions Nlsur Quaids
>>>>>> To: [email protected]
>>>>>>
>>>>>> - To specify initial values to your parameters, add the following
>>>>>> option to your -nlsur- call:
>>>>>> initial(a3 1 a5 1 b3 1 b5 1)
>>>>>> where you can change the 1's to the values of your choice. Just make
>>>>>> sure the initial a3+b3 and a5+b5 are not 0.
>>>>>>
>>>>>> - Brian Poi's -quaids- command can be installed by writing:
>>>>>>
>>>>>> net install st0268_1.pkg
>>>>>>
>>>>>> Then write:
>>>>>>
>>>>>> help quaids to see how it works.
>>>>>>
>>>>>> Let me know if changing the initial values works. If not, I will take
>>>>>> a closer look at your code.
>>>>>>
>>>>>>
>>>>>> --------------------------------------------
>>>>>> Jorge Eduardo Pérez Pérez
>>>>>> Graduate Student
>>>>>> Department of Economics
>>>>>> Brown University
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 8, 2013 at 10:59 AM, Guilherme Travassos
>>>>>> <[email protected]> wrote:
>>>>>>> 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/
>>>>>>
>>>>>> *
>>>>>> * 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/
>> *
>> * 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