if-statement in a loop
Posted: Fri Oct 21, 2016 3:45 am
Hey
I am very new i the Eviews framework, so I hope you will help me. I am using Eviews9
I have these series: Number, Return and Index
Number, return, index is like:
1 0,04 0,032
3 0,1 0,094
2 -0,2 -0,031
1 0,05 0,021
2 -0,12 -0,01
And so on, down to row 331
The i want to make the regression but only when Number is equal 1:
ls return c index
And then i want store the beta values in a matrix.
I have tried the following code:
for !i = 1 to 331 'Number of firms with a return and index
smpl @all
matrix(331,2) beta 'Create a matrix called beta to store the value of estimation
if Number=1 then
smpl 13 220 'Take the rows with values in
equation mm.ls afkast c indeks
mm.makeresids resid01
beta(!i,1) = c(1)
beta(!i,2) = c(2)
delete comp index afkast indeks resid01
endif
next
This give me a matrix(331,2) and the right numbers but also a lot of rows with zero.
Thanks for your help.
/Anders
I am very new i the Eviews framework, so I hope you will help me. I am using Eviews9
I have these series: Number, Return and Index
Number, return, index is like:
1 0,04 0,032
3 0,1 0,094
2 -0,2 -0,031
1 0,05 0,021
2 -0,12 -0,01
And so on, down to row 331
The i want to make the regression but only when Number is equal 1:
ls return c index
And then i want store the beta values in a matrix.
I have tried the following code:
for !i = 1 to 331 'Number of firms with a return and index
smpl @all
matrix(331,2) beta 'Create a matrix called beta to store the value of estimation
if Number=1 then
smpl 13 220 'Take the rows with values in
equation mm.ls afkast c indeks
mm.makeresids resid01
beta(!i,1) = c(1)
beta(!i,2) = c(2)
delete comp index afkast indeks resid01
endif
next
This give me a matrix(331,2) and the right numbers but also a lot of rows with zero.
Thanks for your help.
/Anders