Page 1 of 1

Help with rolling regression

Posted: Thu Dec 10, 2020 3:38 pm
by AdamElderfield
Hi,

I am trying to do a rolling regression to find reasonable guess values for a Deibold and Li style dynamic factor model. I have a vector of "times to maturity" which I have creates as follows:

Code: Select all

dec vect tau(7) 
dofor tenor = 40 1 4 4 8 1 8
 compute tau(%doforpass) = tenor
end dofor tenor
Then I want to run the following regression

Code: Select all

compute lambda1 = 0.06
nonlin b1 b2
frml ns = constant+b1*(1-exp(-lambda1*tau))/(lambda1*tau)+b2*((1-exp(-lambda1*tau))/(lambda1*tau)-exp(-lambda1*tau))

do i= 1, %nobs
  nlls(frml = ns) %eqnxvector(yvars,i)
end do i

Where yvars here is Tx7 matrix of yields. What I am trying to do is loop through time and run a regression of yvars on tau, and tau is transformed bases on the expressions above. However, I get the following error when executing the frml instruction:

Code: Select all

Can't Find Match for EXP(MATRIX[REAL]). Possibilities are EXP(REAL)
## SX27. Illegal Combination of Data Types for Operation
>>>>1-exp(-lambda1*tau)<<<<


The error message is rather informative, however, I don't know how to go about resolving it.

Note, I am aware that I don't need to use nlls here and can use the linreg instruction - I still get the same error when trying to compute or set the exogenous variables.

Any suggestions?

Adam

Re: Help with rolling regression

Posted: Thu Dec 10, 2020 6:13 pm
by TomDoan
If I understand you correctly, then neither LINREG, nor NLLS is the correct estimation procedure. You have seven dependent variables, so you need to be using a system estimator---probably NLSYSTEM. Also, you probably have some error in your FRML definition, as b1 and b2 are multiplying the same function.

The error comes up because the FRML is supposed to be evaluating to a single real, but TAU is a seven-vector. You need to define a VECT[FRML] with 7 elements; one for each of the elements of Y (and TAU). See

https://estima.com/docs/RATS%2010%20Use ... df#page152

for how to define those.

Re: Help with rolling regression

Posted: Thu Dec 10, 2020 9:41 pm
by AdamElderfield
Thanks Tom - I actually think what I am trying to do here is estimate a cross section regression at each point in time. So, rather than 7 dependent variables I have 7 observations in the Y vector, and 7 observations for each regressor (a constant, the first term (1-exp(-lambda1*tau))/(lambda1*tau) and the second term ((1-exp(-lambda1*tau))/(lambda1*tau)-exp(-lambda1*tau))).

The authors of the original paper, linked below, then uses these results in an VAR(1) and an AR(1). I'd like to do the same, and then use these results as my initial values for the state space model.

Paper:
https://www.sas.upenn.edu/~fdiebold/pap ... old-Li.pdf

Also below is a MATLAB example of what I am trying to do

https://au.mathworks.com/help/econ/usin ... model.html

Thanks for the tip regarding VECT[FRML] I'll take a look, looks like something pretty important to get across :)

Re: Help with rolling regression

Posted: Fri Dec 11, 2020 10:41 am
by TomDoan
Sorry, I missed the nesting on the parentheses in your FRML. So this is estimating a 3 regressor linear regression at each point in time using 7 observations? That seems a bit dicey.

Re: Help with rolling regression

Posted: Fri Dec 11, 2020 6:25 pm
by AdamElderfield
Yes - I completely agree. I'm actually trying to fit this model to inflation expectations, rather than yields data. Unfortunately, there isn't nearly as much data on inflation expectations in Australia as there are yields. Hopefully I can get more, but I doubt I will expand Y beyond say 10.

So yes, dicey. But probably a little more informative than guess values for DLM, no? In any case, would VECT[FRML] be the way to do this?