Estimation involved time trend

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

CySam
Posts: 21
Joined: Thu Mar 27, 2014 10:23 am

Estimation involved time trend

Postby CySam » Tue Feb 16, 2016 11:28 am

Hi, I have a question regarding to the estimation involving a time trend.
Let say I had estimated an equation and obtained all the coefficients of the variables such as:
equation.ls y c @trend y(-1)
Coefficients obtained: 0.3 for c; 0.5 for @trend; 1.2 for y(-1).

Now if I want to generate a series based on my estimated coefficients by specifying the equation as
y = 0.3 + 0.5*@trend + 1.2*y(-1).
Unfortunately, the eviews doesn't allow me to generate the series (or observation) mentioned that @trend is a reserved term.

My question is, if I want to generate observation based on my estimated equation, how should I specify in the equation, given that the coefficients information.

startz
Non-normality and collinearity are NOT problems!
Posts: 3796
Joined: Wed Sep 17, 2008 2:25 pm

Re: Estimation involved time trend

Postby startz » Tue Feb 16, 2016 11:39 am

Now if I want to generate a series based on my estimated coefficients by specifying the equation as
y = 0.3 + 0.5*@trend + 1.2*y(-1).
Unfortunately, the eviews doesn't allow me to generate the series (or observation) mentioned that @trend is a reserved term.
That command is perfectly legal in EViews. So there must be something else funky going on. Exactly what did you type and what error message did you get?

CySam
Posts: 21
Joined: Thu Mar 27, 2014 10:23 am

Re: Estimation involved time trend

Postby CySam » Tue Feb 16, 2016 11:55 am

Hi thank you for your reply.
Actually I am writing a program to help me generate series after I estimated an equation. I am working in this way:
First, I estimate an equation named "Equation" involved a constant, time trend and its lagged variable using least square:
Equation.ls y c @trend y(-1)
After I estimated and obtained the estimated coefficients such as
0.3 for c
0.5 for @trend
1.2 for y(-1)
and I save it.

Next, I try to generate series based on the information above:
for !i=1 to 50
y(!i) = 0.3 + 0.5*@trend + 1.2*y(!i-1)
next
But when come to this step, I was stopped by the program and telling me that @trend is a reserve term. Then I'm wondering am I wrong in the equation specification and thinking is there any other way for me to generate the series. Hope that my problem is clear for you now.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Estimation involved time trend

Postby EViews Gareth » Tue Feb 16, 2016 1:46 pm

As Startz mentioned, it is a perfectly legal command. Something else is going on. Post your entire program.

CySam
Posts: 21
Joined: Thu Mar 27, 2014 10:23 am

Re: Estimation involved time trend

Postby CySam » Wed Feb 17, 2016 1:03 am

Hi, below is my simple program. The program couldn't complete due to the problem I mentioned. Hope that you can help to resolve my problem. Thanks.

workfile test u 1000
series y = nrnd
series x = 0
equation estimate.ls y c @trend y(-1)

vector(3) coef
for !i=1 to 3
coef(!i) = estimate.@coefs(!i)
next

x(1) = y(1)
for !ic=2 to 1000
x(!ic) = coef(1) + coef(2)*@trend + x(!ic-1)
next

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Estimation involved time trend

Postby EViews Gareth » Wed Feb 17, 2016 1:22 am

You're working element by element inside your loop, but you're not accessing an element of @trend.

I think you just want:

Code: Select all

workfile test u 1000 series y = nrnd series x = 0 equation estimate.ls y c @trend y(-1) vector(3) coef for !i=1 to 3 coef(!i) = estimate.@coefs(!i) next x(1) = y(1) smpl 2 1000 x = coef(1) + coef(2)*@trend + x(-1)

Or, to make it much simpler:

Code: Select all

workfile test u 1000 series y = nrnd series x equation estimate.ls y c @trend y(-1) x(1) = y(1) smpl 2 1000 x = estimate.@coef(1) + estimate.@coef(2)*@trend + estimate.@coef(3)*x(-1)

CySam
Posts: 21
Joined: Thu Mar 27, 2014 10:23 am

Re: Estimation involved time trend

Postby CySam » Thu Feb 25, 2016 2:13 am

Thank you for your prompt. May I know is there possible to compile the series by generating its observation one by one using loop? This is because I intend to generate the series recursively in my program.

Example:
Given y = series y; x = series x; resids_y = residual y; resids_x = residual x

for !i=1 to 100
dy(!i) = coef(1) + coef(2)*@trend + coef(3)*y(!i-1) + coef(4)*x(!i-1) + resids_y
dx(!i) = coef1(1) + coef1(2)*@trend + coef1(3)*y(!i-1) + coef1(4)*x(!i-1) + resids_x

y(!i) = dy(!i) + y(!i-1)
x(!i) = dx(!i) + x(!i-1)
next

I need to generate the observation one by one in order to generate the series y and x properly.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Estimation involved time trend

Postby EViews Gareth » Thu Feb 25, 2016 7:42 am

I don't understand why you need a loop.

CySam
Posts: 21
Joined: Thu Mar 27, 2014 10:23 am

Re: Estimation involved time trend

Postby CySam » Thu Feb 25, 2016 9:39 am

Hi Gareth, because in the generation of series y there is a cross over with series x. In order to get the observation y, we need to first generate the ith observation of dy then only can generate ith observation of y. So in the generating process, I have to complete the whole process in order to get the ith observation.
Example for the program 1:
workfile test1 u 100
rndseed 12345
series resid_y = nrnd
series resid_x = nrnd

series y = 0
series x = 0
series dy = 0
series dx = 0

smpl 2 100
dy = y(-1) + x(-1) + resid_y
dx = y(-1) + x(-1) + resid_x

y = dy + y(-1)
x = dx + x(-1)

is different with the program 2:
workfile test2 u 100
rndseed 12345
series resid_y = nrnd
series resid_x = nrnd

series y = 0
series x = 0
series dy = 0
series dx = 0

for !i = 2 to 100
dy(!i) = y(!i-1) + x(!i-1) + resid_y(!i)
dx(!i) = y(!i-1) + x(!i-1) + resid_x(!i)

y(!i) = dy(!i) + y(!i-1)
x(!i) = dx(!i) + x(!i-1)
next

Both will generate different values for series y and x. Hope that you get my concerns and what I wanted to express. Thanks.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13586
Joined: Tue Sep 16, 2008 5:38 pm

Re: Estimation involved time trend

Postby EViews Gareth » Thu Feb 25, 2016 10:07 am

ok.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Estimation involved time trend

Postby EViews Glenn » Thu Feb 25, 2016 11:36 am

Simultaneous generation of several dynamic series is one of the things for which the model object is built:

Code: Select all

workfile test3 u 100 rndseed 12345 series resid_y = nrnd series resid_x = nrnd series y = 0 series x = 0 model a a.append dy = y(-1) + x(-1) + resid_y a.append dx = y(-1) + x(-1) + resid_x a.append y = dy + y(-1) a.append x = dx + x(-1) a.scenario "actuals" a.solve
Note that you can simplify the computation (at the expense of clarity) by folding the dy and dx equations into the y and x generating equations.

CySam
Posts: 21
Joined: Thu Mar 27, 2014 10:23 am

Re: Estimation involved time trend

Postby CySam » Wed Mar 02, 2016 11:02 pm

Ok, I got it now. Thanks lot for your efforts!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest