Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: NLSUR Quaids


From   "Brian P. Poi" <bpoi@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: NLSUR Quaids
Date   Thu, 27 Oct 2011 10:36:23 -0500

Rahkovsky, Ilya wrote:
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
...
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)
...


The problem is that the way your program is written, you are reloading the dataset every time the program nlsuraids gets called.  Instead, you should load in the data once, define the nlsuraids program to just compute the predicted share equations, then call -nlsur- The solution is simple.  In your sample code, just move the three lines

program drop nlsuraids
program nlsuraids
        version 10.1

down, just before the -syntax- statement.

The other problem is that your -tokenize- statement is not correct.

The outline of your entire do-file should be something like


use "E:\Data\Demand\agg_aids.dta", clear
gen exp = ...
gen lnexp = ln(exp)
gen lnp1 = ...
...
gen w1 = ...


capture program drop nlsuraids
program nlsuraids
        version 10.1
        syntax varlist(min=10 max=10) if, at(name)

        tokenize `varlist'
	args w1 w2 w3 w4 lnp1 lnp2 lnp3 lnp4 lnp5 lnexp

        ...
        <I haven't studied the rest of your code carefully, but it looks okay>
        ...
        replace `w1' ...
        replace `w2' ...
        replace `w3' ...
        replace `w4' ...

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



--
Brian P. Poi
Senior Economist
StataCorp LP
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index