# 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