msmFit
is an implementation for modeling Markov Switching Models using the EM algorithm
msmFit(object, k, sw, p, data, family, control)
an object of class "lm" or "glm", or "formula" with a symbolic description of the model to be fitted.
numeric, the estimated number of regimes that the model has.
a logical vector indicatig which coefficients have switching.
integer, the number of AR coefficients that the MS model has to have. The default value is zero. If p
is higher than zero, the last values of sw
have to contain the AR coefficients which have switching.
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which "glm" is called.
a character value indicating what family belongs to the model. It is only required when the object is a "General linear formula".
a list of control parameters. See "Details".
msm.fit
returns an object of class '>MSM.lm
or '>MSM.glm
, depending on the input model.
The control
argument is a list that can supply any of the following components:
-trace
: A logical value. If it is TRUE, tracing information on the progress of the optimization is produced.
-maxiter
: The maximum number of iterations in the EM method. Default is 100.
-tol
: Tolerance. The algorithm stops if it is unable to reduce the value by a factor of tol
at a step. Default is 1e-8.
-maxiterOuter
: The number of short runs of the EM method to stablish the initial values. Default is 5
-maxiterInner
: The number of iterations in the EM method in each short run to stablish the initial values. Default is 10
-parallelization
: A logical value. Whether the process is done by using parallelization or not. Default is TRUE.
Hamilton J.D. (1989). A New Approach to the Economic Analysis of Nonstionary Time Series and the Business Cycle. Econometrica 57: 357-384 Hamilton, J.D. (1994). Time Series Analysis. Princeton University Press. Goldfeld, S., Quantd, R. (2005). 'A Markov model for switching Regression',Journal of Econometrics 135, 349-376. Perlin, M. (2007). 'Estimation, Simulation and Forecasting of a Markov Switching Regression', (General case in Matlab).
Overview: MSwM-package
Classes : '>MSM.lm
, '>MSM.glm
, '>MSM.fitted
Methods : msmFit
,summary
,AIC
,intervals
,msmResid
Plot : plot
,plotProb
,plotReg
,plotDiag
# NOT RUN {
## Not run
## data(energy)
## model=lm(Price~Oil+Gas+Coal+EurDol+Ibex35+Demand,energy)
## mod=msmFit(model,k=2,sw=rep(TRUE,8))
## summary(mod)
## End(Not run)
# }
Run the code above in your browser using DataLab