Thanks. In fact, a closer scrutiny of your
original reveals what may be the main problem,
so my request for extra information should
have been superfluous in this case.
I link you need to call
lags(A1 A2 <etc.>
_not_
lags(`A1' `A2' <etc.>)
I wouldn't do it that way, however:
foreach k of varlist netprem disclm elr solv {
preserve
keep if variable == "`k'"
forvalues x = 1/19 {
sum lagrawnotrend if comcode == `x', mean
local lags "`lags' `r(mean)'"
}
levinlin `k', lags(`lags')
restore
}
I still don't buy the explanation for the -preserve-
and -restore-. Sounds as if you just need to modify
the -if- condition.
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of
> Dev Vencappa
> Sent: 22 October 2003 14:45
> To: [email protected]
> Subject: Re: st: RE: RE: feeding optimal lag lengths in levinlin
> andipshinwithin a loop
>
>
> Nick
>
> Sorry for missing some details in the explanation. This is
> how the data looks like. Let us say in one panel I have
> variables A B C D E F and suppose variable A is the optimal
> lag length for each company in that panel. This one panel
> however refers to an identifier variable called netprem.
> Now I append to the first panel a second panel which is for
> for identifier variable disclm, which takes the same values
> for variables B C D E F but has different values for
> variable A (as the optimal lag length will be different for
> a different identifier and each company for that diferent
> identifier). Same applies to the panel for identifiers elr
> and solv. This is why I have to use preserve to ask stata
> to run the levinlin test for one identifier, and then
> restore the data to run it for the second identifier and so on.
> When using this loop, the error message I get is
> option lags() required
>
> which seems to indicate that stata cannot read these scalar
> values A1, A2, etc in the levinlin option.
>
> Hope that helps in finding a solution to the problem.
>
> Many thanks
>
> Dev
>
> Dev Vencappa
> School of Economics
> University of Nottingham
> University Park
> Nottingham
> NG7 2RD
> U.K.
> Tel : +44 (0)115 951 5608
> Fax: +44 (0) 115 951 4159
> >>> [email protected] 10/22/03 2:26 PM >>>
> You don't say how this fails to work, but a lot may
> hinge on
>
> keep if variable == "`k'"
>
> which suggests either an unusual data structure
> or a misunderstanding of -keep-.
>
> However, none of the -preserve-, -restore- or
> -keep- seems essential for the rest of the code.
>
> Also, are the results of -summarize- all integers?
>
> Nick
> [email protected]
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]]On Behalf Of
> > Dev Vencappa
> > Sent: 22 October 2003 14:15
> > To: [email protected]
> > Subject: st: RE: feeding optimal lag lengths in levinlin and
> > ipshinwithin a loop
> >
> >
> > Stata users, I have a slight problem with panel unit root test.
> > Thanks to an earlier suggestion by Nick, Ernest and others,
> > I managed to replicate what I am doing below for simple
> > time series.
> > My current problem is that I have four variables recorded
> > in a panel of 19 companies over 18 years. For each
> > variable,I have worked out an optimal lag length for each
> > company, and would now like levinlin to be able to read
> > this optimal lag length for each company rather than me
> > having to feed it in the lags option of the command every
> > time. I have come up with the following loop, which does
> > not seem to work unfortunately. Can anybody spot the
> > problem please and suggest a shortcut to that if possible?
> > The same thing will also be used for ipshin. Does anybody
> > also know how to save the results of ipshin and call them
> > into a variable?
> >
> > foreach k of varlist netprem disclm elr solv {
> > preserve
> > keep if variable=="`k'"
> > forvalues x=1/19{
> > sum lagrawnotrend if comcode==`x', mean
> > scalar A`x'=r(mean)
> > }
> >
> > levinlin `k', lags(`A1' `A2' `A3' `A4' `A5' `A6' `A7' `A8'
> > `A9' `A10' `A11' `A12' `A13' `A14' `A15' `A16' `A17' `A18' `A19')
> > restore
> > }
> >
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/