m <- seas(AirPassengers)
inspect(m)
### customizing inspect
# a single function
fc <- function(m){
ts.plot(series(m, "fct", verbose = FALSE))
}
inspect(m, fc)
# 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")
}
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