Bookmark and Share

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: RE: RE: RE: RE: RE: RE: RE: Extracting results from -rolling- in one file per window


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: RE: RE: RE: RE: RE: Extracting results from -rolling- in one file per window
Date   Mon, 17 Mar 2014 16:27:05 +0000

Micha,

I don't know a lot about -rolling-, but my understanding is that you need to -tsset- your data first and -tsset- uses the format of the time variable to determine the increments.  So if your data is in daily format, you will either need to change it to weekly format or use -rolling, stepsize(7)- possibly with the -start()- option. Either of these should work, but I think the latter would be easier.

I'm not sure what is going on with your "no; data would be lost" problem. I had a similar problem when I was working out a solution to your original question, but I don't remember how I fixed it.  I was using my work computer and I am home today due to snow so I might be able to figure out something tomorrow when I return to work.

Regards,
Joe

________________________________________
From: [email protected] [[email protected]] on behalf of Micha Schildmann [[email protected]]
Sent: Monday, March 17, 2014 11:43 AM
To: [email protected]
Subject: st: RE: RE: RE: RE: RE: RE: Extracting results from -rolling- in one file per window

Hm ok yea that was kind of obvious. Was probably a bit too late at that point. Thanks both of you for pointing my mistake out.

After stata first did not want to execute my rolling window due to "no; data in memory would be lost", I added a clear command to the code as can be seen below (the -preserve- and -restore- commands should be useless at that point, I just forgot to delete them). The comand executed and created several hundred files with the regression results. At that point I realized that I probably chose a wrong window size as I ony expected to get around 120 files as I wanted a rolling window increasing by a month, but got over 500 files (at that point I stopped the execution). My data is in daily format, but in weekly steps (so first observation at 01/02/04, second on 01/09/04) and by choosing a window of 4 I hoped to get monthly windows. Should I instead switch to a window of (30)or change the date to weekly format and then try 4 again? I checked the -rolling- but I am not sure if I understood it right.

Furthermore, after trying to adopt the code to have a rolling window of 30, the code did not work anymore although I used the code from the review of stata. Again, I got the "no; data in memory would be lost" error and using trace I get again



-------------------------------
  - if c(changed) {
  - di as error "no; data in memory would be lost"
no; data in memory would be lost
  - exit 4
-------------------------------

Deleting -preserve- and -restore- does not help.

I am a bit confused...

The code that worked one time but now does not 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
restore
clear
end

rolling, window(4) stepsize (4) recursive: rollingwindow


Any help is much appreciated.

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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index