An introduction to EViews programming.

For questions regarding programming in the EViews programming language.

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

eviews_user_2010
Posts: 4
Joined: Thu Jun 03, 2010 10:57 am

Re: An introduction to EViews programming.

Postby eviews_user_2010 » Tue Aug 31, 2010 2:32 pm

Hello,

I like to modify the code below (it's one of the sample programs) to include the names of the depedent and independent variables of the regressions and to store these names in the vector/matrix output. For example, the first regression would be EQ_GDP_UNEMP. I would appreciate any help. Thanks. Dan




'create a workfile
wfcreate q 1990 2010

'create a group which will contain the xs
group xs

'create 5 series
for %i GDP UNEMP INFL CPI M1
series {%i}=nrnd
xs.add {%i}
next

'create vector to store r-squares
vector(10) r2s

'create empty equation to be used inside the loop
equation eq

''counter of how many equations we have run
!rowcounter=1

'run pairwise regressions between each series
for !i=1 to xs.@count-1
%iname = xs.@seriesname(!i)
for !j=!i+1 to xs.@count
%jname = xs.@seriesname(!j)
eq.ls {%iname} c {%jname}
r2s(!rowcounter) = eq.@r2
!rowcounter = !rowcounter+1
next
next

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Tue Aug 31, 2010 2:45 pm

Code: Select all

'create a workfile
wfcreate q 1990 2010

'create a group which will contain the xs
group xs

'create 5 series
for %i GDP UNEMP INFL CPI M1
series {%i}=nrnd
xs.add {%i}
next

'create vector to store r-squares
vector(10) r2s

'create empty equation to be used inside the loop
equation eq

''counter of how many equations we have run
!rowcounter=1

table equation_vars

'run pairwise regressions between each series
for !i=1 to xs.@count-1
%iname = xs.@seriesname(!i)
for !j=!i+1 to xs.@count
%jname = xs.@seriesname(!j)
eq.ls {%iname} c {%jname}
r2s(!rowcounter) = eq.@r2
equation_vars(!i,1) = %iname
equation_vars(!i,2) = %jname
!rowcounter = !rowcounter+1
next
next


something along those lines.
Follow us on Twitter @IHSEViews

eviews_user_2010
Posts: 4
Joined: Thu Jun 03, 2010 10:57 am

Re: An introduction to EViews programming.

Postby eviews_user_2010 » Wed Sep 22, 2010 8:29 am

Thanks E-view Gareth for your suggestion.

I've implemented a modified version of your suggestion into my code (please see below). This code, based on one of your examples, is to run regressions with every single possible combination of the independent variables using the same dependent variable, which is a lot like a piecewise linear regression, but this code will generate a table of all the possible combinations.

Currently, I'm trying to improve the code so that it would capture the t-statistics for the independent variables, including the constant. From perusing this website and other posts, it seems that I need to use @coef, but I'm not sure the exact syntax for t-statitiscs.

One other feature of interest is to be able to generate the foor loop automatically. I might have over 100 possible independent variables, which means with this program I would need 100 loops. It would be a nice feature if it could automatically generate the additional foor loops.

Thanks a lot,



wfcreate q 1990 2010

series GDP = nrnd

group xs
for %i UNEMP INFL CPI
series {%i} = nrnd
xs.add {%i}
next

vector(25) r2s

equation eq

!rowcounter=1

table equation_vars

for !i=1 to xs.@count
%iname = xs.@seriesname(!i)
eq.ls d(GDP) c d({%iname})
r2s (!rowcounter) = eq.@r2
equation_vars(!rowcounter) = "GDP"
equation_vars(!rowcounter, !i+1) = %iname
!rowcounter = !rowcounter+1

for !j=!i+1 to xs.@count
%jname = xs.@seriesname(!j)
eq.ls d(GDP) c d({%iname}) d({%jname})
r2s(!rowcounter) = eq.@r2
equation_vars(!rowcounter) = "GDP"
equation_vars(!rowcounter, !i+1) = %iname
equation_vars(!rowcounter, !j+1) = %jname
!rowcounter = !rowcounter+1

for !k= !j+1 to xs.@count
%kname = xs.@seriesname(!k)
eq.ls d(GDP) c d({%iname}) d({%jname}) d({%kname})
r2s (!rowcounter) = eq.@r2
equation_vars(!rowcounter) = "GDP"
equation_vars(!rowcounter, !i+1) = %iname
equation_vars(!rowcounter, !j+1) = %jname
equation_vars(!rowcounter, !k+1) = %kname
!rowcounter = !rowcounter+1

next
next
next

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Wed Sep 22, 2010 9:49 am

You can use @tstats to obtain the t-statistics from an equation.

Something similar to this:
viewtopic.php?f=15&t=878

but rather than using @coefs to store the coefficients, use @tstats to store the t-statistics.
Follow us on Twitter @IHSEViews

eviews_user_2010
Posts: 4
Joined: Thu Jun 03, 2010 10:57 am

Re: An introduction to EViews programming.

Postby eviews_user_2010 » Wed Sep 22, 2010 11:41 am

Thanks a lot Eviews_Garenth. I was just about to post a message that I found out that I could capture the tstats using @tstat.

Do you happen to know how to create an automatic additional loop to account for additional independent variables in the group as shown in below code? The number of loops in this code depends on the number of variables in the xs group. Is there a way to create a program to automatically generate a loop for each independent variable?

wfcreate q 1990 2010

series GDP = nrnd

group xs
for %i UNEMP INFL CPI
series {%i} = nrnd
xs.add {%i}
next

vector(7) r2s
table equation_vars
table tstats

equation eq

!rowcounter=1
!columncounter =1

for !i=1 to xs.@count
%iname = xs.@seriesname(!i)
eq.ls d(GDP) c d({%iname})
r2s (!rowcounter) = eq.@r2
tstats(!rowcounter) = "N/A"
tstats(!rowcounter, !columncounter+1) = eq.@tstat(!columncounter)
tstats(!rowcounter, !columncounter+2) = eq.@tstat(!columncounter+1)
equation_vars(!rowcounter) = "GDP"
equation_vars(!rowcounter, !columncounter+1) = "C"
equation_vars(!rowcounter, !columncounter+2) = %iname
!rowcounter = !rowcounter+1

for !j=!i+1 to xs.@count
%jname = xs.@seriesname(!j)
eq.ls d(GDP) c d({%iname}) d({%jname})
r2s(!rowcounter) = eq.@r2
tstats(!rowcounter) = "N/A"
tstats(!rowcounter, !columncounter+1) = eq.@tstat(!columncounter)
tstats(!rowcounter, !columncounter+2) = eq.@tstat(!columncounter+1)
tstats(!rowcounter, !columncounter+3) = eq.@tstat(!columncounter+2)
equation_vars(!rowcounter) = "GDP"
equation_vars(!rowcounter, !columncounter+1) = "C"
equation_vars(!rowcounter, !columncounter+2) = %iname
equation_vars(!rowcounter, !columncounter+3) = %jname
!rowcounter = !rowcounter+1

for !k= !j+1 to xs.@count
%kname = xs.@seriesname(!k)
eq.ls d(GDP) c d({%iname}) d({%jname}) d({%kname})
r2s (!rowcounter) = eq.@r2
tstats(!rowcounter) = "N/A"
tstats(!rowcounter, !columncounter+1) = eq.@tstat(!columncounter)
tstats(!rowcounter, !columncounter+2) = eq.@tstat(!columncounter+1)
tstats(!rowcounter, !columncounter+3) = eq.@tstat(!columncounter+2)
tstats(!rowcounter, !columncounter+4) = eq.@tstat(!columncounter+3)
equation_vars(!rowcounter) = "GDP"
equation_vars(!rowcounter, !columncounter+1) = "C"
equation_vars(!rowcounter, !columncounter+2) = %iname
equation_vars(!rowcounter, !columncounter+3) = %jname
equation_vars(!rowcounter, !columncounter+4) = %kname
!rowcounter = !rowcounter+1

next
next
next

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

An introduction to EViews programming.

Postby EViews Gareth » Wed Sep 22, 2010 11:47 am

I don't understand the question. Perhaps you could make a smaller, easier example if what you're trying to do.
Follow us on Twitter @IHSEViews

puf
Posts: 22
Joined: Sun Jan 09, 2011 4:26 pm

Re: An introduction to EViews programming.

Postby puf » Thu Jan 13, 2011 1:19 pm

Hi,
want to estimate GARCH(1,1) model for the variable retx (stock return). I found that I can do it using command

equation eq.ARCH(1,1) retx

Similarly, I can get the coefficients using commands

scalar omega = eq.c(1)
scalar alpha = eq.c(2)
scalar beta = eq.c(3)

However, I have no idea how to get p-values of these coefficients. Is there a general rule how to get different estimetes (e.g. coefficients, their p-values, Rsquared, AIC,...) from an estimated equation? If yes, please tell me about it, if not, is there a list of variables which can be obtained from an estimated equation?

thank you

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

An introduction to EViews programming.

Postby EViews Gareth » Thu Jan 13, 2011 1:51 pm

Look at the start of the equation section of the object reference. It lists all equation data members.
Follow us on Twitter @IHSEViews

roteirofigo
Posts: 5
Joined: Tue Jul 19, 2011 2:02 pm

Re: An introduction to EViews programming.

Postby roteirofigo » Wed Jul 20, 2011 10:46 am

How can I store the coefficients with the highest R-squares?

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

Re: An introduction to EViews programming.

Postby EViews Gareth » Wed Jul 20, 2011 10:50 am

A coefficient doesn't have an R-squared, so I'm not sure I understand the question.
Follow us on Twitter @IHSEViews

Hottax
Posts: 4
Joined: Tue Aug 09, 2011 1:13 am

Re: An introduction to EViews programming.

Postby Hottax » Thu Aug 11, 2011 7:43 am

I really a beginner in EViews program..please help me how to create different series below (by using EViews7)

1. Create a series X1 whose element satisfy
- the number of elements is 100
- all alements are zero

2. Create a series X2 of size 100 with the first element is being 1, the second is 2, the third is 3,...,the last is 100
3. Create a series X3 of size 100 with the first element is being 2, the second is 4, the third is 6,...,the last is 200
4. Create a series X4 with each element being the logarithm value of the corresponding element of X1. and how to graph series X1 against and X4
(X1 Horizontal axis and X4 Vertical axis)..

is it different with EViews 6 or not?



thank you very much.

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

Re: An introduction to EViews programming.

Postby startz » Thu Aug 11, 2011 7:52 am

You might want to start by reading the free chapters of EViews Illustrated posted at http://www.eviews.com/illustrated/illustrated.html.

Hottax
Posts: 4
Joined: Tue Aug 09, 2011 1:13 am

Re: An introduction to EViews programming.

Postby Hottax » Thu Aug 11, 2011 8:30 am

Thank you for your quick reply..I understand now how to solve and create series X1-X3...and about series X4, is it ok if I just put it this way series X4 = log series x1

thank you..

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

Re: An introduction to EViews programming.

Postby startz » Thu Aug 11, 2011 8:57 am

Just series x4 = log(x1)

Hottax
Posts: 4
Joined: Tue Aug 09, 2011 1:13 am

Re: An introduction to EViews programming.

Postby Hottax » Fri Aug 12, 2011 1:42 am

Please help me again, how to draw a graph with the function : f(x) = x^3 + 2x^2 - x + 4
Can I draw the graph directly by using EViews program (6 or 7 version)..or firstly I compute in Excel and then copy it to EViews?

Thanks a lot..


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 25 guests