fitted.SSModel: Smoothed Estimates or One-step-ahead Predictions of Fitted...

View source: R/fitted.KFS.R

fitted.SSModelR Documentation

Smoothed Estimates or One-step-ahead Predictions of Fitted Values

Description

Computes fitted values from output of KFS (or using the SSModel object), i.e. one-step-ahead predictions f(\theta_t | y_{t-1}, \ldots, y_1) (m) or smoothed estimates f(\theta_t | y_n, \ldots, y_1) (muhat), where f is the inverse of the link function (identity in Gaussian case), except in case of Poisson distribution where f is multiplied with the exposure u_t.

Usage

## S3 method for class 'KFS'
fitted(object, start = NULL, end = NULL, filtered = FALSE, ...)

## S3 method for class 'SSModel'
fitted(object, start = NULL, end = NULL, filtered = FALSE, nsim = 0, ...)

Arguments

object

An object of class KFS or SSModel.

start

The start time of the period of interest. Defaults to first time point of the object.

end

The end time of the period of interest. Defaults to the last time point of the object.

filtered

Logical, return filtered instead of smoothed estimates of state vector. Default is FALSE.

...

Additional arguments to KFS. Ignored in method for object of class KFS.

nsim

Only for method for for non-Gaussian model of class SSModel. The number of independent samples used in importance sampling. Default is 0, which computes the approximating Gaussian model by approxSSM and performs the usual Gaussian filtering/smoothing so that the smoothed state estimates equals to the conditional mode of p(\alpha_t|y). In case of nsim = 0, the mean estimates and their variances are computed using the Delta method (ignoring the covariance terms).

Value

Multivariate time series containing fitted values.

See Also

signal for partial signals and their covariances.

Examples

data("sexratio")
model <- SSModel(Male ~ SSMtrend(1,Q = list(NA)),u = sexratio[, "Total"],
  data = sexratio, distribution = "binomial")
model <- fitSSM(model,inits = -15, method = "BFGS")$model
out <- KFS(model)
identical(drop(out$muhat), fitted(out))

fitted(model)

KFAS documentation built on Sept. 8, 2023, 5:56 p.m.