How to store beta coefficients from 700 cross-sections

For questions regarding programming in the EViews programming language.

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

divac
Posts: 10
Joined: Sun Jan 30, 2011 4:36 pm

How to store beta coefficients from 700 cross-sections

Postby divac » Sun Jan 30, 2011 5:08 pm

Hi,

I have the time series for 12 interest rates (700 obs each maturity). I would like to estimate each set of interest rates (e.g. maturities from 1month to 120months, think of it as a term structure) as a function of 3 variables (which might NOT vary over time) for each point in time (e.g. as if it is the 700 cross-section OLS estimations). The goal is to derive a time-series of coefficients from the 700 regression.

Suppose the model looks as follows:

Y c x1 x2

Below, I post an idea of how to do it for say two time periods, but it requires to create a two Y (Y1, Y2) and four X variables (X11, X12, X21, X22) for each time period (e.g. month 1 and month 2). The task will be very time consuming if I extend it to 700 repetitions.

Example for 2 data points

Code: Select all

'create vector where I suppose to store coefficients
vector(2) coefs

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

''counter of how many equations we have run
!rowcounter=1

'run pairwise regressions between each series
for !i=1 to 2
  !rowcounter = !i
  for !j=1 to 2
    if !i<>!j then
      equation eq{!i}.ls Y{!i} c X1{!i} X2{!i}
      coefs(!rowcounter)=eq{!i}.@coefs(2)
    endif
  next
next


As you can see I manage to store only one coefficient at the time.

The questions would be how to force Eviews to take consecutive set of interest rates, run OLS, store 3 (!) coefficients (const, beta1, beta2) as a time series? How appropriately input the data?

Many thanks,
divac

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

Re: How to store beta coefficients from 700 cross-sections

Postby EViews Gareth » Sun Jan 30, 2011 5:51 pm

Not sure I follow exactly the way your data is structured. Could you describe that in more detail?
Follow us on Twitter @IHSEViews

divac
Posts: 10
Joined: Sun Jan 30, 2011 4:36 pm

Re: How to store beta coefficients from 700 cross-sections

Postby divac » Tue Feb 01, 2011 7:12 am

The data example is attached. There are 12 interest rates (from 3months to 30 years). Together they represent a yield curve at each point in time. I would like to model the yield curve with two independent variables, say X1 and X2 using OLS. Then I would like to store a constant, beta1 and beta2 from each equation. E.g. for 1/4/1995 - const=8.2; beta1=-2.3; beta3=4.4, then in 1/11/1995 - const=7.2; beta1=-3.3; beta3=2.4 and so on in order to see coefficients' time variation.

Can you help with it given the code I started to form in the first post? Many thanks

Doc2.jpg
data
Doc2.jpg (142.17 KiB) Viewed 4426 times

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

Re: How to store beta coefficients from 700 cross-sections

Postby EViews Gareth » Tue Feb 01, 2011 8:50 am

How is it structured inside EViews?
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 48 guests