Statalist


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

st: Re: save coeff estimators of Arima model with foreach


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: Re: save coeff estimators of Arima model with foreach
Date   Thu, 12 Mar 2009 01:21:42 +0100

<>

I cannot see what is inherently wrong in your code. If others want to check my reasoning, it is pretty much equivalent to

*******
sysuse auto, clear
g coeffs=.
qui levelsof rep78, loc(levels)
qui foreach l of local levels {
    reg pr we f tr if rep == `l'
    replace coeffs= _b[tr] if rep == `l'
}
sort rep
l coef rep78, noo sepby(rep)
*******

which does work, and is itself equivalent to the easier

*******
statsby _b[tr], by(rep78) clear : reg pr we f tr
*******

though that -after your confirmation- destroys your dataset in memory.


So you say that you have checked you can run these commands on the entire sample. That need not mean much. Rather, pick out some level of your gvkey randomly and run the thing with the if-statements present. Try that for a couple of these levels to get a flavor of what is going on and report the results back to the list...

HTH
Martin
_______________________
----- Original Message ----- From: "Hua Pan" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 11, 2009 11:42 PM
Subject: st: save coeff estimators of Arima model with foreach


Hi statalisters,

I’m a beginner for Stata, and I have just a problem with it. I want to do a cross-sectional time series analysis with command “arima” and imput the estimator of “AR L1. Coefficient” of every panel data into the datasheet with the help of “foreach” and “levelsof”.

My Data looks like this:
gvkey      qtl         eps
1 2003q1        ….
1       2003q2        ….
1       2003q3        ….
...       …….
2       2003q1
2       2003q2
2       2003q3
…
gvkey:  identify-Nr. of firms (panel variable, long)
qtl:     quarter (time variable, float)
eps:    earnings per share (dependent variable, float)

So I’ve tried:

- generate AR =.
tsset gvkey qtl
levelsof gvkey, local(levels)
foreach l of local levels {
arima eps if gvkey == `l', arima(1,0,0) sarima(0,1,0,4)
replace AR = _b[ARMA:L1.ar] if gvkey == `l'
}

But it doesn’t seem to work. Time series analysis (Arima) hasn’t been done and all of AR are still missing value.
I’m sure this is correct:
- arima eps, arima(1,0,0) sarima(0,1,0,4)
- replace AR = _b[ARMA:L1.ar]
I’ve tried it for data with one Observation (one gvkey)

I guess, there may be something wrong with foreach or levelsof, but I can’t find the error. Can anyone here give me any advice?
Any help would be greatly appreciated. Thanks in advance for your time.
I’m using Stata version 10.1 SE (Windows).

Best Regards

Hua Pan
University of Cologne


--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
*
*   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index