1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/fitted.KFS.R
3\name{fitted.SSModel}
4\alias{fitted.SSModel}
5\alias{fitted.KFS}
6\title{Smoothed Estimates or One-step-ahead Predictions of Fitted Values}
7\usage{
8\method{fitted}{KFS}(object, start = NULL, end = NULL, filtered = FALSE, ...)
9
10\method{fitted}{SSModel}(object, start = NULL, end = NULL, filtered = FALSE, nsim = 0, ...)
11}
12\arguments{
13\item{object}{An object of class \code{KFS} or \code{SSModel}.}
14
15\item{start}{The start time of the period of interest. Defaults to first time
16point of the object.}
17
18\item{end}{The end time of the period of interest. Defaults to the last time
19point of the object.}
20
21\item{filtered}{Logical, return filtered instead of smoothed estimates of
22state vector. Default is \code{FALSE}.}
23
24\item{...}{Additional arguments to \code{\link{KFS}}.
25Ignored in method for object of class \code{KFS}.}
26
27\item{nsim}{Only for method for for non-Gaussian model of class \code{SSModel}.
28The number of independent samples used in importance sampling.
29Default is 0, which computes the
30approximating Gaussian model by \code{\link{approxSSM}} and performs the
31usual Gaussian filtering/smoothing so that the smoothed state estimates
32equals to the conditional mode of \eqn{p(\alpha_t|y)}{p(\alpha[t]|y)}.
33In case of \code{nsim = 0}, the mean estimates and their variances are computed using
34the Delta method (ignoring the covariance terms).}
35}
36\value{
37Multivariate time series containing fitted values.
38}
39\description{
40Computes fitted values from output of \code{KFS}
41(or using the \code{SSModel} object), i.e. one-step-ahead
42predictions  \eqn{f(\theta_t | y_{t-1}, \ldots, y_1)}{
43f(\theta[t] | y[t-1], ... , y[1]),} (\code{m}) or smoothed estimates
44\eqn{f(\theta_t | y_n, \ldots, y_1)}{f(\theta[t] | y[n], ... , y[1]),} (\code{muhat}),
45where \eqn{f} is the inverse of the link function
46(identity in Gaussian case), except in case of Poisson distribution where
47\eqn{f} is multiplied with the exposure \eqn{u_t}{u[t]}.
48}
49\examples{
50data("sexratio")
51model <- SSModel(Male ~ SSMtrend(1,Q = list(NA)),u = sexratio[, "Total"],
52  data = sexratio, distribution = "binomial")
53model <- fitSSM(model,inits = -15, method = "BFGS")$model
54out <- KFS(model)
55identical(drop(out$muhat), fitted(out))
56
57fitted(model)
58}
59\seealso{
60\code{\link{signal}} for partial signals and their covariances.
61}
62