Learn R Programming

tsforecast (version 1.3.0)

tsexplore: Explore a Time Series Numerically and Graphically

Description

The function `tsexplore` generates statistics, various tests, and graphs regarding the location, deviation, distribution of a time series.

Usage

tsexplore(
  x,
  show.plot = TRUE,
  x.name = NULL,
  mu = 0,
  adf.lag = 0,
  lag.max = 8,
  ...
)

# S3 method for tsexplore plot( x, trend = c("linear", "smooth", "none"), histbin = 15, lwidth = 0.7, pwidth = 0.7, x.col = "darkgrey", extra.col = "red", plot.incl = c("all", "line", "hist", "box", "qq", "acf", "pacf"), ... )

# S3 method for tsexplore print( x, digits = max(3L, getOption("digits") - 3L), stats.incl = c("all", "stats", "var", "qtls", "acf", "tests"), ... )

Value

An object of class "tsexplore" with following components:

x

original series data

x.time

list of time in which the series values were observed.

x.timegap

time gap between the series and forecasted values.

x.name

name of the time series for which forecasts was requested.

stats

a list of statistics and test results conducted on the time series

Arguments

x

a time series to be explored or a `tsexplore` object.

show.plot

logical. If TRUE, all exploration charts will be displayed directly. Default is TRUE.

x.name

name of the series. If omitted here, the series name found by tsname() will be taken over here. If tsname() is NULL, the variable name will be used instead. Default is NULL.

mu

test value specified under the null hypothesis of the t-test for the mean location. Default is 0.

adf.lag

number of AR lags included in the ADF test. Default is 0.

lag.max

maximum lag at which to calculate the acf. Default is 8. Will be automatically limited to one less than the number of observations in the series. If the series has less than 8 observations.

...

parameter values that can affect the plots created for time series exploration.

trend

a character string indicating whether and how the trend line should be fitted in the time series line plot. Available options are `linear`, `smooth`, `none`. Default is `linear`.

histbin

a numeric value to specify the number of bins in the histogram. Can be omitted. Default is 15.

lwidth

line width of the series line plot. Default is 0.7.

pwidth

size of the markers in the QQ plot. Default is 0.7.

x.col

line colour of the time series line plot. Default is `darkgrey`.

extra.col

colour of extra information in the plots. Default is `red`.

plot.incl

time series components that should be plotted. Available options are `all` (default), `line` (line plot), `hist` (histogram), `box` (boxplot), `qq` (QQ plot), `acf` (ACF plot), and `pacf` (PACF plot). Ignored if show.plot = FALSE.

digits

the number of significant digits.

stats.incl

time series statistics that should be printed. Available options are `all` (default), `stats` (statistics), `var` (variability), `qtls` (quantiles), `acf` (autocorrelation), and `tests` (tests).

Details of the `<code>stats</code>` component

The following statistics and test results are stored in the component `stats` of the `tsexplore` object:

statisticsn (number of observations), nvalid (number of valid observations), sum, mean, median, skewness, kurtosis, cv (coefficient of variation)
variabilityvariance, sd (standard deviation), range, iqr (interquartile range)
quantilesminimum, q1 (1st quartile), median, q3 (3rd quartile), maximum
autocorrelationacf (autocorrelation function), pacf (partial autocorrelation function) - from lag 0 (ACF) or lag 1 (PACF) until lag.max
testslocation (t-test), normality (Shapiro-Wilk-test), stationarity (ADF-test), independence (Ljung-Box-test) - each test contains the test statistics (statistics and the p-value (p.value))

Author

Ka Yui Karl Wu

References

Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and practice (3rd ed.). OTexts.
https://otexts.com/fpp3/

Examples

Run this code
tsexplore(airport$Travellers, lag.max = 24, histbin = 10)

Run the code above in your browser using DataLab