m <- seas(AirPassengers)
inspect(m)
m2 <- inspect(m) # save the model after closing the GUI
### customizing inspect
# a single function
# a new item 'User Plot' can be chosen in the 'View' menu
inspect(m, fun = function(x) hist(resid(x)))
# more than one function collected in a list
myfun <- list()
myfun[['Spectum X-13']] <- function(m){
plot(series(m, "spectrum.specorig", verbose = FALSE)[,-1], t = "l")
}
myfun[['Spectum R']] <- function(m){
spectrum(diff(log(AirPassengers)), method = "ar", main = "")
}
inspect(m, myfun)
# and a bonus example
spaghetti <- function(m, back = 10){
ser <- original(m)
tx <- time(ser)[(length(ser) - back):length(ser)]
z <- NULL
for (txi in tx){
assign(as.character(m$call$x), window(ser, end = txi))
z <- cbind(z, final(eval(m$call)))
}
ts.plot(window(z, start = time(ser)[(length(ser) - back- 15)]),
col = rainbow(back + 1))
}
inspect(m, spaghetti)
Run the code above in your browser using DataLab