MS Linear Regression with Time-varying TP

Discussion of models with structural breaks or endogenous switching.
turana

MS Linear Regression with Time-varying TP

Unread post by turana »

For my master thesis i want to conduct an analysis of asymmetries in mutual fund performance, and for that i what to estimate the following two state model (carhart 4 factor model) with maximum likelihood:


R= α + β ×〖MRK〗+ s ×〖SMB〗+ h ×〖HML〗+ p ×〖MOM〗+ e

where α, β, s, h, p, e are switching ( every coefficient and the variance). Alpha is the risk-adjusted performance in the two different regimes.

I have successfully estimated the model with fixed transition probabilities, and the result are sensible. I also want to estimate this model with time-varying transition probabilities, where the transitions is explained by the following two equations:

P= ϕ(d_1∆(CLI){2})
Q= ϕ(d_2∆(CLI){2})


where ϕ(.) is the cumulative normal distribution function. The transitions is explained by the 2 month lagged Composite Leading Indicator.

First i what to do this in an univariate setting, then in a multivariate setting where i have 3 equations (3 investments objectives).

This is done in Kosowski´s paper "Do mutual funds perform when it matters most to investors? US Mutual Fund Performance and Risk in Recessions and Expansions". The paper can be found on this link: http://papers.ssrn.com/sol3/papers.cfm? ... _id=926971

The intuition is to analyze whether mutual funds perform different in recessions and in expansions. Kosowski conclude that mutual funds perform better in recessions than in expansions.

I want to do a similar analysis in my master thesis. First of all, I am wondering if these estimations are possible in RATS, and if someone could help me a bit on the way? At the moment I am focusing on the univariate model ( value weighed portfolio of all funds in my database), but I´m a bit stuck when it comes to the coding of the the time-varying transition probabilities.

Appriciate all the help i can get :D
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: MS Linear Regression with Time-varying TP

Unread post by TomDoan »

Aren't you going to need an intercept in the two transition "index" functions? Otherwise, both are going to float around .5.

To do the TVTP, you need to override the %MSRegPMat function.

nonlin(parmset=tvtpparms) d10 d11 d20 d21
frml pfrml = %cdf(d10+d11*dcli{2})
frml qfrml = %cdf(d20+d21*dcli{2})
*
function %MSRegPMat time
type rect %MSRegPmat
type int time
*
compute %MSRegPMat=||pfrml(time),1-qfrml(time)|1-pfrml(time),qfrml(time)||
end

Provide guess values for the dxx variables (obvious choices are d11 and d21 = 0 and d10 and d20 back transformed from the probabilities from the fixed transition model). Estimate by maximum likelihood pretty much the same way as before, with tvtpparms replacing the fixed transition parameter set.
turana

Re: MS Linear Regression with Time-varying TP

Unread post by turana »

Hello,
thanks for the answer.

Im using the following code to estimate the model with fixed transition probabilities:

Code: Select all

OPEN DATA "/Users/Dropbox/30.7/rats ew.xls"
DATA(FORMAT=XLS,ORG=COLUMNS) 1 383 EW SMB HML PR1YR MRKT OSEAXMRKT CLI

*
@MSRegression(switch=ch,states=2) EW
# constant OSEAXMRKT SMB HML PR1YR
*
nonlin(parmset=regparms) betas gammas sigsqv
nonlin(parmset=msparms)  p
*
compute gstart=1,gend=383
@MSRegInitial gstart gend
*
* Compute a lower bound on the permitted values of the variance to
* prevent convergence to a zero-variance spike.
*
compute sigmalimit=1.e-6*%minvalue(sigsqv)
*
frml logl = f=%MSRegFVec(t),fpt=%MSProb(t,f),log(fpt)
@MSFilterInit
maximize(start=%(sigmatest=%MSRegInitVariances(),pstar=%msinit()),$
  parmset=regparms+msparms,$
  reject=sigmatest<sigmalimit,$
  method=bfgs,pmethod=simplex,piters=5) logl gstart gend

*
@MSSmoothed gstart gend psmooth
*
* Smoothed probabilities of the regimes
*
set p1smooth = psmooth(t)(1)
graph(footer="Smoothed Probabilities of Regime 1",max=1.0,min=0.0)
# p1smooth
*
do i=1,2
   disp "Conditional Mean for Regime" i $
     betas(i)(1)/(1-betas(i)(2)-betas(i)(3))
end do i


set p1smooth = psmooth(t)(2)
graph(footer="Smoothed Probabilities of Regime 2",max=1.0,min=0.0)
# p1smooth
*
do i=1,2
   disp "Conditional Mean for Regime" i $
     betas(i)(1)/(1-betas(i)(2)-betas(i)(3))
end do i
I´m not entirely sure if I´m doing it completely correct, but I get sensible results:

Code: Select all

MAXIMIZE - Estimation by BFGS
Convergence in    18 Iterations. Final criterion was  0.0000067 <=  0.0000100
Usable Observations                       383
Function Value                      1062.7312

    Variable                        Coeff      Std Error      T-Stat      Signif
