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]
Re: st: Looping through several hundred regressions and performing deseasonalising
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Looping through several hundred regressions and performing deseasonalising
Date
Thu, 6 Mar 2014 15:25:58 +0000
On the contrary, -foreach- is exactly what you want. But we can't tell
what "did not work out" for you and why without sight of code and
results.
Something like this appears to be what you want:
foreach v of varlist <varlist> {
su `v', meanonly
local mean = r(mean)
reg `v' `c(Months)' , nocons
predict double `v'SA, residual
replace `v'SA = `v'SA + `mean'
}
It's a nice coincidence that the long English names of months are in
c(Months): see -creturn list-.
Nick
[email protected]
On 6 March 2014 15:17, Micha Schildmann <[email protected]> wrote:
> Hello everyone,
>
> I am currently trying to deseasonalised a few hundred timelines. My command for a single time series looks like this.
>
> sum ACCRUE, meanonly
> local mACCRUE =r(mean)
> reg ACCRUE January February March April May June July August September October November December, nocons
> predict double ACCRUESA, residual
> replace ACCRUESA=ACCRUESA+`mACCRUE'
>
> So now I want to do that for all the time series in my data set. Is there a convinient way to loop the operation?
>
> I was looking at foreach, but that did not work out.
>
> Any help much appreciated.
>
> Best
> Micha
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/