ms_reg — Markvov Switching regression model
r=ms_reg(endo,exo_com,exo_idio,MS_M,MS_M_V,MS_var_opt,arg1, ,argn)
endo =
- either: (T x K) string matrix of endogenous variables
- or: a list containing all the endogenous variables in any of the following form:
* a time series
* a real matrix
* a string representing such objects
* the string 'const' (for the constant variable)
exo_com =
- either: (T x K) string matrix of non switching exogenous variables
- or: a list containing all the non switching exogenous variables in any of the following form:
* a time series
* a real matrix
* a string representing such objects
* the string 'const' (for the constant variable)
exo_idio =
-either: (T x K) string matrix of switching exogenous variables
- or:a list containing all the switching exogenous variables in any of the following form:
* a time series
* a real matrix
* a string representing such objects
* the string 'const' (for the constant variable)
MS_M = a scalar equal the # of states
MS_V = a scalar:
- 1 if the variance of the residuals is the same for all states
- MS_M if the variance of the residuals differs among the states
MS_var_opt = a scalar:
- 1 if the variance of residuals is heteroskedastic
- 2 if the variance of residuals is homoskedastic
- 3 if the variance of residuals is unconstrained
arg1, argn = optional arguments which can be:
- 'datation=xx' where xx is the name of a series used as an a priori datation (default: no a priori datation)
- 'transf=xx' where xx is either 'dem' if the user wants all series to be demeaned or 'stu' if the user wants all series to be studentized (default: no transformation)
- 'gdelta=xx' where xx is a number used to calculate the numerical derivative of the log-likelihood (default 1e-4)
- 'hdelta=xx' where xx is a number used to calculate the numerical hessian (default 1e-5)
- 'prt=xx' where xx='nothing', 'final', 'all' or ['initial';'final'] if the user wants to print nothing, only the final results or the final and the initial results
- 'noprint' if the user wants to print nothing (equivalent to 'prt=nothing')
- the string 'dropna' if the user wants to remove the NA values from the data
r = a results tlist with:
- r('meth') = 'ms regression'
- r('typmod') = model numbered type (4 or 5)
- r('y') = a (N x M) matrix of original endogenous variables
- r('x') = the (N x n_x) matrix of exogenous switching regressors
- r('z') = the (N x n_z) matrix of exogenous non switching regressors
- r('ymat') = the (N x M) matrix of -transformed- endogenous variables
- r('xmat') = the (N x M) matrix of -transformed- exogenous switching regressors
- r('zmat') = the (N x M) matrix of -transformed- non switching regressors
- r('switching V') = a scalar:
. 1 if the variance does not switch with the states
. M if the variance switches with the states
- r('var_opt') = a scalar:
. 1 if the variance of residuals is heteroskedastic
. 2 if the variance of residuals is homoskedastic
. 3 if the variance of residuals is unconstrained
- r('nobs') = the # if observations
- r('nendo') = the # of endogenous variables
- r('nb_states') = the # of states
- r('coeff') = the (np x 1) vector of parameters
- r('llike') = the log-likekihood
- r('grad') = the gradient at the solution
- r('yhat') = the adjusted y
- r('resid') = the residuals of the regression
- r('dll') = the degrees of freedom
- r('prob_st') = the (M x 1) vector of egodic state probabilities
- r('ptrans') = the (M x M) matrix of transition probabilities
- r('sigma') = the (M*M_V x M) variance-covariance matrix of the residuals
- r('beta_id') = the (1 x n_x*K*M) vector of switching parameters
- r('beta_co') = the (1 x n_z*K) vector of non switching parameters
- r('inv_sigma') = the (K x K) inverse of the variance matrix
- r('det_inv_sigma') = the determinant of the inverse of the variance matrix
- r('smoothed probs') = the (T x M) vector of smoothed probabilities
- r('stderr') = the (np x 1) vector of coefficients standard errors
- r('tstat') = the (np x 1) vector of associated t-stats
- r('pvalue') = the (np x 1) vector of associated p-values
- r('covbeta') = the (np x np) variance-covariance matrix of the parameters
- r('corbeta') = the (np x np) correlation matrix of the parameters
- r('ptrans_tstat') = the (M x 1) vector of t-stats for the transition probabilities
- r('beta_id_tstat') = the (1 x n_x*K*M) vector of t-stats for switching parameters
- r('beta_co_tstat') = the (1 x n_z*K) vector of t-stats for non switching parameters
- r('sigma_tstat') = the (M*M_V x M) matrix of t-stats for the variance-covariance matrix of the residuals
- r('ptrans_pvalue') = the (M x M) matrix of t-stats for transition probabilities
- r('beta_id_pvalue') = the (1 x n_x*K*M) vector of t-stats for switching parameters
- r('beta_co_pvalue') = the (1 x n_z*K) vector of t-stats for non switching parameters
- r('sigma_pvalue') = the (M*M_V x M) matrix of t-stats for the variance-covariance matrix of the residuals
- r('namey') = the (ny x 1) vector of names of the endogenous variables
- r('namex_id') = the (n_x x 1) vector of names of the swicthing exogenous variables
- r('namex_co') = the (n_x x 1) vector of names of the non swicthing exogenous variables
- r('apriori') = a scalar
. 0 if there is no a priori datation
. 1 if there is an a priori datation
- r('prests') = a boolean indicating whether there are ts in the regression
- r('prests') = a boolean indicating whether there are ts in the regression
- r('datation') = the a priori datation if any
- r('namedat') = the name of the series used for an a priori datation if any
- r('dropna') = boolean indicating if NAs have been dropped
- r('bounds') = if there is a timeseries in the forecast, the bounds of the regression
- r('nonna') = vector indicating position of non-NAs
load('C:\SCI\macros\grocer\db\us_revu.dat') bounds('1967m4','2004m2') nb_states=2 switch_var=2 var_opt=3 r=ms_reg('100*(log(us_revu)-lagts(2,log(us_revu)))',['100*(lagts(1,log(us_revu))-lagts(3,log(us_revu)))';… '100*(lagts(2,log(us_revu))-lagts(4,log(us_revu)))';'100*(lagts(3,log(us_revu))-lagts(5,log(us_revu)))'],'const',nb_states,switch_var,var_opt,'transf=stud',… 'prt=initial;final') This example is taken from function ms_reg_d. The endogenous variable is '100*(log(us_revu)-lagts(2,log(us_revu)))'. The non switching exogenous variables are '100*(lagts(1,log(us_revu))-lagts(3,log(us_revu)))', '100*(lagts(2,log(us_revu))-lagts(4,log(us_revu)))' and '100*(lagts(3,log(us_revu))-lagts(5,log(us_revu)))'. The switching exogenous variables is here the constant. There are 2 states, the variances are switching (switch_var=2) and the var-cov matrix is unrestricted(var_opt=3). Two optional arguments have been given: 'transf= stud' which means that variables are studentuzed before estimation and 'prt=initial;final' which means that sarting values and final results are both printed.