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: NLSUR Quaids


From   "Rahkovsky, Ilya" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: NLSUR Quaids
Date   Thu, 27 Oct 2011 15:06:49 +0000

Hello,

I am trying to follow Brians Poi (2008) QAIDS model. I keep getting an error 111. I have a trace on, and I guess that the error is in the specifying the number of equations, but I am not sure what I should change in the code.

Thank you, Ilya



ERROR MESSAGE



      ------------------------------------------------------------------ begin nlsuraids ---
      - version 10.1
      - use "E:\Data\Demand\agg_aids.dta", clear
      - gen exp = s0 + s1 + s2 + s3 + s9
      - gen lnexp =ln(exp)
      - gen lnp1 = ln(p0)
      - gen lnp2 = ln(p1)
      - gen lnp3 = ln(p2)
      - gen lnp4 = ln(p3)
      - gen lnp5 = ln(p9)
      - drop w*
      - gen w1 = s0 / exp
      - gen w2 = s1 / exp
      - gen w3 = s2 / exp
      - gen w4 = s3 / exp
      - gen w5 = s9 / exp
      - keep w1 w2 w3 w4 lnp1 lnp2 lnp3 lnp4 lnp5 lnexp
      - syntax varlist(min=10 max=10) if, at(name)
      -------------------------------------------------------------------- end nlsuraids ---
    - }
    - if _rc {
    - di as error "nlsur`eqn' returned " _rc
    = di as error "nlsuraids returned " _rc
nlsuraids returned 111
    - di as error "verify that nlsur`eqn' is a function evaluator program"
    = di as error "verify that nlsuraids is a function evaluator program"
verify that nlsuraids is a function evaluator program
    - exit _rc
      }
      }
could not restore sort order because variables were dropped
    ----------------------------------------------------------------- end nlsur.Estimate ---
could not restore sort order because variables were dropped




MY CODE 




set trace on
set tracedepth 4

program drop nlsuraids
program nlsuraids
        version 10.1
use "E:\Data\Demand\agg_aids.dta", clear




gen exp = s0 + s1 + s2 + s3 + s9
gen lnexp =ln(exp)

gen lnp1 = ln(p0)
gen lnp2 = ln(p1)
gen lnp3 = ln(p2)
gen lnp4 = ln(p3)
gen lnp5 = ln(p9)

drop w*

gen w1 = s0 / exp
gen w2 = s1 / exp
gen w3 = s2 / exp
gen w4 = s3 / exp
gen w5 = s9 / exp



keep w1 w2 w3 w4 lnp1 lnp2 lnp3 lnp4 lnp5 lnexp 

syntax varlist(min=10 max=10) if, at(name) 

tokenize w1 w2 w3 w4 lnp1 lnp2 lnp3 lnp4 lnp5 lnexp 

args w0 w1 w2 w3 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' - `a0'

  

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 g44

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' 
  

quietly { 

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

} 

} 

replace `w1' = `a1' + `g11'*`lnp1' + `g12'*`lnp2' + `g13'*`lnp3' + `g14'*`lnp4' + `g15'*`lnp5' + `b1'*(`lnexp' - `lnpindex') 

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

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

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

end 

nlsur aids @ w1 w2 w3 w4  lnp1-lnp5 lnexp, ifgnls nequations(4) param(a1 a2 a3 a4 b1 b2 b3 b4  g11 g12 g13 g14 g22 g23 g24 g33 g34 g44 ) nolog


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