partialAR (version 1.0.3)

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

Description

Estimates hidden states of a partially autoregressive model

Usage

statehistory.par(A, data = A$data)

Arguments

A
A par.fit object returned from a previous call to fit.par
data
A sequence of observed states

Value

  • A data.frame with one row for each observation in data. The columns in the data.frame are as follows:
  • XValue of the observed state (data) at this time
  • MEstimated value of the mean-reverting component at this time
  • REstimated value of the random walk component at this time
  • eps_MEstimated innovation to the mean-reverting component
  • eps_REstimated innovation to the random walk component

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.

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

Run this code
# 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))

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()

Run the code above in your browser using DataLab