Learn R Programming

tfarima (version 0.4.1)

fit.ssm: Estimation of the ARIMA model

Description

fit fits the univariate model to the time series z.

Usage

# S3 method for ssm
fit(
  mdl,
  z = NULL,
  updateSSM,
  param,
  show.iter = FALSE,
  tol = 1e-04,
  method = "BFGS",
  ...
)

fit(mdl, ...)

# S3 method for um fit( mdl, z = NULL, method = c("exact", "cond"), optim.method = "BFGS", show.iter = FALSE, envir = NULL, ... )

Value

An object of class "ssm" with the estimated parameters.

An object of class "um" with the estimated parameters.

Arguments

mdl

an object of class um or tfm.

z

a time series.

updateSSM

user function to update the parameters of the SS model. The function must take a model object and a parameter vector as inputs and return an updated model object.

param

a numeric vector of named parameters passed to the updateSSM function.

show.iter

logical value to show or hide the estimates at the different iterations.

tol

numeric. Tolerance to check if a root is close to one.

method

Exact/conditional maximum likelihood.

...

additional arguments for the optim function.

optim.method

the method argument of the optim function.

envir

environment in which the function arguments are evaluated. If NULL the calling environment of this function will be used.

Examples

Run this code
# Predefined local level model
ucm1 <- ucm(Nile, uc = "llm", fit = FALSE)
ucm1 <- fit(ucm1)
ucm1

# User defined local level model
ssm1 <- ssm(Nile, b = 1, C = 1, S = diag(c(1, 0.5)) )
param <- c(irr = var(Nile), lvl = var(diff(Nile)))
updateSSM <- function(mdl, param) {
mdl$S[1,1] <- param[1]
mdl$S[2,2] <- param[2]
mdl
}
fit(ssm1, updateSSM = updateSSM, param = param)

z <- AirPassengers
airl <- um(i = list(1, c(1, 12)), ma = list(1, c(1, 12)), bc = TRUE)
airl <- fit(airl, z)

Run the code above in your browser using DataLab