Learn R Programming

stsm (version 1.7)

stsmFit: Interface to Different Fitting Procedures

Description

This function is an interface to the methods available in the package for fitting a structural time series model (maximum likelihood in the time and frequency domain via different optimization algorithms).

Usage

stsmFit(x, stsm.method = c("maxlik.fd.scoring", "maxlik.td.scoring", "maxlik.fd.optim", "maxlik.td.optim"), xreg = NULL, ...)

Arguments

x
an object of class stsm.
stsm.method
a character indicating the method to be used.
...
further arguments to be passed to the the function selected in stsm.method.
xreg
vector or matrix of external regresors.

Value

A list of class stsmFit. See the section ‘Value’ in maxlik.fd.

Details

This interface is useful to simplify the code and reduce the number of arguments in functions that call some of those functions that can be specified through stsm.method. For example, the package tsoutliers uses: do.call("stsmFit", args = c(list(x = y, args.tsmethod)), where args.tsmethod is a list containing the arguments to be passed to stsmFit, which includes stsm.method. Thus, the code is simplified since no switch or if statements are necessary; the number of arguments is also reduced since those that are passed tot the function specified in stsm.method are gathered in a list.

The external regressors can be defined in the input object x of class stsm. This is the way the recommend specification for functions maxlik.td and maxlik.fd. This interface allows defining xreg as an argument passed to this function because it simplifies the code in some functions of package tsoutliers. If xreg and x@xreg are both not NULL and error is returned.

See Also

maxlik.fd.scoring, maxlik.td.scoring, maxlik.fd.optim and maxlik.td.optim.