Fluorite | Level 6

## Outputting 'state prediction' time series with Proc Model Switching regression

Hello, I have been working on US recession turning point analysis using LEI data, and I have run into a bit of a snag. One of the models I am working with is a Markov Switching model, seen here:

http://support.sas.com/documentation/cdl/en/etsug/66100/HTML/default/viewer.htm#etsug_model_sect277.... (I believe this is the most famous example of how to do this in SAS by far)

However this code only estimates the parameters of the equation in each state, as well as a series of tests to see if the parameters are significantly different between states. What I am looking for out of this model is a monthly time series output (I'm using monthly time series data) of which state it believes is active in a given month, so basically a series of regime/state probabilities. Is there any way to get this working in SAS?

3 REPLIES 3
SAS Employee

## Re: Outputting 'state prediction' time series with Proc Model Switching regression

Using the switching regression example in the PROC MODEL chapter you could output the predicted regime probabilities by using the following FIT and OUTVARS statemnt in place of the FIT statement in the example:

``````   fit starts / method=marquardt converge=1.0e-5 out=o;
outvars d;``````

The values of 'd' written to the ouput data set represent the predicted probabiltiy each observation is in regime 2.

Fluorite | Level 6

## Re: Outputting 'state prediction' time series with Proc Model Switching regression

Thanks, that worked perfectly. However, it brought another issue to my attention that I'm not sure how to solve.

For this Markov Switching model, I'm using LEI to predict whether or not the economy is in a recession, using the binary indicator provided by the NBER as a point of reference. Following the example I linked to, I ended up using the binary recession indicator to construct 'd'. But this is obviously an issue since my goal is to predict the state variable endogenously, rather than figure out the parameters in different states.If I am using the NBER indicator in my markov chain, which is the thing I'm trying to predict, then I'm not actually doing anything.

Would you know how I could set up this model in SAS to predict the state variable, ONLY using %change in the LEI (without referencing the NBER indicator?).

For reference, here is my code (mostly taken wholesale from the example):

```proc model data=revisedLEI_and_nber;
parms sig1=10 sig2=10 int1 int2;
bounds 0.0001 < sig1 sig2;

a = NBER_binary;
d = probnorm(a);

y1=int1;
y2=int2;

rtchglei = (1 - d)*y1 + d*y2;

logL = ((1/2)*( (log(2*3.1415)) +
log( (sig1**2)*((1-d)**2)+(sig2**2)*(d**2) )
+ (resid.rtchglei*( 1/( (sig1**2)*((1-d)**2)+(sig2**2)*(d**2) ) )*resid.rtchglei) ) );

errormodel rtchglei ~ general(logL);
fit rtchglei / method=marquardt converge=1.0e-5 out=o;
outvar d;

run;```

SAS Employee

## Re: Outputting 'state prediction' time series with Proc Model Switching regression

If I understand your question correctly you would just need to model 'a' using one or more parameters that are also estimated. In the original PROC MODEL example 'p' plays the role of this parameter.
Discussion stats
• 3 replies
• 822 views
• 0 likes
• 2 in conversation