if-statement in a loop

For questions regarding programming in the EViews programming language.

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

Anders
Posts: 1
Joined: Fri Oct 21, 2016 3:29 am

if-statement in a loop

Postby Anders » 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

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

Re: if-statement in a loop

Postby startz » Fri Oct 21, 2016 7:21 am

The first part is

Code: Select all

smpl if number=1 ls return c index


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests