Monthly regression
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
Monthly regression
I have 3 time series of daily observations for 10 years, and I want to run the regression of every month separately (not rolling regression, I want to use the daily observations of each month to run the regression of that month, and then move to the next month and doing the same and so on. Any suggestions on how to do that?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13323
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Monthly regression
You can create a series of month numbers (starting at 1 for the first month in your sample, then increasing each month) with the following:
(this simply sets the first observation [@trend=0] to 1, then has a test - if the month of the current observation is different from the previous observation, add 1, otherwise stay the same).
Once you have that series you can just have a for loop that loops through the values in that series, setting the sample and estimating the equation.
Code: Select all
series monthnum = @recode(@trend=0,1,@recode(@month<>@month(-1),monthnum(-1)+1,monthnum(-1)))
(this simply sets the first observation [@trend=0] to 1, then has a test - if the month of the current observation is different from the previous observation, add 1, otherwise stay the same).
Once you have that series you can just have a for loop that loops through the values in that series, setting the sample and estimating the equation.
Follow us on Twitter @IHSEViews
Re: Monthly regression
Amazing! I know how to create the for loop but I did not manage to set the sample using the monthnum series, please can you suggest how to do it?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13323
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Monthly regression
Brilliant. Solved. Million thanks.
Re: Monthly regression
Hello again, I have another question. Is there a way to save the residual series of all the sample regressions? now the regression is based on the sample (each month) and not the whole time series. So, when I used "makeresids" commands it saved the residuals of the first month/sample only and it shows N/A for the rest samples/months. I need the residual series of all the samples/months. Please I highly appreciate your suggestions on how to do that.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13323
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Monthly regression
After each regression, copy the residuals into a series. Since the sample is set to the current monthly, the copy will only copy values for the month being estimated.
Follow us on Twitter @IHSEViews
Re: Monthly regression
Thank you so much for your reply. Actually, I have tried that and did not work properly because the length of the time series (10 years) is not identical to the length of the sample (one month). I put the save command of the residual series inside the loop to save the residual series for every month but did not work. It only saved the residuals of the first month of the first series and left the other residual series content as N/A.
Who is online
Users browsing this forum: Google [Bot] and 16 guests