Learn R Programming

partialAR (version 1.0.12)

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:

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

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
# NOT RUN {
# 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()
# }

Run the code above in your browser using DataLab