Loop and Store from Regression

For questions regarding programming in the EViews programming language.

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

sonja11
Posts: 3
Joined: Mon Dec 12, 2011 3:08 am

Loop and Store from Regression

Postby sonja11 » Mon Dec 12, 2011 3:19 am

Hey, I'm absolutely new in Programming, so please help me :)

I need each month Regression Coefficients in one series.
My time series is from 1980 to 2011 and I need to make a Regressionanalysis each month (so my first sample is from 1980m1 to 2011 m1; the next sample will be from 1980 m1 to 2010 m12.....)and store the betas of each sample.

I already read the topics about my problem, but I didn't get it :/

So pleeease help me :)

sonja11
Posts: 3
Joined: Mon Dec 12, 2011 3:08 am

Re: Loop and Store from Regression

Postby sonja11 » Mon Dec 12, 2011 7:41 am

maybe I have to be more detailed...

my regression is of the form:

equation b2.ls logrx2(+12) c (gamma1+gamma2*logy1+gamma3*logf2+gamma4*logf3+gamma5*logf4+gamma6*logf5)

same for
equation b3.ls logrx3(+12)...
equation b4.ls logrx4(+12)...
equation b5.ls logrx5(+12)...


time horizon is 1996m1 2011m12 (192 obs)

--------------------------------------------------------------------------

this will give me the regression coefficients for 2011m12... i do also need it for each month before: 2011m11, 2011m10.....1996m1

the best would be to make a matrix with the coefficients.

anybody able to help me now?

THANK YOU

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

Re: Loop and Store from Regression

Postby EViews Gareth » Mon Dec 12, 2011 8:44 am

What have you done so far, and have you read the programming guide?

sonja11
Posts: 3
Joined: Mon Dec 12, 2011 3:08 am

Re: Loop and Store from Regression

Postby sonja11 » Wed Dec 14, 2011 3:00 am

' set window size
!window = 10

' get size of workfile
!length = @obsrange

'----------------------------------------------
'Notation
'----------------------------------------------

'yield

series y1=@movav(zero1y,3)/100
series y2=@movav(zero2y,3)/100
series y3=@movav(zero3y,3)/100
series y4=@movav(zero4y,3)/100
series y5=@movav(zero5y,3)/100

'preis

series P1=1/((1+y1)^1)
series P2=1/((1+y2)^2)
series P3=1/((1+y3)^3)
series P4=1/((1+y4)^4)
series P5=1/((1+y5)^5)

'Logarithmierung der Preise:
series logp1=log(P1)
series logp2=log(P2)
series logp3=log(P3)
series logp4=log(P4)
series logp5=log(P5)

'Erstellung der log-Yields aus log-Preisen:
series logy1=-(1/1)*logp1
series logy2=-(1/2)*logp2
series logy3=-(1/3)*logp3
series logy4=-(1/4)*logp4
series logy5=-(1/5)*logp5

'Erstellung der Forwards:
series logf2=logp1-logp2
series logf3=logp2-logp3
series logf4=logp3-logp4
series logf5=logp4-logp5

'Erstellung der Returns:
series logr2(+12)=logp1(+12)-logp2
series logr3(+12)=logp2(+12)-logp3
series logr4(+12)=logp3(+12)-logp4
series logr5(+12)=logp4(+12)-logp5

'Erstellung der Excess Returns:
series logrx2(+12)=logr2(+12)-logy1
series logrx3(+12)=logr3(+12)-logy1
series logrx4(+12)=logr4(+12)-logy1
series logrx5(+12)=logr5(+12)-logy1

'average excess return

series rxavg=(logrx2+logrx3+logrx4+logrx5)/4

' declare matrix to store results
matrix(!length-!window+1,5) rff

' compute stats for each window
for !i = 1 to !length-!window+1
smpl @first+!i-1 @first+!i+!window-2

equation cpavg.ls rxavg(+12) c logy1 logf2 logf3 logf4 logf5

' store coeff in matrix
rff(!i,1) = c(2)
rff(!i,2) = c(3)
rff(!i,3) = c(4)
rff(!i,4) = c(5)
rff(!i,5) = c(6)

next



why isn't it working...?

I get: Insufficient number of observations in "equation cpavg.ls rxavg(+12) c logy1 logf2 logf3 logf4 logf5"

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

Re: Loop and Store from Regression

Postby EViews Gareth » Wed Dec 14, 2011 8:49 am

You probably don't have enough observations available to estimate that equation. Perhaps you have NAs?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests