Hi all,
I've two series X1 and X2 and want to create a new series X2_EXT with all NAs in X2 filled in using the growth rates obtained from X1.
For instance in the example below, the NA at time T2 in X2 would be replaced by 60*(90/95) = 5.7 in X2_EXT.
What makes things a bit more complicated is the fact that I have many pairs of data series like X1 and X2 in the same workfile and all these X2's have NAs at different dates. So, in order to create X2_EXT from each pair of X1 and X2, I also also need to figure out a way to identify the dates with NAs in each X2.
Any suggestion would be much appreciated.
Morak
Date X1 X2 X2_EXT
T1 100 NA 5.1
T2 90 NA 5.7
T3 95 6.0 6.0
T4 88 5.6 5.6
T5 70 NA 4.4
T6 83 NA 5.2
T7 66 NA 4.2
How to extend a data series using growth rates from another
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to extend a data series using growth rates from anot
Where did the 60 come from?
Re: How to extend a data series using growth rates from anot
Sorry, I meant 6. That is, 6*(90/95) = 5.7, where 6 is the date T3 value of X2.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to extend a data series using growth rates from anot
Something like:
Although, in your example you're out of luck for the last three observations, since you don't have an end value to compute from.
Code: Select all
series x2_ext = x2
smpl if x2=na
genr(r) x2_ext = x1/x1(1)*x2_ext(1)
Re: How to extend a data series using growth rates from anot
Hi Gareth,
Many thanks for the suggestion. Unfortunately, it didn't do the trick.
I'm attaching a sample workfile as an example. It contains two similar but slightly US GDP series over the period of 1970 to 2011 (x1 and x2). X1 has values ranging from 1970 to 2011, while X2 from 1980 to 2011. What I'd like to do is to create a new series X2_EXT that is extended back to 1970 using the annual growth rates of X1 over 1970 - 1979. For example, the code below produces the value of x2_ext for the year 1979, but only back to 1979, and not all way back to 1970.
Many thanks for the suggestion. Unfortunately, it didn't do the trick.
I'm attaching a sample workfile as an example. It contains two similar but slightly US GDP series over the period of 1970 to 2011 (x1 and x2). X1 has values ranging from 1970 to 2011, while X2 from 1980 to 2011. What I'd like to do is to create a new series X2_EXT that is extended back to 1970 using the annual growth rates of X1 over 1970 - 1979. For example, the code below produces the value of x2_ext for the year 1979, but only back to 1979, and not all way back to 1970.
Code: Select all
series x2_ext = x2
smpl 1970 1980
series x2_ext(-1) = (1-@pch(x1(-1)))*x2_ext
- Attachments
-
- test.wf1
- (8.78 KiB) Downloaded 299 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to extend a data series using growth rates from anot
Did you try the code I posted. It appears to work just fine.
Re: How to extend a data series using growth rates from anot
Yes, Gareth. But your code also extends x2 only back to 1979, not all way to 1970.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to extend a data series using growth rates from anot
Not for me, it goes all the way back for me.
Which version of EViews are you using?
Which version of EViews are you using?
Re: How to extend a data series using growth rates from anot
Mine is Version 7.2
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to extend a data series using growth rates from anot
(there's a reason we ask you to state the version number in every post on the forum...).
Doesn't work in EViews 7. You'll have to upgrade to 8, or calculate them one by one in a for loop.
Doesn't work in EViews 7. You'll have to upgrade to 8, or calculate them one by one in a for loop.
Re: How to extend a data series using growth rates from anot
Aha! I see. Many thanks, Gareth.
As for the loop, I'm thinking about using the while loop with the number of NAs in x2_ext as the control. In other words, run while # of NAs in X2_ext > 1. Is there a command for counting the # of NAs in this case?
As for the loop, I'm thinking about using the while loop with the number of NAs in x2_ext as the control. In other words, run while # of NAs in X2_ext > 1. Is there a command for counting the # of NAs in this case?
Who is online
Users browsing this forum: No registered users and 2 guests
