check code

For questions regarding programming in the EViews programming language.

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

Karen8169
Posts: 8
Joined: Thu Apr 28, 2016 8:10 pm

check code

Postby Karen8169 » Thu Apr 28, 2016 10:04 pm

‘Create a workfile undated, range 1 to 500.
!reps = 50000
for !i=1 to !reps
genr perturbacion{!i}=@nrnd
smpl 1 1
genr y{!i}=0
smpl 2 500
genr y{!i}=y{!i}(-1)+perturbacion{!i}
smpl 1 500
matrix(!reps,2) resultados
equation eq{!i}.ls D(y{!i})=c(1)*y{!i}(-1)
resultados(!i,1)=eq{!i}.@coefs(1)
resultados(!i,2)=eq{!i}.@tstats(1)
d perturbacion{!i}
d y{!i}
d eq{!i}
NEXT
‘Export “resultados” to Excel.
‘Create a workfile undated, range 1 to 50,000.
‘Copy and paste from Excel to the workfile.

All above are the code that I can paste to the eviews and run a Monte Carlo Experiment: A Dickey-Fuller Distribution.
Is anywhere need to be modified? Thanks a lot.

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

Re: check code

Postby trubador » Fri Apr 29, 2016 3:26 am

If you are not familiar with EViews, I suggest you to learn the basics before doing such complex analyses. Other than that, use the modified code below instead:

Code: Select all

wfcreate u 500 'create an undated workfile with 500 observations. !reps = 10000 'number of simulations matrix(!reps,2) resultados 'create a matrix to store the results series y 'create a blank series equation eq 'create an equation object smpl 2 500 'adjust the sample mode quiet 'run in quiet mode 'run the simulation for !i=1 to !reps y(1)=@nrnd 'randomly initialize the first value y=y(-1)+@nrnd 'generate a random walk sequence eq.ls D(y)=c(1)*y(-1) 'estimate the equation resultados(!i,1)=eq.@coefs(1) 'store the coefficients resultados(!i,2)=eq.@tstats(1) 'store the t-stats statusline !i of !reps 'monitor the progress NEXT delete y eq 'clean up if you like

Karen8169
Posts: 8
Joined: Thu Apr 28, 2016 8:10 pm

Re: check code

Postby Karen8169 » Mon May 02, 2016 4:59 am

Sorry,can I ask you basic equations?
How to define y and eq or where can I get related information? (I never use code on eviews before.)
Where can I see related information on youtube because most of videos just teach us how to click on youtube?
Thanks a million!!!

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

Re: check code

Postby trubador » Mon May 02, 2016 11:48 pm

Open a program window (File->New->Program), copy-and-paste the script and then hit Run. All the information produced will be stored in the workfile.

Karen8169
Posts: 8
Joined: Thu Apr 28, 2016 8:10 pm

Re: check code

Postby Karen8169 » Wed May 04, 2016 6:59 am

Can I ask you a few questions?
1."wfcreate u 500"
I know that "wfcreate u 500" means to create a new workfile called u,with 100 random data, but where is the workfile u when I run the code?

2.matrix(!reps,2) resultado
Why I have to create a matrix? Can it be a series?

3.Why can't I change the arrangement like that? What errors will be made?
series y
y(1)=0
y=y(-1)+nrnd
equation eq
eq.ls D(y)=c(1)*y(-1)
smpl 2 500
mode quiet

4.What the meaning of the arrangement?
series y
equation eq

5.What dose the "statusline" mean?
ThANK YOU!!

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

Re: check code

Postby EViews Gareth » Wed May 04, 2016 7:15 am

1. http://www.eviews.com/help/helpintro.ht ... reate.html

2. It is the wrong size to be a series.

3. Why don't you try it and see.

4. Create a series called Y. Create an equation called EQ

5. http://www.eviews.com/help/helpintro.ht ... sline.html


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests