I would like to generate a series of the following formula:
v = 0.606 * v(-1) + e
e is simply the residual of a previous regression, which I can obtain from resid, but the problem with this formula is that it contains a lag of itself - the v(-1) term. Is there any programming code that can take care of this problem?
Thank you very much for your help.
- Eric
Generating a New Variable that Includes a Lag of Itself
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generating a New Variable that Includes a Lag of Itself
Well, you'll have to decide how you want to handle the problem mathematically before you can decide how to handle it programmatically.
What do you want the first value of v to be equal to?
What do you want the first value of v to be equal to?
Re: Generating a New Variable that Includes a Lag of Itself
The first value of v is equal to the first value of e
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generating a New Variable that Includes a Lag of Itself
Code: Select all
series v=e
smpl @first+1 @last
v=0.606*v(-1)+e
smpl @all
Re: Generating a New Variable that Includes a Lag of Itself
Thank you so much Gareth. I will try this soon and I expect it to work.
I had assumed that I needed a genr command. I am not familiar with the series command.
Also, would the code still work if I replaced the 0.606 with a coefficient from the last regression - c(3) or c(2) for example?
I had assumed that I needed a genr command. I am not familiar with the series command.
Also, would the code still work if I replaced the 0.606 with a coefficient from the last regression - c(3) or c(2) for example?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generating a New Variable that Includes a Lag of Itself
SERIES and GENR are interchangeable - they're the same command. It's a matter of personal preference that I use SERIES, but a lot of the others around here use GENR.
And yes, it would work if you replace 0.606 with c(1)
And yes, it would work if you replace 0.606 with c(1)
Re: Generating a New Variable that Includes a Lag of Itself
I just tested the code that you gave me and it just produced a vector of NA's. I think it may be due to the fact that the samples might be off. Here is the code that I used:
The first value of ehat is actually the fourth value in the total data set. Is there a way to correct for this in the code?
Code: Select all
smpl 1 42
genr lninvpc=log(invpc)
ls lninvpc c t
genr lninvpc_detrend=lninvpc-(c(1)+c(2)*t)
ls lninvpc_detrend c gprice lninvpc(-1) gprice(-1)
smpl 4 42
ls lninvpc_detrend c gprice lninvpc_detrend(-1) gprice(-1)
genr ehat=resid
genr vhat=ehat
smpl @first+1 @last
vhat=c(3)*vhat(-1)+ehat
smpl @all
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Generating a New Variable that Includes a Lag of Itself
change
to be
Code: Select all
smpl @first+1 @last
Code: Select all
smpl 5 42
Who is online
Users browsing this forum: No registered users and 2 guests
