Page 1 of 1

Naming variable question

Posted: Tue Jun 18, 2019 12:46 pm
by miorinnovo
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!

Re: Naming variable question

Posted: Tue Jun 18, 2019 2:42 pm
by EViews Matt
Hello,

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 = ...

Re: Naming variable question

Posted: Wed Jun 19, 2019 10:25 am
by miorinnovo
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!

Re: Naming variable question

Posted: Wed Jun 19, 2019 11:47 am
by EViews Matt
Perhaps the simple solution is to perform the RMSE calculation explicitly, using either the current sample, e.g.,

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.

Re: Naming variable question

Posted: Wed Jun 19, 2019 12:06 pm
by miorinnovo
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?

Re: Naming variable question

Posted: Wed Jun 19, 2019 12:49 pm
by EViews Matt
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

Re: Naming variable question

Posted: Wed Jun 19, 2019 1:09 pm
by miorinnovo
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

Re: Naming variable question

Posted: Thu Jun 20, 2019 9:46 am
by EViews Matt
Would not a variation of my first response work then?

Re: Naming variable question

Posted: Thu Jun 20, 2019 11:09 am
by miorinnovo
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 = ...

Re: Naming variable question

Posted: Thu Jun 20, 2019 1:13 pm
by EViews Matt
I believe I'm not understanding what you're trying to achieve. Could you provide a more detailed description and perhaps an example?

Re: Naming variable question

Posted: Fri Jun 21, 2019 8:56 am
by miorinnovo
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?

Re: Naming variable question

Posted: Fri Jun 21, 2019 10:05 am
by EViews Gareth
That seems entirely unrelated to your original question, which was about naming series?

Re: Naming variable question

Posted: Fri Jun 21, 2019 11:32 am
by miorinnovo
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.