Help Needed to Get Program to Run Existing Workfile Data

For questions regarding programming in the EViews programming language.

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

bjonyou
Posts: 6
Joined: Wed Aug 08, 2012 4:06 pm

Help Needed to Get Program to Run Existing Workfile Data

Postby bjonyou » Thu Aug 09, 2012 8:24 am

Hello All,

This is probably a very basic question but I am new to EViews and have no coding experience. I have been running regression and have all my dependent and independent variables set up in a workfile. However, I just created and tried to run a program to alleviate the repetition but I'm getting an error message that states:

Workfile_Data is not defined in "DO_Workfile_Data.WF1d Q 1930 2014".

I have no clue what this means an what I'm doing wrong. Can anyone help me?

EViews Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby EViews Esther » Thu Aug 09, 2012 8:28 am

Can you see your workfile with your dataset of interest?

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

Help Needed to Get Program to Run Existing Workfile Data

Postby EViews Gareth » Thu Aug 09, 2012 8:37 am

Copy and paste your program (or at least the offending part) here.

bjonyou
Posts: 6
Joined: Wed Aug 08, 2012 4:06 pm

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby bjonyou » Thu Aug 09, 2012 8:38 am

Yes I have access to my worfile and dataset. I just can't get the program to run or link to it. At least I think thats the problem.

I dont know if the problem is occuring because I did something wrong when I created a new program or saved it to the wrong destination or what.

bjonyou
Posts: 6
Joined: Wed Aug 08, 2012 4:06 pm

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby bjonyou » Thu Aug 09, 2012 8:39 am

I grabbed this code from something you wrote or helped someone with.

Code: Select all

'create a workfile junb1_monthly_data.wf1 q 1930 2014 'create a dependent variable series cons_stap_pe_yoy = nrnd 'create 3 series series cpi_yoy = nrnd series avg_hrly_ernings_yoy = nrnd series savin_rate_yoy = nrnd %regs = "cpi_yoy avg_hrly_ernings_yoy savin_rate_yoy" !L = @wcount(%regs) 'create vector to store r-squares, AICs, BICs vector(2^!L) r2s vector(2^!L) aics vector(2^!L) bics svector(2^!L) specs 'create empty equation to be used inside the loop equation eq '1. Make an index vector which contains either 0 or 1 (Convert2Binary) '2. drop x if index=0, otherwise take x !rowcounter=1 'counter of how many equations we have run for !i = 0 to (2^!L)-1 vector(!L) index !temp= !i call Convert2Binary(index, !temp) %xs = "" for !j = 1 to !L %reg = @word(%regs,!j) if index(!j)==1 then %xs = %xs + %reg + " " endif next eq.ls y c {%xs} r2s(!rowcounter) = eq.@r2 aics(!rowcounter) = eq.@aic bics(!rowcounter) = eq.@schwarz specs(!rowcounter) = eq.@spec !rowcounter = !rowcounter+1 next d(noerr) index subroutine local Convert2Binary(vector out, scalar N) if N<0 then stop return endif !i = @rows(out) while N > 1 !a = @floor(N/2) out(!i) = N-2*!a !i = !i - 1 N = !a wend out(!i) = N endsub

EViews Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby EViews Esther » Thu Aug 09, 2012 8:42 am

Code: Select all

'create a workfile wfcreate junb1_monthly_data.wf1 q 1930 2014

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

Help Needed to Get Program to Run Existing Workfile Data

Postby EViews Gareth » Thu Aug 09, 2012 8:42 am

You're missing part of the first line. You need a create command in there.

bjonyou
Posts: 6
Joined: Wed Aug 08, 2012 4:06 pm

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby bjonyou » Thu Aug 09, 2012 8:54 am

You guys are GREAT! I may have more questions but THANK YOU!

bjonyou
Posts: 6
Joined: Wed Aug 08, 2012 4:06 pm

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby bjonyou » Thu Aug 09, 2012 9:36 am

I need some more help again guys.

I'm trying to combine two programs you have offered

1) Run lagging regressions through an interval (-12 to 12) and provide the lowest AIC (or best fitting model)

2) Store the AIC, R2, etc. in a matrix or vector.

So I essentially combined two different programs together and although it works fine, the AIC output is only storing two outputs and I cannot even tell which period the outputs are for.

The end goal is that I would like to see something like this:

-12 1.02
-11 1.01
-10 1.00
-9 .99
-8 .98
-7 .97
-6 .96

and then I would pick (-6) as it is the lowest AIC. Can you please help? Here is my code:
'create a workfile
wfcreate junb1_monthly_data.wf1 q 1930 2014

'create a variable
series cons_stap_pe_yoy = nrnd
series avg_hrly_ernings_yoy = nrnd

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

'variable to store the minimum AIC. Initialise it to a large number
!aic = 99999999

'variable saying how many lags to go up to
!maxlags = 12

'Variable to store the "best" number of lags
!bestlag = 0

'set sample to be the !maxlag'th value onwards
smpl @first+!maxlags @last

for !i=1 to !maxlags
eq.ls cons_stap_pe_yoy c avg_hrly_ernings_yoy(-12 to -!i) 'run regression of Y on a constant and lagged values of itself up to the iTH lag.
if eq.@aic < !aic then
!bestlag = !i 'if this lag specification has the best AIC, then store this lag as !bestlag.
!aic = eq.@aic
endif
next

show eq.ls cons_stap_pe_yoy c avg_hrly_ernings_yoy(12 to -!bestlag)

'reset sample
smpl @all

%regs = "avg_hrly_ernings_yoy"
!L = @wcount(%regs)

'create vector to store r-squares, AICs, BICs
vector(2^!L) r2s
vector(2^!L) aics
vector(2^!L) bics
svector(2^!L) specs

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

'1. Make an index vector which contains either 0 or 1 (Convert2Binary)
'2. drop x if index=0, otherwise take x
!rowcounter=1 'counter of how many equations we have run
for !i = 0 to (2^!L)-1
vector(!L) index
!temp= !i
call Convert2Binary(index, !temp)
%xs = ""
for !j = 1 to !L
%reg = @word(%regs,!j)
if index(!j)==1 then
%xs = %xs + %reg + " "
endif
next
eq.ls cons_stap_pe_yoy c {%xs}
r2s(!rowcounter) = eq.@r2
aics(!rowcounter) = eq.@aic
bics(!rowcounter) = eq.@schwarz
specs(!rowcounter) = eq.@spec
!rowcounter = !rowcounter+1
next
d(noerr) index

subroutine local Convert2Binary(vector out, scalar N)
if N<0 then
stop
return
endif
!i = @rows(out)
while N > 1
!a = @floor(N/2)
out(!i) = N-2*!a
!i = !i - 1
N = !a
wend
out(!i) = N
endsub

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

Re: Help Needed to Get Program to Run Existing Workfile Data

Postby EViews Glenn » Thu Aug 09, 2012 11:02 am

At some point you are going to have to debug these yourself, but...

!L = 1

This is why you are only getting 2 values. Your loop goes from 0 to 1.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests