Excel and EViews 8 with VBA code

For questions regarding programming in the EViews programming language.

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

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

Re: Excel and EViews 8 with VBA code

Postby EViews Gareth » Tue Jan 20, 2015 12:37 pm

ok, now we're getting somewhere.

All you need to do is add the code I provided above, then fetch the numbers back.

Just add these lines to your VBA:

Code: Select all

Dim Kurt
Dim Skew
app.Run "equation eq1.ARCH(DERIV=AA)  serie_1 C  AR(1)"
app.Run "scalar kurt = @kurt(resid)"
app.Run "scalar skew = @skew(resid)"
Kurt = app.Get("kurt")
Skew = app.Get("skew")

Cells(3, 7) = Kurt
Cells(4, 7) = Skew
Follow us on Twitter @IHSEViews

Ziller
Posts: 17
Joined: Tue Jan 13, 2015 7:41 am

Re: Excel and EViews 8 with VBA code

Postby Ziller » Tue Jan 20, 2015 1:07 pm

Thank you so much! I think it worked properlly!

I just need one more thing: using the same equation, calculate and then export to Excel the GARCH Variance Series.

One step to heaven! hahahaha...

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

Re: Excel and EViews 8 with VBA code

Postby EViews Gareth » Tue Jan 20, 2015 2:41 pm

The EViews command to make the garch series is:

Code: Select all

eq1.makegarch mygarch

You can then bring it back in with the VBA method app.getseries, as outlined in the whitepaper.
Follow us on Twitter @IHSEViews

Ziller
Posts: 17
Joined: Tue Jan 13, 2015 7:41 am

Re: Excel and EViews 8 with VBA code

Postby Ziller » Fri Jan 23, 2015 11:02 am

Hello! It´s me bothering you again...

Sorry!!! hahahaha

Using the codes I´m using, I´m not calculating the residual serie, is that correct?

I´d like to obtain kurtosis and skewness of the residual series. Is there a way to do that?

Another doubt I have: when running GARCH on Eviews 8, I´m obtaining results that are different than running it on EViews 6. So far, the only difference I could notice is that on EViews 8 the results are obtained after 54 iterations, and on EViews 6 are obtained after 13 iterations, as seen on the file attached.

I´ve checked all the options and did´nt found any configuration differences between those files. Does anybody knows what may be happening?

Thanks again!!!
Attachments
Differences.jpg
Differences.jpg (260.47 KiB) Viewed 7505 times

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

Re: Excel and EViews 8 with VBA code

Postby EViews Gareth » Fri Jan 23, 2015 11:13 am

EViews calculates the residuals automatically. So you don't need to.

Probably just improved algorithms between 6 and 8.
Follow us on Twitter @IHSEViews

Ziller
Posts: 17
Joined: Tue Jan 13, 2015 7:41 am

Re: Excel and EViews 8 with VBA code

Postby Ziller » Fri Jan 23, 2015 11:27 am

I´m calculating using the VBA code you sent me, like above:

app.Run "equation eq1boi_gordo.ARCH(DERIV=AA) boi_gordo C AR(1)"
app.Run "scalar kurt = @kurt(resid)"
app.Run "scalar skew = @skew(resid)"

Using this, @kurt is 4.702 and @skew is -0.1398.

Calculating manually, I follow these steps:

1) Clik on eq1;
2) Estimate > OK.
3) Proc > Make Residual Series - Select Standard - and then OK.
4) On the residual series (resid01, by default), the kustosis obtainded is 3.800 and skewness is 0.05.

What´s the difference between what I´m doing manually and the VBA?

Thanks!

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

Re: Excel and EViews 8 with VBA code

Postby EViews Gareth » Fri Jan 23, 2015 11:49 am

You're calculating the kurtosis and skewness of the standardised residuals, not the ordinary. Are you sure that's what you want to do?
Follow us on Twitter @IHSEViews

Ziller
Posts: 17
Joined: Tue Jan 13, 2015 7:41 am

Re: Excel and EViews 8 with VBA code

Postby Ziller » Fri Jan 23, 2015 12:00 pm

Yes, I need to calculate from standardized... Is there a way I could change the VBA and insert this parameter?

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

Re: Excel and EViews 8 with VBA code

Postby EViews Gareth » Fri Jan 23, 2015 12:14 pm

Code: Select all

eq1.makeresids(s) myresids
scalar kurt = @kurt(myresids)
scalar skew = @skew(myresids)
Follow us on Twitter @IHSEViews

Ziller
Posts: 17
Joined: Tue Jan 13, 2015 7:41 am

Re: Excel and EViews 8 with VBA code

Postby Ziller » Mon Jan 26, 2015 6:01 am

I think this will be my last doubt... THANK GOD and also THANK GARETH!!! hahahaha

All OK generating GARCH variance series and all stuff, but I´m having trouble with getseries.

The VBA I´m using is the following:

app.Run "eq1cafe.makegarch mygarch"
Set range_garch = Sheets("Dados").Range("O2:O507")
o = app.GetSeries("mygarch")
range_garch = o

What am I doing wrong?

Again, thank you so much!!!

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Excel and EViews 8 with VBA code

Postby EViews Steve » Mon Jan 26, 2015 9:25 am

GetSeries returns a 1-dimensional array. I believe Excel Range objects expect a 2-dimensional array.

I would suggest you read our COM Automation documentation located here:
http://www.eviews.com/download/whitepap ... mation.pdf

And pay particular attention to the GetGroup method that returns a 2-dimensional array. Here's an excerpt from Page 5:

Code: Select all

'Excel VBA Example – Retrieve series "x" and series "y" (along with the date labels) for date range 1980 thru 1990
Dim o
o = app.GetGroup("@date x y", "1980 1990", NATypeAsExcelNA)

Dim rows, cols As Integer
rows = UBound(o, 1) – LBound(o, 1) + 1 'number of rows in returned object
cols = UBound(o, 2) – LBound(o, 2) + 1 'number of columns in returned object

Dim wsht as Worksheet
Set wsht = ActiveSheet
Dim rng
Set rng = wsht.Range(wsht.Cells(1, 1), wsht.Cells(rows, cols))
rng.Value = o 'puts data into top left corner of sheet


Steve

oliveira83
Posts: 3
Joined: Fri Dec 22, 2017 10:58 am

Re: Excel and EViews 8 with VBA code

Postby oliveira83 » Fri Mar 09, 2018 6:08 am

If I have two pages on the same workfile how can I select one of them to get a group?

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

Re: Excel and EViews 8 with VBA code

Postby EViews Gareth » Fri Mar 09, 2018 6:15 am

Pageselect
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 21 guests