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]
st: Rolling does not roll properly
From
Micha Schildmann <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Rolling does not roll properly
Date
Sun, 23 Mar 2014 23:10:46 +0000 (GMT)
Dear Statalist,
I am trying to create a rolling window regression and capture the t-value. The window should expand by one month per roll and regress all variables on the dependent variable, then rank them according to their t-value and export the results for the given time window. Then the window should expand and repeat the steps. My code currently looks like this.
global counter =0
capture program drop rollingwindow
program rollingwindow
global counter=$counter + 1
global tflist ""
foreach var of varlist *SA{
reg Mid `var'
tempfile tfcur
parmest, idstr("`var'") saving(`"`tfcur'"', replace) flis(tflist)
}
preserve
clear
append using $tflist
sencode idstr, gene(xvar)
lab var xvar "X-variable"
keybygen xvar, gene(parmseq)
drop if parmseq==2
egen rank = rank (-t)
drop if rank>30
save $counter, replace
export excel xvar t using $counter, firstrow(variables) replace
restore
clear
end
For some reason all the files generated contain the same results, as if window is not properly expanding. Additionally, I am not able to recreate the results using single queries.
Does someone see an issue with my formula? Or am I using -rolling- wrong? Alternatively, is there another way to approach this analysis?
Best regards
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/