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

From |
"Hua Pan" <panhua@gmx.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
AW: st: Re: save coeff estimators of Arima model with foreach |

Date |
Thu, 12 Mar 2009 15:31:02 +0100 |

Oh my god, I�really sorry for that, Martin! I� avoid such spelling mistakes later. And you know what, I’ve tried my foreach command that I’ve written in the Email again, and it works!!! I must have made some mistakes as I typed, or you have some magic?! Whatever I really appreciate your great help, and hope at least that my Email and my foreach command with arima can be helpful to the beginners who have difficulty with these commands. Martin, thank you very much again and thank you everybody who read this Email for your time and attention. Best Wishes Hua -------- Original-Nachricht -------- > Datum: Thu, 12 Mar 2009 13:53:36 +0100 > Von: "Martin Weiss" <martin.weiss1@gmx.de> > An: statalist@hsphsun2.harvard.edu > Betreff: AW: st: Re: save coeff estimators of Arima model with foreach > <> > > > "Marin" is a new variant, but at least you can distinguish it more clearly > from other listers... You also intersperse your text with German words > "als" and "wenn"... > > > " ... and run the foreach command several times" I did not want you to run > -foreach- several times: Rather, run examples of what happens inside the > loop. > > **** > arima eps if gvkey == 3, arima(1,0,0) sarima(0,1,0,4) > replace AR = _b[ARMA:L1.ar] if gvkey == 3 > **** > > and try other values for "gvkey" (and report the results). > > > If all you type is - generate AR = _b[ARMA:L1.ar]-, Stata creates a new > variable and fills it with the expression after the equal sign, so you end up > with an array of identical values. > > > > > HTH > Martin > > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Hua Pan > Gesendet: Donnerstag, 12. März 2009 13:23 > An: statalist@hsphsun2.harvard.edu > Betreff: Re: st: Re: save coeff estimators of Arima model with foreach > > Hello Marin, Hello Statalisters, > > Thank you very much for your quick response and quite a few advices, > Martin. It’s really very kind of you. > > Following your advice, I picked out some gvkey randomly and run the > foreach command several times, but it appears the same result, all of the AR > remain missing. > > I’ve tried statsby, which you advice me > - tsset gvkey qtl > -statsby, by(gvkey): arima eps, arima(1,0,0) sarima(0,1,0,4) > but an error appears: > -sample may not include multiple panels > -an error occurred when statsby executed arima > -r(459); > > I’ve checked rolling, estimates store, eststo and postfile, but they > don’t seem to help a lot. I just want to generate the new variable > “_b[]” in the old datasheet. But thank you all the same for your advice. > > I really have no idea what’s wrong with it, it seems to be correct like > your sample, but it doesn’t work!? > > Maybe some more details may help us to find out the key: > I tied this one for just one gvkey and it works well: > - tsset qtl > - arima eps, arima(1,0,0) sarima(0,1,0,4) > - generate AR = _b[ARMA:L1.ar] > > and for many gvkey(panel data) without loop: > - tsset gvkey qtl > - by gvkey, sort : arima eps, arima(1,0,0) sarima(0,1,0,4) > tables of estimation of all gvkeys appear on the screen, it works well. > But wenn I typed: > - generate AR = _b[ARMA:L1.ar] > The value of ARs for all gvkeys is the value of AR for the last gvkey. So > I want to try with foreach to get AR (AR-Coef.) for each gvkey and save > them als new variable in datasheet. > Thany you very much in advance. > > Best Regards > > Hua > > -------- Original-Nachricht -------- > > Datum: Thu, 12 Mar 2009 01:21:42 +0100 > > Von: "Martin Weiss" <martin.weiss1@gmx.de> > > An: statalist@hsphsun2.harvard.edu > > Betreff: st: Re: save coeff estimators of Arima model with foreach > > > <> > > > > 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" <panhua@gmx.de> > > To: <statalist@hsphsun2.harvard.edu> > > 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/ > > -- > 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/ -- 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/

**References**:**st: save coeff estimators of Arima model with foreach***From:*"Hua Pan" <panhua@gmx.de>

**st: Re: save coeff estimators of Arima model with foreach***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: Re: save coeff estimators of Arima model with foreach***From:*"Hua Pan" <panhua@gmx.de>

**AW: st: Re: save coeff estimators of Arima model with foreach***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**Re: st: AW: RE: AW: RE: Re: Generate Variable** - Next by Date:
**RE: st: nonconvergence of switching probit when data weighted** - Previous by thread:
**AW: st: Re: save coeff estimators of Arima model with foreach** - Next by thread:
**Re: st: Re: Generate Variable** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |