Excel Example of an AR(1) Model from Eviews

For questions regarding programming in the EViews programming language.

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

medlo
Posts: 3
Joined: Tue Dec 16, 2008 2:43 pm

Excel Example of an AR(1) Model from Eviews

Postby medlo » Tue Dec 16, 2008 2:54 pm

Basic ? Anyone have an example of an excel implementation of EViews output of an AR(1) model that they can post? Thanks

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

Re: Excel Example of an AR(1) Model from Eviews

Postby EViews Gareth » Tue Dec 16, 2008 3:21 pm

I'm not sure I follow what you're asking. Are you asking if someone has an Excel example of the estimation of an AR(1) model? Or are you asking if someone has put EViews output into Excel (which seems like a trivial question)?
Follow us on Twitter @IHSEViews

medlo
Posts: 3
Joined: Tue Dec 16, 2008 2:43 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby medlo » Wed Dec 17, 2008 12:56 pm

yes an Excel example of an AR(1) thx

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

Re: Excel Example of an AR(1) Model from Eviews

Postby EViews Gareth » Wed Dec 17, 2008 12:57 pm

Again, are you asking of an example of Excel calculating an AR(1)?
Follow us on Twitter @IHSEViews

shhgc2
Posts: 5
Joined: Mon Dec 15, 2008 5:50 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby shhgc2 » Wed Dec 17, 2008 5:18 pm

I am not sure that I catched what you means. but you can use below inputcode and translate to excel.
Excel has a random generator.

Code: Select all

wfcreate AR a 1950 2000
'creating indepedent variable
series x=7*@sin(@trend+1)
'creating error term with N(0,1)
series u=nrnd
series e=u
'creating error term with ar(1) and rho is 0.85
'error term(u) =0.85*u(-1)+e
'creating dependent variable
series y=x+(0.85*u(-1)+e)

equation out1.ls y  x
show out1
equation out2.ls y  x ar(1)
show out2


trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby trubador » Thu Dec 18, 2008 2:59 am

As I understand, you are willing to build an AR(1) model in Excel and to compare the estimation results with those of EViews'. I believe you are trying to understand the underlying mechanism of AR estimations. Such exercises (both specification and estimation) are very difficult to be carried out in Excel, since it is a data-centric program. In other words, EViews assigns your time series data into a single variable, whereas Excel stores in cells.

There is a small difference in the code written by shhgc2. If you generate the series y = x + (0.85*u(-1)+e)) and estimate is as equation out2.ls y x ar(1) the results will be different than you expect, since the latter means you actually estimate y = c(1)*x + [ar(1) = c(2)]. Other than that, it is very useful and in the file attached you will find the Excel version this code. The only difference is that I preferred to include the c(1) coefficient and assigned 0.5 as its simulated value.

Please note that, estimation of the model in Excel requires Solver add-in. In worksheet, you will also find the output from EViews for comparison purposes.
AR1 example.xls
AR1 Example in Excel
(32.5 KiB) Downloaded 3363 times
Last edited by trubador on Thu Dec 18, 2008 11:58 pm, edited 2 times in total.

shhgc2
Posts: 5
Joined: Mon Dec 15, 2008 5:50 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby shhgc2 » Thu Dec 18, 2008 2:17 pm

That's good excel example. and a good explanation from trubador.
I just add some comments. in equation y = x + (0.85*u(-1)+e)), y = c(1)*x + [ar(1) = c(2)], My code is that c(1)=1 for simplifying the coefficient.
so, if you do simulation, you can easily find the c(1)=1. I also attached simulation code.


Code: Select all

wfcreate AR a 1950 2000
series x=7*@sin(@trend+1)

for !j= 1 to 1000

series u{!j}=nrnd
series e{!j}=u{!j}
series y{!j}=1*x+(0.85*u{!j}(-1)+e{!j})

equation out2{!j}.ls y{!j}  x ar(1)
series beta1(!j)=out2{!j}.@coef(1)

next

show beta1.stats


medlo
Posts: 3
Joined: Tue Dec 16, 2008 2:43 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby medlo » Fri Dec 19, 2008 3:43 pm

Many hanks for the insightful comments and for taking the time to respond. Happy Holidays all.

colden
Posts: 2
Joined: Tue Feb 17, 2009 4:51 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby colden » Tue Feb 17, 2009 5:16 pm

I am trying to recreate predicted values from an AR(1) model outputted by EViews using Excel. I found the Excel example posted here very helpful but I was wondering if someone could expand it to show how exactly EViews calculates its predicted values using the "Static Forecast" option. Specifically, I cannot arrive at EViews' predicted values using Excel and I believe it is because I am not understanding how the AR(1) term enters into the equation. Could someone please explain exactly how EViews arrives at its predicted values using actual numbers from the Excel example posted earlier in this thread? Thanks,

Chris Oldenburg
chris_oldenburg@hotmail.com

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

Re: Excel Example of an AR(1) Model from Eviews

Postby EViews Gareth » Tue Feb 17, 2009 5:39 pm

At some point over the next few days I might write up a more general explanation of how AR estimation/forecasting in EViews works, but for now, here's a program I have lying on my hard disk that should explain forecasting a simple ar:

Code: Select all

rndseed 1
create u 100
series x=nrnd
series y=nrnd

equation e1.ls y c x ar(1)

'Static Forecast

series restemp=y-c(1)-c(2)*x

smpl 20 100

e1.fit yhats1   'EViews fitted values  (static)

series yhats2=c(1)+c(2)*x+c(3)*restemp(-1)  'completely manual calculation



'Dynamic Forecast

e1.forecast yhatd1  'EViews fitted values (dynamic)

smpl 20 20
series yhatd2=c(1)+c(2)*x+c(3)*restemp(-1)   'manual calculation of first value

smpl 21 100
series yhatd2 = c(1)+c(2)*x+c(3)*(yhatd2(-1)-c(1)-c(2)*x(-1))  'manual calculation of other values.

smpl 20 100

show yhatd1 yhatd2
Follow us on Twitter @IHSEViews

colden
Posts: 2
Joined: Tue Feb 17, 2009 4:51 pm

Re: Excel Example of an AR(1) Model from Eviews

Postby colden » Wed Feb 18, 2009 11:18 am

Thank you for your program. I have used the data from the previous Excel example, estimated and forecasted using EViews, and then compared EViews' predicted values to those resulting from your calculation method. The two are slightly different, and the differences are too large to be due to rounding I think. Please see attached. Thanks,

Chris
Attachments
eViews Example.xls
(21 KiB) Downloaded 1575 times

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

Re: Excel Example of an AR(1) Model from Eviews

Postby EViews Gareth » Wed Feb 18, 2009 12:59 pm

Follow us on Twitter @IHSEViews

ar2
Posts: 2
Joined: Tue Aug 18, 2015 8:50 am

Re: Excel Example of an AR(1) Model from Eviews

Postby ar2 » Tue Aug 18, 2015 8:57 am

Hi folks,

The excel example for ar(1) forecast is truly helpful. It enabled us to build a tool to forecast the outcome based on various scenarios for the independent variables. I tried to expand the excel example to ar(2) cases without any success. Is there a similar excel example available when the equation includes ar(2)?

Thanks!
-John

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

Re: Excel Example of an AR(1) Model from Eviews

Postby EViews Gareth » Tue Aug 18, 2015 9:02 am

No, but it is a trivial extension.
Follow us on Twitter @IHSEViews

ar2
Posts: 2
Joined: Tue Aug 18, 2015 8:50 am

Re: Excel Example of an AR(1) Model from Eviews

Postby ar2 » Tue Aug 18, 2015 9:13 am

Can you possibly help build an example, Gareth? I have been using models without ar(2) due to implementation hurdle.

Actually the particular model has both ar(1) and ar(2) in the equation...

Thanks!
Last edited by ar2 on Tue Aug 18, 2015 9:33 am, edited 1 time in total.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests