Learn R Programming

astsa (version 1.16)

ssm: State Space Model

Description

Fits a simple univariate state space model, x[t] = alpha + phi x[t-1] + w[t], and y[t] = A x[t] + v[t]. The parameters alpha, phi, sigma[w] and sigma[v] are estimated; parameter phi may be fixed. State predictions and smoothers and corresponding error variances are evaluated at the estimates. The sample size must be at least 20.

Usage

ssm(y, A, phi, alpha, sigw, sigv, fixphi = FALSE)

Value

At the MLEs, these are returned invisibly:

Xp

time series - state prediction, \(x_t^{t-1}\)

Pp

corresponding MSPEs, \(P_t^{t-1}\)

Xf

time series - state filter, \(x_t^t\)

Pf

corresponding MSEs, \(P_t^t\)

Xs

time series - state smoother, \(x_t^n\)

Ps

corresponding MSEs, \(P_t^n\)

Arguments

y

data

A

measurement value (fixed constant)

phi

initial value of phi, may be fixed

alpha

initial value for alpha

sigw

initial value for sigma[w]

sigv

initial value for sigma[v]

fixphi

if TRUE, the phi parameter is fixed

Author

D.S. Stoffer

Details

The script works for a specific univariate state space model. The initial state conditions use a default calculation and cannot be specified. The parameter estimates are printed and the script returns the state predictors and smoothers.

References

You can find demonstrations of astsa capabilities at FUN WITH ASTSA.

The most recent version of the package can be found at https://github.com/nickpoison/astsa/.

In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.

The webpages for the texts are https://www.stat.pitt.edu/stoffer/tsa4/ and https://www.stat.pitt.edu/stoffer/tsda/.

Examples

Run this code
if (FALSE) {

u = ssm(gtemp_land, A=1, alpha=.01, phi=1, sigw=.05, sigv=.15)
tsplot(gtemp_land, type='o', col=4)
lines(u$Xs, col=6, lwd=2)
}

Run the code above in your browser using DataLab