Learn R Programming

seasonal (version 0.60.0)

inspect: Interactively Inspect a Seasonal Adjustment Model (RStudio only)

Description

Interactively inspect a "seas" object. inspect uses the manipulate package and can only be used with RStudio. The goal of inspect is to summarize all relevant options, plots and statistics that should be usually considered.

Usage

inspect(x, fun = NULL)

Arguments

x
an object of class "seas"
fun
a function or a list of functions (see details)

Details

The inspect function opens an interactive window that allows for the manipulation of a number of arguments. It offers several views to analyze the series graphically. With each change, the adjustment process and the visualizations are recalculated. Summary statics are shown in the R console.

With the Show static call option, a replicable static call is also shown in the console. Note that this option will double the time for recalculation, as the static function also tests the static call each time (this is a beta feature of seasonal, which allows intensive testing; it may be disabled in future versions).

The views in inspect may be customized via the fun argument. One or several plot functions may be supplied. The plot functions should have a "seas" object as their only argument. Several functions must be wrapped in a list (see examples).

References

R Studio IDE: http://www.rstudio.com/ide/

See Also

seas for the main function of seasonal.

Examples

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