statehistory.par: Estimates hidden states of a partially autoregressive model

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/fit.R

Description

Estimates hidden states of a partially autoregressive model

Usage

1

Arguments

A

A par.fit object returned from a previous call to fit.par

data

A sequence of observed states

Details

Based on the parameters of the model fitted by the previous call to fit.par, produces a data.frame containing the inferred hidden states of the process.

Value

A data.frame with one row for each observation in data. The columns in the data.frame are as follows:

X

Value of the observed state (data) at this time

M

Estimated value of the mean-reverting component at this time

R

Estimated value of the random walk component at this time

eps_M

Estimated innovation to the mean-reverting component

eps_R

Estimated innovation to the random walk component

Author(s)

Matthew Clegg matthewcleggphd@gmail.com

References

Clegg, Matthew. Modeling Time Series with Both Permanent and Transient Components using the Partially Autoregressive Model. Available at SSRN: http://ssrn.com/abstract=2556957

See Also

fit.par

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# A simple example to compare the fitted values of the mean-reverting
# component with the actual data
set.seed(1)
xactual <- rpar(1000, 0.9, 2, 1, include.state=TRUE)
xfit <- fit.par(xactual$X)
xstates <- statehistory.par(xfit)
summary(lm(xstates$M ~ xactual$M))

## Not run: 
    require(ggplot)
    xdf <- rbind(data.frame(data="actual", x=1:nrow(xactual), value=xactual$M), 
      data.frame(data="fitted", x=1:nrow(xstates), value=xstates$M))
    ggplot(xdf, aes(x=x, y=value, colour=data)) + geom_line()

## End(Not run)

partialAR documentation built on April 14, 2020, 6:05 p.m.