initialize_season: Initialize the seasonal state given actuals and previous...

View source: R/initialize_states.R

initialize_seasonR Documentation

Initialize the seasonal state given actuals and previous fitted

Description

Initialize the seasonal state given actuals and previous fitted

Usage

initialize_season(x, fitted, m, method, threshold)

Arguments

x

Numeric vector of actuals

fitted

Numeric vector of fitted values of a level and trend component

m

The period length of the seasonal component

method

Are we using an additive or a multiplicative seasonal component?

threshold

A value between 0 and 1; return a neutral default seasonal component when the seasonal component's reduction of variance in the residuals is less than the threshold

Examples

x <- rt(n = 55, df = 3) + 5 * cospi((1:55) / 6)
x[seq_along(x) %% 12 == 0] <- NA_real_

plot(x, pch = 19)
lines(x)

fitted <- rep(median(x, na.rm = TRUE), length(x))

s <- tulip:::initialize_season(
  x = x,
  fitted = fitted,
  m = 12,
  method = "multiplicative",
  threshold = 0.5
)

lines(s * fitted, col = "blue", lty = 2)


timradtke/heuristika documentation built on April 24, 2023, 1:55 a.m.