Naming variable question
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Naming variable question
Hi,
Is there a way to name a variable something different depending on when the sample ends? I have an expanding sample and I'd like to rename my variable some thing based on what month it is relative to the quarter. So all Januarys, Aprils, Julys and Octobers would be X_1 because they are the first month of a quarter. Then X_2 would be February, May, August and November, etc.
Thanks!
Is there a way to name a variable something different depending on when the sample ends? I have an expanding sample and I'd like to rename my variable some thing based on what month it is relative to the quarter. So all Januarys, Aprils, Julys and Octobers would be X_1 because they are the first month of a quarter. Then X_2 would be February, May, August and November, etc.
Thanks!
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Naming variable question
Hello,
You can certainly calculate the correct month-of-the-quarter defined by the end of a sample, e.g., the current sample,
You can certainly calculate the correct month-of-the-quarter defined by the end of a sample, e.g., the current sample,
Code: Select all
!q = @mod(@datepart(@dateval(@word(@pagesmpl, 2)), "mm") - 1, 3) + 1
series x_!q = ...
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Re: Naming variable question
Thanks Matt. I think your solution would work in the case of doing them all at once. What I'm looking to do is find the rmse of a model with mixed frequencies. So I thought I could create different variables for the forecast depending on how many months are known as the forecasts are made in an expanding window.
Edit: Is there a way to calculate the RMSE of select observations in a series? that would be another way to get at what i want.
Thanks!
Edit: Is there a way to calculate the RMSE of select observations in a series? that would be another way to get at what i want.
Thanks!
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Naming variable question
Perhaps the simple solution is to perform the RMSE calculation explicitly, using either the current sample, e.g.,
or an explicit sample, e.g.,
to specify the observations you're considering.
Code: Select all
@sqrt(@sumsq(x - x_f) / @obs(x_f))
or an explicit sample, e.g.,
Code: Select all
@sqrt(@sumsq(x - x_f, "<sample>") / @obs(x_f, "<sample>"))
to specify the observations you're considering.
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Re: Naming variable question
Yes this would be good. I suppose I could just create a sample for all first months, second months and third months. like this:
sample firstmonths = 2010m1 2010m4 2010m7 2010m10 2011m1 etc...
unless theres a quicker way?
sample firstmonths = 2010m1 2010m4 2010m7 2010m10 2011m1 etc...
unless theres a quicker way?
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Naming variable question
How about,
Code: Select all
sample firstmonths @all if @mod(@month, 3) = 1
sample secondmonths @all if @mod(@month, 3) = 2
sample thirdmonths @all if @mod(@month, 3) = 0
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Re: Naming variable question
I'm not sure thats working, but thinking about it its not a good solution anyway because the forecasted variable is quarterly, so I need to have a forecast for each month of the quarter in quarter frequency. In other words, I'm back to needing to be able to name my forecasted variable something different depending on how many months of data i have.
Maybe I can get around this with an if function?
is it possible to turn something like following into code
if the date is a first month
series xfirstmonth=x
if the date is a second month
series xsecondmonth=x
etc
Maybe I can get around this with an if function?
is it possible to turn something like following into code
if the date is a first month
series xfirstmonth=x
if the date is a second month
series xsecondmonth=x
etc
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Naming variable question
Would not a variation of my first response work then?
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Re: Naming variable question
I dont understand what that answer does. I tried plugging it in and it just gives me a copy of the same series
!q = @mod(@datepart(@dateval(@word(@pagesmpl, 2)), "mm") - 1, 3) + 1
series x_!q = ...
!q = @mod(@datepart(@dateval(@word(@pagesmpl, 2)), "mm") - 1, 3) + 1
series x_!q = ...
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Naming variable question
I believe I'm not understanding what you're trying to achieve. Could you provide a more detailed description and perhaps an example?
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Re: Naming variable question
Yes of course.
I want to write a program with a simple model y= c+Bx. My y is quarterly and my x is monthly. Lets say I have data for January 2019 for x. I want to fill in February and March in some way in order to have a full Q1 that can be used to forecast my y. I also want to be able to do this when I get February data for x, and March etc. To calculate the RMSE of an expanding window I usually just create the forecast and copy it to a new series so that I have a series of one period ahead forecasts. This works when I'm dealing with only quarterly data. But the fact that I'm working with mixed frequencies makes this more difficult. I want to know what the RMSE of my model is at different points in the quarter.
IS that a bit clearer?
I want to write a program with a simple model y= c+Bx. My y is quarterly and my x is monthly. Lets say I have data for January 2019 for x. I want to fill in February and March in some way in order to have a full Q1 that can be used to forecast my y. I also want to be able to do this when I get February data for x, and March etc. To calculate the RMSE of an expanding window I usually just create the forecast and copy it to a new series so that I have a series of one period ahead forecasts. This works when I'm dealing with only quarterly data. But the fact that I'm working with mixed frequencies makes this more difficult. I want to know what the RMSE of my model is at different points in the quarter.
IS that a bit clearer?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Naming variable question
That seems entirely unrelated to your original question, which was about naming series?
Follow us on Twitter @IHSEViews
-
- Posts: 199
- Joined: Sun Mar 01, 2015 5:01 pm
Re: Naming variable question
EViews Gareth wrote:That seems entirely unrelated to your original question, which was about naming series?
Not at all. My original question was about naming the series something different depending on how much data there is in order to separate the 0th months, first months and second months in order to calculate the rmses of each point in the quarter. I just gave more background as to what I'm trying to do.
Who is online
Users browsing this forum: No registered users and 22 guests