Docstrings

Forecast.ForecastModule

Collection of methods for Time Series analysis

Featured Methods:

acf:        Auto-correlation or auto-covariance of univariate series. 
ar:         Multivariate Autoregressive Model.
arsim:      Simulated Multivariate Autoregressive Model.
boxcox:     Box-Cox Transformations.
ccf:        Cross-correlation or cros-covariance of two univariate series.
d:          Lagged differences of a given order for Vector and Array.
forecast:   Forecast values of fitted time series models.
hma:        Henderson moving average filter.
iboxcox:    Inverse Box-Cox Transformations.
loess:      Locally estimated scatterplot smoothing.
p:          Reverse lagged differences of a given order for types Vector and Array.
pacf:       Partial Auto-correlation function.
sma:        Simple moving average.
splot:      Plot a seasonal plot for types Vector and TimeArray.
stl:        Seasonal and Trend decomposition using loess.
summarize:  Statistical summary.
Forecast.ARType

Package: Forecast

Store results from the function ar

Arguments

varnames List of variable names order Order of Autoregressive Model ndims Number of dimensions Φ Collection of d by d matrices of coefficients coefficients Alias for Φ Φ0 Constant constant Alias for Φ0 Σ2 ML variance/covariance Matrix variance Alias for Σ2 Σ Variables Standard deviation stdev Alias for Σ x Original dataset fitted Fitted values residuals Prediction Error ic::Dict Collection of Information Criteria stats::Dict Collection of Statistics Φse Parameters Standard Error pse Alias for Φse Φ0se Constant Standard Error p0se Alias for Φ0se Φpv p-value for Parameters ppv Alias for Φpv Φ0pv p-value for Constant p0pv Alias for Φ0pv call::String Method called to generate AR

Forecast.CCFType

Package: Forecast

Store results from the functions acf, ccf and pacf

Arguments

ccf An array with results from ccf, acf and pacf N Length of ccf type Type of CCFlagMaximum number of lagsalphCI thresholdsciCI for the alphaautoAuto-correlationcall` Method called to generate ccf

Forecast.FORECASTType

Package: Forecast

Store results from the function forecast

Arguments

model: Model object containing information about the fitted model. x: Original time series. alpha: The confidence levels associated with the prediction intervals. mean: Point forecasts. lower: Lower limits for prediction intervals. upper: Upper limits for prediction intervals. se: Standard Error.

Forecast.STLType

Package: Forecast

Store results from the function stl

Arguments

`decomposition::DataFrame`    A time array with three time series from a fitted STL model
`call::String`                method called to generate ta
Forecast.SUMMARIZEType

Package: Forecast

Store results from the function summarize

Arguments

quantiles::DataFrame DataFrame with the data quantiles for each column moment::DataFrame DataFrame with the first four moments for each column format::DataFrame DataFrame with number of types per column

Forecast.acfMethod

Package: Forecast

acf(x::{AbstractVector,DataFrame},
    type = "cor",
    lag = Integer(ceil(10*log10(length(x)))),
    alpha = (0.95,0.99))

Compute the auto-correlation or auto-covariance for an univariate series.

The results are normalized to preserve homoscedasticity. The distribution used to normalize the data is an approximation of a Fisher Transformation via a Normal Distribution. There is a plot recipe for the returned object, if the type is cor the plot will also show confidence intervals for the given alpha values.

Arguments

  • x: Vector or uni-dimensional DataFrame of data.
  • type: Valid values are "cor" for correlation (default) and "cov" for convariance.
  • lag: Maximum number of lags.
  • alpha: A tuple with two thresholds (t1,t2) with t1 <= t2 to plot confidence intervals. The default values are 0.95 and 0.99.

Returns

A CCF object.

Examples

julia> x = rand(100);
res = acf(x; type="cor");
plot(res)
Forecast.airMethod

Package: Forecast

air()

Return the classic Box & Jenkins airline data. Monthly totals of international airline passengers from 1949 to 1960.

Box, G. E. P., Jenkins, G. M. and Reinsel, G. C. (1976) Time Series Analysis, Forecasting and Control. Third Edition. Holden-Day. Series G.

Returns

Dataframe containing the descrived dataset.

Examples

julia> air()
71×2 DataFrame
 Row │ year        quakes 
     │ Date        Int64  
─────┼────────────────────
   1 │ 1950-01-01     138
   2 │ 1951-01-01     151
   3 │ 1952-01-01     181
   [...]
Forecast.arFunction

Package: Forecast

ar(x::DataFrame, or, constant = true;             
                 alpha = 1.0, dΦ0 = nothing, dΦ = nothing)

ar(x::AbstractArray, or, constant = true; 
                     alpha = false, dΦ0 = nothing, dΦ = nothing, varnames = nothing)

Fit a multivariate autoregressive series model.

The fitting is done via Ordinary Least Squared and implements the following model:

\[Xt = \Phi_0 + \sum_{i=1}^p \Phi_i \cdot X_{t-i} + \mathcal{N}(\vec{0},\Sigma)\]

Arguments

  • x: Multivariate series each column containing a dimension and ordered by time ascending rows.
  • or: Number of parameters Φ to be estimated.
  • constant: If truear estimates Φ0 otherwise it is assume to be zero.
  • alpha: fixes to zero all coefficients which significance is below its value. It defaults to one.
  • dΦ0: Tuple containing two Φ0 objects, the first one will act as an original reference to the second one and different values will be fixed in the fitting process to the values in the second Φ0.
  • : Equivalent to dΦ0 but for Φ.
  • varnames: Names of the dimensions (by default xi where i is an integer)

Returns

An AR object containing the model coefficients, the error sigma matrix, residuals and a collection of information criteria

Examples

```julia-repl julia> ar(rand(100,2),2) AR([...])

