Hi - I have the following code:
for !i =1 to @columns(m1)
vector v!i = @columnextract(m1, !i)
mtos(v1, s1)
'do stuff here on the series'
next i
It works in 1 program file but not in another. The error message is: V1 is not the same length as the sample MTOS(V1,S1). I don't understand the message - so I am not sure how to fix it! Also generally confused as it works in the other program file....Could you help pls! Thanks!
mtos
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: mtos
When you go from a series to a group using stom, the output size can be arbitrary since vectors and matrices are of arbitrary numbers of rows.
When you go from a matrix to a series or group, the source must be the same as the destination as the series are in the workfile which is of fixed size.
When you go from a matrix to a series or group, the source must be the same as the destination as the series are in the workfile which is of fixed size.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: mtos
It depends on the size of the source and the workfile. In some cases/workfiles it will work (if the destination size matches), and it others it won't.
If you have a vector of size 20 and a workfile of size 100, there's no way to create a series of size 20.
And no, you don't have to create the series first.
If you have a vector of size 20 and a workfile of size 100, there's no way to create a series of size 20.
And no, you don't have to create the series first.
Re: mtos
Hi Glenn,
I've figured out what the issue is. I am pulling in a bunch of data - so at this point my range is set - so any series I declare has the same size as the data range.
I then do a movav on the series - now the series range has decreased by the window over which i am averaging.
I then get past this issue as I convert to matrix and remove all the NAs with the function @convert. I then do a bunch of stuff on the matrix.
At this point I try to go back to series and it can't cope as it is expecting a series of the length of the original data range.
So my question is: how do I tell it that it needs to look at a shorter range?
Sorry if this question is really basic!
thanks
I've figured out what the issue is. I am pulling in a bunch of data - so at this point my range is set - so any series I declare has the same size as the data range.
I then do a movav on the series - now the series range has decreased by the window over which i am averaging.
I then get past this issue as I convert to matrix and remove all the NAs with the function @convert. I then do a bunch of stuff on the matrix.
At this point I try to go back to series and it can't cope as it is expecting a series of the length of the original data range.
So my question is: how do I tell it that it needs to look at a shorter range?
Sorry if this question is really basic!
thanks
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: mtos
You're a little sparse on details, and I have no idea what you're asking.
Let me clear up some things.
First of all, as Glenn says, when using the stom command, the resulting vector/matrix will have number of rows equal to the number of non NA-observations in the source series under the current the workfile sample.
Same is true for @convert.
With mtos the source vector/matrix must have a number of rows less than or equal to the number of observations in the current workfile sample. If the number of rows is less than the current workfile sample, EViews will pad the rest with NAs.
Let me clear up some things.
First of all, as Glenn says, when using the stom command, the resulting vector/matrix will have number of rows equal to the number of non NA-observations in the source series under the current the workfile sample.
Same is true for @convert.
With mtos the source vector/matrix must have a number of rows less than or equal to the number of observations in the current workfile sample. If the number of rows is less than the current workfile sample, EViews will pad the rest with NAs.
Re: mtos
Apologies for asking you the same questions over and over – but I still don’t know how to solve the issue I am having. I'm obviously missing something.
I have pulled 10 time series from Bloomberg over a long time period. My time series are all of length x.
I then do a PCA over the group of time series over a rolling 240day window (win)
I store the PCA weights for the first 3 PCs in three separate matrices
The size of the matrices are (x-win, 10)
Using these weights only I re-compute the time series (estimated values).
I minus these estimated values from the original dataset. The size of this matrix, which I shall call differences, is (x-win, 10).
I want to calculate a moving average of these differences. I know that to use the function movav I need to apply it to a time series. So I columnextract the columns of the differences matrix and I try to make them into a timeseries with the mtos function so that I can apply the movav function to it.
At this point I get an error message as the vector size is x-win and the range size is x. The exact error message is “V1 is not the same length as the sample in “MTOS(V1, TESTSERIES1)”.
So my question is how do I re-declare the range of a series. I want to tell the program that my series size should now be (x-240), so the first date should be 240days after the first date in the series
Please could you give me an example of how to do this – i.e an example of where you manipulate some series in some way such that it's size changes, then store it as a vector and then try to put it back into a series so that you can compute a movav on it.
Apologies again if I am asking you the same thing as before! I know you said that eviews would just fill it with NAs, but I don't think it can do that because it doesn’t know where the NAs should be – I;e the first 240 entries, the last 240 or some other combination ….
Thanks again
I have pulled 10 time series from Bloomberg over a long time period. My time series are all of length x.
I then do a PCA over the group of time series over a rolling 240day window (win)
I store the PCA weights for the first 3 PCs in three separate matrices
The size of the matrices are (x-win, 10)
Using these weights only I re-compute the time series (estimated values).
I minus these estimated values from the original dataset. The size of this matrix, which I shall call differences, is (x-win, 10).
I want to calculate a moving average of these differences. I know that to use the function movav I need to apply it to a time series. So I columnextract the columns of the differences matrix and I try to make them into a timeseries with the mtos function so that I can apply the movav function to it.
At this point I get an error message as the vector size is x-win and the range size is x. The exact error message is “V1 is not the same length as the sample in “MTOS(V1, TESTSERIES1)”.
So my question is how do I re-declare the range of a series. I want to tell the program that my series size should now be (x-240), so the first date should be 240days after the first date in the series
Please could you give me an example of how to do this – i.e an example of where you manipulate some series in some way such that it's size changes, then store it as a vector and then try to put it back into a series so that you can compute a movav on it.
Apologies again if I am asking you the same thing as before! I know you said that eviews would just fill it with NAs, but I don't think it can do that because it doesn’t know where the NAs should be – I;e the first 240 entries, the last 240 or some other combination ….
Thanks again
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: mtos
Code: Select all
smpl @first @first+xwin-1
Who is online
Users browsing this forum: No registered users and 2 guests