************************************************************************************
1.  BETAS(1)(1)                  -0.000944521  0.000815868     -1.15769  0.24699118
2.  BETAS(1)(2)                   1.002195878  0.013415743     74.70297  0.00000000
3.  BETAS(1)(3)                   0.074097042  0.019507159      3.79845  0.00014560
4.  BETAS(1)(4)                  -0.062901130  0.015205589     -4.13671  0.00003523
5.  BETAS(1)(5)                  -0.019181077  0.020770100     -0.92349  0.35574947
6.  BETAS(2)(1)                   0.002714715  0.003589673      0.75626  0.44949525
7.  BETAS(2)(2)                   0.965499197  0.042096640     22.93530  0.00000000
8.  BETAS(2)(3)                   0.183029483  0.072309833      2.53118  0.01136782
9.  BETAS(2)(4)                  -0.003079186  0.071055485     -0.04333  0.96543453
10. BETAS(2)(5)                  -0.063278724  0.071775468     -0.88162  0.37798206
11. SIGSQV(1)                     0.000140489  0.000020925      6.71401  0.00000000
12. SIGSQV(2)                     0.000866426  0.000182261      4.75377  0.00000200
13. P(1,1)                        0.961610905  0.022631199     42.49050  0.00000000
14. P(1,2)                        0.162792625  0.058647937      2.77576  0.00550728
How do I implement time- varying transition probabilities in this model? I have tried to substitute this part of the code with what you wrote, but get an error:
nonlin(parmset=regparms) betas gammas sigsqv
nonlin(parmset=msparms) p

in my dataset I have already calculated the difference of the second lagged CLI. Could you please help me a bit on the code, Im new to RATS.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: MS Linear Regression with Time-varying TP

Unread post by TomDoan »

The calculation of the conditional means doesn't make sense in your model (that's just for an AR(1) with intercept only).

That result isn't atypical of a model with both coefficients and variance switching---whether it's your intention or not, the regimes are being identified mainly with changes of variance rather than mean models.

You want to use the TVTPPARMS parameter set rather than the MSPARMS parameter set when you estimate.
Have you looked at the Filardo JBES 1994 replication?
turana

Re: MS Linear Regression with Time-varying TP

Unread post by turana »

Thanks for answering. I do not quite understand what you mean. Is the model estimated wrong? i get exact(almost) same results if i estimate the model with fixed transitions in Eviews. I don´t use the calculation of the conditional means for anything, they are just there because i forgot to remove them when copying the code from another code.

is there anything wrong with this code?

Code: Select all

@MSRegression(switch=ch,states=2) excessEW
# constant ExcessOSEAX SMB HML PR1YR
*
nonlin(parmset=regparms) betas gammas sigsqv
nonlin(parmset=msparms)  p
*
compute gstart=1,gend=383
@MSRegInitial gstart gend
*
* Compute a lower bound on the permitted values of the variance to
* prevent convergence to a zero-variance spike.
*
compute sigmalimit=1.e-6*%minvalue(sigsqv)
*
frml logl = f=%MSRegFVec(t),fpt=%MSProb(t,f),log(fpt)
@MSFilterInit
maximize(start=%(sigmatest=%MSRegInitVariances(),pstar=%msinit()),$
  parmset=regparms+msparms,$
  reject=sigmatest<sigmalimit,$
  method=bfgs,pmethod=simplex,piters=5) logl gstart gend
regarding the regimes being identified with changes of the variance rather than mean. Is there any way i can improve upon this?


and for the model with TVTP I have written the following code:

Code: Select all

OPEN DATA "/Users/30.7/rats ew.xls"
DATA(FORMAT=XLS,ORG=COLUMNS) 1 383 EW SMB HML PR1YR MRKT OSEAXMRKT CLI CLI2 RCLI2


@MSRegression(switch=ch,states=2) EW
# constant OSEAXmrkt SMB HML PR1YR


nonlin(parmset=regparms) betas gammas sigsqv
nonlin(parmset=tvtpparms) d10 d11 d20 d21
frml pfrml = %cdf(d10+d11*rcli2)
frml qfrml = %cdf(d20+d21*rcli2)

compute d10=3.22
compute d20=-1.6375946


function %MSRegPMat time
type rect %MSRegPmat
type int time

compute %MSRegPMat=||pfrml(time),1-qfrml(time)|1-pfrml(time),qfrml(time)||
end

compute gstart=1,gend=383
@MSRegInitial gstart gend
*
* Compute a lower bound on the permitted values of the variance to
* prevent convergence to a zero-variance spike.
*
compute sigmalimit=1.e-6*%minvalue(sigsqv)
*
frml logl = f=%MSRegFVec(t),fpt=%MSProb(t,f),log(fpt)
@MSFilterInit
maximize(start=%(sigmatest=%MSRegInitVariances(),pstar=%msinit()),$
  parmset=regparms+tvtpparms,$
  reject=sigmatest<sigmalimit,$
  method=bfgs,pmethod=simplex,piters=5) logl gstart gend
From this code I do not get any result on the significance of the logistic index parameters. t-statistics are 0.00000000 for all the four parameters. What am I doing wrong here?

Appriciate all the help :D
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: MS Linear Regression with Time-varying TP

Unread post by TomDoan »

Use the procedure file I've attached below with the change shown to your LOGL definition.
msregression.src
Updated procedure file
(16.63 KiB) Downloaded 1292 times
frml logl = fpt=%MSRegProb(t),log(fpt)


There's nothing wrong with your fixed transition estimates. It's just that many people think they'll get regimes with very distinct regressions, when in many cases the main difference ends up being in the variances instead (and thus often rather different regimes than expected).
Post Reply