Forecast.arsimMethod

Package: Forecast

arsim(Φ,Φ0,x0,n; Σ,E,fix)
arsim(AR,n;fix)

Simulate a multivariate autoregressive series model.

The simulated series follows the model:

\[Xt = \Phi_0 + \sum_{i=1}^p \Phi_i \cdot X_{t-i} + E\]

Arguments

  • AR: AR struct coming from an ar model.

  • Φ: Array with dimensions (m,m,p) for the parameters in the AR model.

  • Φ0: Vector size m for the constant in the AR model. Default value is 0.

  • x0: Array with dimensions (m,p) for the initial value in the AR model. Default value is a random value from zero to one.

  • n: Number of simulations.

  • fix: Matrix{Union{Missing,Float64}} containing values to be fixed in th simulation.

  • Σ2: Variance Covariance matrix for the AR model with a MvNormal distribution for the noise. Default value is an identity Matrix.

  • E: Distribution for the error.

Returns

A multivariate series simulating an AR model each column containing a dimension and ordered by time ascending rows.

Examples

```julia-repl julia> arsim(1,1,1,10) 10-element Vector{Float64,1}: [...]

Forecast.boxcoxMethod

Package: Forecast

boxcox(x::Vector)
boxcox(x::Vector, λ::Float64)  
boxcox(x::Vector, λ::Vector)

Compute a Box-Cox power transformation given λ or (λ1,λ2) for data containing negative values, or compute an optimal power transformation if no λ or (λ1,λ2) is provided.

\[x(\lambda) = \begin{cases} \dfrac{x_i^\lambda - 1}{\lambda} & \text{if } \lambda \neq 0 \\ \ln x_i & \text{if } \lambda = 0 \end{cases}\]

for negative values

\[x(\boldsymbol{\lambda}) = \begin{cases} \dfrac{(x_i + \lambda_2)^{\lambda_1} - 1}{\lambda_1} & \text{if } \lambda_1 \neq 0 \\ \ln (x_i + \lambda_2) & \text{if } \lambda_1 = 0 \end{cases} \]

Arguments

  • x: Vector to be transformed.
  • λ: Exponent/s for the tranformation

Returns

A vector with a boxcox tarnsformation for x or a Dict with :x boxcox tranformed and the optimal :λ

Reference

Box, G. E. P. and Cox, D. R. (1964). An analysis of transformations, Journal of the Royal Statistical Society, Series B, 26, 211-252. A

Examples

julia> x = rand(100)
julia> bc = boxcox(x)
julia> iboxcox(bc[:x],bc[:λ]) ≈ x

julia> x = rand(100) .- 0.5
julia> bc = boxcox(x)
julia> iboxcox(bc[:x],bc[:λ]) ≈ x
Forecast.ccfMethod

Package: Forecast

ccf(x1::{AbstractVector,DataFrame},
    x2::{AbstractVector,DataFrame};
    type = "cor",
    lag = Integer(ceil(10*log10(length(x1)))),
    alpha = (0.95,0.99))

Compute the cross-correlation or cros-covariance of two univariate series.

The results are normalized to preserve homoscedasticity. The distribution used to normalize the data is an approximation of a Fisher Transformation via a Normal Distribution. There is a plot recipe for the returned object, if the type is cor the plot will also show confidence intervals for the given alpha values.

If, for a given integer k, x2 repeats x1 values such that x1[t] = x2[t+k] for all i then high correlation value will be placed at the right from the center in the results. That is, this convention will be represented in the plots as x1_t = x2_{t+k} -> _____0__k__ meaning x2 behavior can be predicted by x1 in k units.

Arguments

  • x1: Vector or uni-dimensional DataFrame of data.
  • x2: Vector or uni-dimensional DataFrame of data.
  • type: Valid values are "cor" for correlation (default) and "cov" for convariance.
  • lag: Maximum number of lags.
  • alpha: A tuple with two thresholds (t1,t2) with t1 <= t2 to plot confidence intervals. The default values are 0.95 and 0.99.

Returns

A CCF object.

Examples

julia> x1 = rand(100);
x2 = circshift(x1,6);
res = ccf(x1, x2; type="cor");
plot(res)
Forecast.co2Function

Package: Forecast

co2(full = false)

Return dataset with atmospheric Carbon Dioxide Dry Air Mole Fractions from quasi-continuous measurements at Mauna Loa, Hawaii.

K.W. Thoning, A.M. Crotwell, and J.W. Mund (2020), Atmospheric Carbon Dioxide Dry Air Mole Fractions from continuous measurements at Mauna Loa, Hawaii, Barrow, Alaska, American Samoa and South Pole. 1973-2019, Version 2020-08 National Oceanic and Atmospheric Administration (NOAA), Global Monitoring Laboratory (GML), Boulder, Colorado, USA https://doi.org/10.15138/yaf1-bk21 FTP path: ftp://aftp.cmdl.noaa.gov/data/greenhouse_gases/co2/in-situ/surface/

Arguments

  • full: if true Returns the full original dataset from 1973 to 2020 in a DataFrame, otherwise returns the subset used in "STL: A Seasonal-Trend Decomposition Procedure Based on Loess" from Cleveland et. al. Its default value is false.

Returns

Dataframe containing the descrived dataset.

Examples

julia> co2()
[ Info: Dataset used in Cleveland et al. paper
4612×2 DataFrame
  Row │ date        co2        
      │ Date        Float64?   
──────┼────────────────────────
    1 │ 1974-05-17      333.38
    2 │ 1974-05-18      333.11
    3 │ 1974-05-19      333.46
   [...]
Forecast.compactMethod

Package: Forecast

compact(x)

Standarize input by dropping empty dimensions and returning an Array. If a Number is passed then a 0-dimensional array is returned. In the case of a DataFrame it removes all non Real columns except if there are columns with Date type in which case keeps the first one found and places it as the first column.

Forecast.dFunction

Package: Forecast

function d(x::{AbstractVector,AbstractArray,DataFrame},
           or::Int=1,
           la::Int=1;
           center::Bool=false)

Return Laged differences of a given or for Vector, Array and TimeSeries.

Arguments

  • x: Vector or Array of data.
  • or: Order of the differences; number of recursive iterations on the same vector/array.
  • la: Lag for the difference.
  • center: Center the result in the response using Missing values.

Returns

Laged differences Vector or Array of a given order.

Examples

julia> x = [1,2,3,4,5];
julia> d(x)
 d(x)
4-element Vector{Int64}:
 1
 1
 1
 1

julia> d(x,2)
3-element Vector{Int64}:
 0
 0
 0


julia> d(x,1,2)
3-element Vector{Int64}:
 2
 2
 2

julia> x = reshape(collect(1:20),10,2);

julia> d(x,2,2)
6×2 Matrix{Int64}:
 0  0
 0  0
 0  0
 0  0
 0  0
 0  0

julia> d(d(x,1,2),1,2) == d(x,2,2)
Forecast.dropMethod

Package: Forecast

drop(M;r,c)

Drop rows and columns from a matrix.

Forecast.fixWMethod

Package: Forecast

fixW(W,dΦ0,dΦ)

For a given Weight matrix returns a version with fixed values based on dΦ0 and dΦ

Forecast.fixnpMethod

Package: Forecast

fixnp(dΦ0,dΦ)

return the number of free parameters

Forecast.fixΦMethod

Package: Forecast

fixΦ(X,Y,dΦ0,dΦ)

For a given X and Y OLS matrices returns the X and Y resulting from fixing parameters given dΦ0 and dΦ

Forecast.fixΦseMethod

Package: Forecast

fixΦse(M,dΦ0,dΦ)

For a given se matrix returns an version with zeroes based on dΦ0 and dΦ

Forecast.forecastMethod

Package: Forecast

forecast(xar, n; levels = (0.8,.95))

Forecast a univariate or multivariate autoregressive model.

The forecasting follows the model:

\[Xt = \Phi_0 + \sum_{i=1}^p \Phi_i \cdot X_{t-i} + E\]

Arguments

xar AR struct coming from the ar function. n Number of time periods to be forecasted. alpha Prediction intervals levels; its default value is (0.8, 0.95) fixMean Fixes the mean in the forecast with a DataFrame which first column is a timestamp type and missing values indicate values to be estimated. Default value is nothing. fixΣ2 fixes Σ2 values in the forecast

Returns

A FORECAST struct

Forecast.hmaMethod

Package: Forecast

hma(s, n)

Applies the Henderson moving average filter to dataset s with n-term.

"Henderson moving averages are filters which were derived by Robert Henderson in 1916 for use in actuarial applications. They are trend filters, commonly used in time series analysis to smooth seasonally adjusted estimates in order to generate a trend estimate.

They are used in preference to simpler moving averages because they can reproduce polynomials of up to degree 3, thereby capturing trend turning points.

The ABS uses Henderson moving averages to produce trend estimates from a seasonally adjusted series. The trend estimates published by the ABS are typically derived using a 13 term Henderson filter for monthly series, and a 7 term Henderson filter for quarterly series.

Henderson filters can be either symmetric or asymmetric. Symmetric moving averages can be applied at points which are sufficiently far away from the ends of a time series. In this case, the smoothed value for a given point in the time series is calculated from an equal number of values on either side of the data point." - Australian Bureau of Statistics (www.abs.gov.au)

Arguments

  • s: Observations' support.
  • n: Observation values. Tipically 13 or 7 for quarterly data, larger values may need a BigInt type.

Returns

An array of Henderson filter smoothed values provided in s.

Examples

julia> hma(rand(1000), BigInt(303)))
1000-element Vector{BigFloat}:
[...]
Forecast.iboxcoxMethod

Package: Forecast

iboxcox(x::Vector, λ::Float64) 
iboxcox(x::Vector, λ::Vector)

Compute the inverse transformation of a Box-Cox power transformation given λ.

Arguments

  • x: Vector with a boxcox tranformation to be inverted.
  • λ: Exponent for the inverse tranformation.

Returns

A vector with witht the inverse transformation of x given λ.

Reference

Box, G. E. P. and Cox, D. R. (1964). An analysis of transformations, Journal of the Royal Statistical Society, Series B, 26, 211-252. A

Examples

julia> x = rand(100)
julia> bc = boxcox(x)
julia> iboxcox(bc[:x],bc[:λ]) ≈ x

julia> x = rand(100) .- 0.5
julia> bc = boxcox(x)
julia> iboxcox(bc[:x],bc[:λ]) ≈ x
Forecast.insert_columnFunction

Package: Forecast

insert_column(M, at, value = 0.0)

Insert a column with specific value at a given position, values are pushed to the right

Forecast.insert_crossFunction

Package: Forecast

insert_row(M, at, value = 0.0)

Insert a row and a column with specific value at a given cross position, values are pushed right and down.

Forecast.insert_rowFunction

Package: Forecast

insert_row(M, at, value = 0.0)

Insert a row with specific value at a given position, values are pushed down

Forecast.loessMethod

Package: Forecast

loess(xv, yv;
      d = 2,
      q = Int64(round(3/4*length(xv))),
      rho = repeat([1.0],inner=length(xv)),  
      predict = xv)

Smooth a vector of observations using locally weighted regressions.

Although loess can be used to smooth observations for any given number of independent variables, this implementation is univariate. The speed of loess can be greatly increased by using fast aproximations for the linear fitting calculations, however this implementation calculates only exact results.

The loess functionality and nomenclature follows the descriptions in:

"STL: A Seasonal, Trend Decomposition Procedure Based on Loess" Robert B. Cleveland, William S. Cleveland, Jean E. McRae, and Irma Terpenning. Journal of Official Statistics Vol. 6. No. 1, 1990, pp. 3-73 (c) Statistics Sweden.

Arguments

  • xv: Observations' support.
  • yv: Observation values.
  • d: Degree of the linear fit, it accepts values 1 or 2.
  • q: As q increases loess becomes smoother, when q tends to infinity loess tends to an ordinary least square poynomial fit of degree d. It defaults to the rounding of 3/4 of xv's length.
    • rho: Weights expressing the reliability of the observations (e.g. if yi had variances σ^2*ki where ki where known, the rhoi could be 1/ki). It defaults to 1.0.
  • predict: Vector containing the real values to be predicted, by default predicts xv.

Returns

The loess values for the values contained in predict.

Examples

julia> loess(rand(5), rand(5); predict=rand(10))
10-element Array{Float64,1}:
[...]
Forecast.londonMethod

Package: Forecast

london()

Return ten years of monthly data about weather and crime in Greater London from 2008 to 2018.

Data has been collected and joined from london.gov.uk and metoffice.gov.uk (Heathrow Station).

Weather Variables

  • MaxTemp: Mean daily maximum temperature in C°
  • MinTemp: Mean daily minimum temperature in C°
  • AirFrost: Days of air frost
  • Rain: Total rainfall in mm
  • Sun: Total sunshine durationin hours

Crime Variables and its aggregated categories

┌─────────────────────────────┬────────────────────────────────────────┐
│                       Crime │                               Category │
├─────────────────────────────┼────────────────────────────────────────┤
│                    Burglary │            Burglary in Other Buildings │
│                             │                 Burglary in a Dwelling │
│                      Damage │            Criminal Damage To Dwelling │
│                             │       Criminal Damage To Motor Vehicle │
│                             │      Criminal Damage To Other Building │
│                             │                  Other Criminal Damage │
│                       Drugs │                       Drug Trafficking │
│                             │                            Other Drugs │
│                             │                    Possession Of Drugs │
│                       Fraud │                     Counted per Victim │
│                             │                  Other Fraud & Forgery │
│                       Other │                         Going Equipped │
│                             │                       Other Notifiable │
│                     Robbery │                      Business Property │
│                             │                      Personal Property │
│                      Sexual │                           Other Sexual │
│                             │                                   Rape │
│                       Theft │                  Handling Stolen Goods │
│                             │ Motor Vehicle Interference & Tampering │
│                             │                            Other Theft │
│                             │                     Other Theft Person │
│                             │               Theft From Motor Vehicle │
│                             │                       Theft From Shops │
│                             │          Theft/Taking Of Motor Vehicle │
│                             │            Theft/Taking of Pedal Cycle │
│                    Violence │                    Assault with Injury │
│                             │                         Common Assault │
│                             │                   Grievous Bodily Harm │
│                             │                             Harassment │
│                             │                                 Murder │
│                             │                       Offensive Weapon │
│                             │                         Other violence │
│                             │                           Wounding/GBH │
└─────────────────────────────┴────────────────────────────────────────┘

Returns

Dataframe containing the descrived dataset.

Examples

julia> london()
132×15 DataFrame
 Row │ Date        MaxTemp  MinTemp  AirFrost  
     │ Date        Float64  Float64  Int64     
─────┼─────────────────────────────────────────[...]
   1 │ 2008-01-01     10.4      4.7         0  
   2 │ 2008-02-01     11.0      2.0         7  
   3 │ 2008-03-01     10.6      3.7         2
   [...]
Forecast.nextoddMethod

Package: Forecast

nextodd(x)

Return the smallest odd integer greater than or equal to x.

Forecast.pFunction

Package: Forecast

function p(dx, x0)

Return reverse lagged differences of a given order for Vector, Array and DataFrame.

Arguments

  • dx: Array or DataFrame of data.
  • x0: Initial constants the reverse difference. The default value represents an integration of order one and lag one with initial values at zero. The format for the initial values is Array{Real,3}(order, variable, lag)"

Returns

Lagged differences Vector or Array of a given order.

Examples


# Order two with Lag two
julia> x = repeat(1:2,30);
julia> dx = d(x,2,2);
julia> x0 = zeros(2,1,2); # lag 2, 1 variable, order 1
julia> x0[1,:,:] = collect(1:2);
julia> p(dx,x0) ≈ x
true

# Calculation of π
julia> x = 0:0.001:1;
julia> y = sqrt.(1 .- x.^2);
julia> isapprox(4*p(y)[end]/1000 , π, atol = 0.01)
true
Forecast.pacfMethod

Package: Forecast

pacf(x::{AbstractVector,DataFrame};
     type = "step-real",
     lag = Integer(ceil(10*log10(length(x)))),
     alpha = (0.95,0.99))

Compute the partial auto-correlation for an univariate series.

There are two versions; the "step" version estimates the auto-regressive parameters of an increasing model, the "real" version estimates the actual partial auto-correlation by eliminating the linear information provided by the lags. When using the default type "stepwise-real" both versions are calculated.

The distribution used to estimate the confidence intervals is an approximation of a Fisher Transformation via a Normal Distribution. There is a plot recipe for the returned object.

Arguments

  • x: Vector or uni-dimensional DataFrame of data.
  • type = Valid values are "stepwise", "real" and "stepwise-real".
  • lag: Maximum number of lags.
  • alpha: A tuple with two thresholds (t1,t2) with t1 <= t2 to plot confidence intervals. The default values are 0.95 and 0.99.

Returns

A CCF object

Examples

julia> x = rand(100);
res = pacf(x);
plot(res)
Forecast.quakesMethod

Package: Forecast

quakes()

Return the number of earthquakes per year on earth with a magnitude higher or equal to six from 1950 to 2020. The data has been collected from https://earthquake.usgs.gov/ and aggregated.

Examples

julia> quakes()
71×2 DataFrame
 Row │ year        quakes 
     │ Date        Int64  
─────┼────────────────────
   1 │ 1950-01-01     138
   2 │ 1951-01-01     151
   3 │ 1952-01-01     181
   [...]
Forecast.seaborneFunction

Package: Forecast

seaborne(full = false)

Return estimates of world seaborne trade from AIS data collected by Marine Traffic.

By default a DataFrame containing deadweight imports for France, Germany and the United Kingdom from 2015-04-01 to 2021-05-02 is returned, otherwise a DataFrame is returned for the same countries with import and exports for the below fields:

numpc: number of port calls mtc: metric tons of cargo dwt: deadweight tonnage suffixma: 30-day moving averages

Data available at UN COMTRADE Monitor.Cerdeiro, Komaromi, Liu and Saeed (2020).

Returns

Dataframe containing the seaborne dataset.

Examples

julia> seaborne()
[ Info: Seaborne deadweight trade imports from AIS
2199×4 DataFrame
  Row │ Date        France   Germany  UK     
      │ Date        Int64    Int64    Int64  
──────┼──────────────────────────────────────
    1 │ 2015-04-01   507946   878377  599573
    2 │ 2015-04-02   332043  1501614  772714
    3 │ 2015-04-03   810077   941663  262994
   [...]
Forecast.smaMethod

Package: Forecast

sma(x, n)
sma(x, n, center)

Smooth a vector of data using a simple moving average.

Arguments

  • x: Vector of data.
  • n: Size of the moving average.
  • center: if true centers the moving averaged values in the response padding with missing values, otherwise the padding takes place at the end.

Returns

Vector of moving average smoothed values containing missing values to preserve the size of the original vector.

Examples

julia> sma(1:5,3,true)
5-element Array{Any,1}:
  missing
 2.0
 3.0
 4.0
  missing
Forecast.splotMethod

Package: Forecast

splot(x, labels)

Plot a seasonal plot of x considering the parameter labels

Arguments

  • x: regular timed observations
  • labels: This parameter accepts Integer, String and Vector values. When an Integer the labels are 1:labels, when a Vector the labels are specified within and when a String it accepts values "month", "day" and "quarter" expecting the first value of x to fall in "Jan", "Mon" or "Q1" unless x is a DataFrame in which case it is treated as a Time Series where the first Date typed column and value columns ares considered, observations are then automatically ordered either by "month", "day" or "quarter" and labels may be use to rename the default values.

Returns

Sesonal plot

Examples

julia> splot(rand(120),"month")
julia> splot(rand(120),"quarter")
julia> splot(rand(120),"day")
Forecast.stlMethod

Package: Forecast

stl(Yv, np; robust=false, 
            nl=nextodd(np), 
            ns=10*length(Yv)+1,
            nt=nextodd(1.5*np/(1-1.5/ns)), 
            ni=robust ? 1 : 2,
            no=0,
            spm=false,
            qsmp=max(div(np,7),2),
            cth = 0.01,
            timestamp = nothing,
            verbose=false)

Decompose a time series into trend, seasonal, and remainder components.

"STL has a simple design that consists of a sequence of applications of the loess smoother; the simplicity allows analysis of the properties of the procedure and allows fast computation, even for very long time series and large amounts of trend and seasonal smoothing. Other features of STL are specification of amounts of seasonal and trend smoothing that range, in a nearly continous way, from very small amount of smoothing to a very large amount; robust estimates of the trend and seasonal components that are not distorted by aberrant behavior in the data; specification of the period of the seasonal component to any intenger multiple of the time sampling interval greater than one; and the ability to decompose time series with missing values."*

All default values are chosen following the recommendations of the original paper when those were recommended. ns is recommended to be chosen of the basis of knowledge of the time series and on the basis of diagnostic methods; it must nonethelessbe always odd and at least 7. A default value is not advised on the original paper, instead the same default value used in the stl implementation in R in usere here.

for no the authors advise 5 ("safe value") or 10 ("near certainty of convergence") cycles or a convergence criterion when robustness is required, in this case when robust is true computations stop when convergence is achieved in trend and seasonality.

for qsmp the authors do not adivise a default but they use a value close to div(np,7).

Arguments

  • np: Seasonality.
  • robust: Robust stl.
  • nl: Smoothing parameter of the low-pass filter.
  • ns: Smoothing parameter for the seasonal component.
  • nt: Smoothing parameter for the trend decomposition.
  • ni: Number of inner loop cycles.
  • no: Number of outer loop cycles.
  • spm: Seasonal post-smoothing.
  • qsmp: Loess q window for Seasonal post-smoothing.
  • cth: Corvengence threshold for Seasonal and Trend.
  • timestamp: Timestamp to be used other than the default.
  • verbose: If true shows updates for the Seasonal and Trend convergence.

Returns

An STL object with the seasonal, trend and remainder components.

  • STL: A Seasonal, Trend Decomposition Procedure Based on Loess" Robert B. Cleveland, William S. Cleveland, Jean E. McRae, and Irma Terpenning. Journal of Official Statistics Vol. 6. No. 1, 1990, pp. 3-73 (c) Statistics Sweden.

Examples

julia> stl_co2 = stl(co2(),365; robust=true, spm=true)
[ Info: Dataset used in Cleveland et al. paper
[ Info: Corvengence achieved (< 0.01); Stopping computation...
STL Object: stl(Yn, np=365; nl=365, ns=46091, nt=549, ni=1, no=0, spm=true, qsmp=52)

julia> plot(stl_co2)
Forecast.summarizeMethod

Package: Forecast

summarize(x; varnames = nothing)

Return statistical summary for x

The values returned are dividen in three sections, the first one shows Minimum, 1st Quantile, Median, Mean, 3rd Quantile, Maxixum and the p-value for the Jarque-Bera Normality Test. The second one show the first four moment; Mean, Variance, Skewness and Kurtosis, an finally a summary with the different types contained in the Array.

Arguments

  • x: Array or DataFrame of data.
  • varnames: Names for the columns to be summarized, it defaults to automatic naming or the existing names in when a DataFrame.

Returns

A SUMMARIZE struct

Examples

julia> summarize(rand(100,3); varnames = ["a","b","c"])
┌──────────┬────────────┬──────────┬──────────┬──────────┬──────────┬──────────┬───────────┐
│ Variable │        Min │       1Q │   Median │     Mean │       3Q │      Max │ H0 Normal │
├──────────┼────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼───────────┤
│        a │ 0.00520465 │ 0.205712 │ 0.462199 │ 0.465784 │   0.6913 │  0.97946 │ 0.0593599 │
│        b │ 0.00218787 │ 0.247344 │ 0.485465 │ 0.498587 │ 0.723371 │ 0.985226 │ 0.0562301 │
│        c │  0.0244256 │ 0.247598 │ 0.530821 │ 0.498689 │ 0.722731 │ 0.967952 │ 0.0356495 │
└──────────┴────────────┴──────────┴──────────┴──────────┴──────────┴──────────┴───────────┘
┌──────────┬──────────┬───────────┬───────────┬───────────┐
│ Variable │     Mean │  Variance │  Skewness │  Kurtosis │
├──────────┼──────────┼───────────┼───────────┼───────────┤
│        a │ 0.465784 │ 0.0823949 │ 0.0823949 │ 0.0823949 │
│        b │ 0.498587 │ 0.0854883 │ 0.0854883 │ 0.0854883 │
│        c │ 0.498689 │ 0.0790597 │ 0.0790597 │ 0.0790597 │
└──────────┴──────────┴───────────┴───────────┴───────────┘
┌──────────┬─────────┐
│ Variable │ Float64 │
├──────────┼─────────┤
│        a │     100 │
│        b │     100 │
│        c │     100 │
└──────────┴─────────┘