Learn R Programming

tssim (version 0.2.7)

sim_outlier: Simulate an outlier

Description

Simulate an outlier

Usage

sim_outlier(
  n,
  k,
  freq = 12,
  type = c("AO", "LS", "TC"),
  effect_size = 10,
  start = c(2020, 1),
  multiplicative = TRUE
)

Value

The function returns k time series of class xts containing the k outlier effects

Arguments

n

Time series length

k

Number of outliers

freq

Frequency of the time series

type

Type of outlier

effect_size

Mean size of outlier

start

Start date of output time series

multiplicative

Boolean. Is multiplicative time series model assumed?

Author

Daniel Ollech

Details

Three types of outliers are implemented: AO=Additive outlier, LS=Level shift, TC=Temporary Change. The effect size is stochastic as it is drawn from a normal distribution with mean equal to the specified effect_size and a standard deviation of 1/4*effect_size. This is multiplied randomly with -1 or 1 to get negative shocks as well. If multiplicative is true, the effect size is measured in percentage. If is not true, the effect size is unit less and thus adopts the unit of the time series the outliers are added to.

References

Ollech, D. (2021). Seasonal adjustment of daily time series. Journal of Time Series Econometrics. tools:::Rd_expr_doi("10.1515/jtse-2020-0028")

Examples

Run this code
plot(sim_outlier(60, 4, type=c("AO", "LS")))

Run the code above in your browser using DataLab