Estimate a MixAR model for a time series. This is a generic function. The methods defined in package mixAR are described here.
fit_mixAR(x, model, init, fix, ...)
a time series.
model, object inheriting from MixAR class.
what initializations to do, see Details.
which parameters to fix, see Details.
additional arguments for the methods.
Method dispatch is done on the first three arguments:
model specifies the model to fit. If
model inherits from
"MixAR", it is used as a template. If
init is missing,
the parameters of
model are also used as initial values.
model can also be a numeric vector specifying the order of a
MixAR model with Gaussian components.
init can be used to give initial values in variety of
ways. If it is a MixAR object it doesn't need to be of the same class
model, to allow using as initial values common parameters
of different MixAR models. A positive integer value of
asks to run the fitting procedure
init times, each time
generating random initial values.
init can also be a list. In that case, each component of the
list should itself be an acceptable value for
init and the
fitting procedure is run with each component of
fix can be given in a number of ways. Note however
that currently there is no method dispatch on it.
Currently the default method for
fit_mixAR just throws error,
since there seems no suitable default task to do.
See individual methods for further details.
a MixAR model or a list of MixAR models, depending on the arguments.
signature(x = "ANY", model = "ANY", init = "ANY")
The default method throws error.
signature(x = "ANY", model = "MixAR", init = "missing")
This is equivalent to setting
init = model.
signature(x = "ANY", model = "MixAR", init = "MixAR")
model is a template for the result,
initial values for the parameters. In principle,
init may be from different classes, to allow for example
using AR coefficients from a Gaussian fit for other distributions.
signature(x = "ANY", model = "MixAR", init = "numeric")
init must be a single positive integer here. The model is
init times, each time starting with a new set of
randomly generated initial values. If
the default, the model with the largest likelihood is returned,
otherwise a list containing the
init fitted models is
signature(x = "ANY", model = "MixAR", init = "list")
Each element of the list
init should be an acceptable value
init. The model is fitted with the initial value set to each
init. A list containing the fitted models is
signature(x = "ANY", model = "MixARGaussian", init = "MixAR")
signature(x = "ANY", model = "numeric", init = "missing")
This is equivalent to setting
init = 1.
signature(x = "ANY", model = "numeric", init = "numeric")
model should be a vector of non-negative integers
specifying the order of the MixAR model. The distribution of the
components is assumed Gaussian.
## model coefficients from Wong&Li (IBM fit) prob <- exampleModels$WL_ibm@prob # c(0.5439, 0.4176, 0.0385) sigma <- exampleModels$WL_ibm@scale # c(4.8227, 6.0082, 18.1716) ar <- exampleModels$WL_ibm@arcoef@a # list(c(0.6792, 0.3208), c(1.6711, -0.6711), 1) ## data(ibmclose, package = "fma") # `ibmclose' mo_WLt3 <- new("MixARgen", prob = prob, scale = sigma, arcoef = ar, dist = list(fdist_stdt(3))) mo_WLt30 <- new("MixARgen", prob = prob, scale = sigma, arcoef = ar, dist = list(fdist_stdt(30))) fi0 <- fit_mixAR(fma::ibmclose, exampleModels$WL_ibm, fix = "shift", crit = 1e-4)