View source: R/initialize_states.R
initialize_season | R Documentation |
Initialize the seasonal state given actuals and previous fitted
initialize_season(x, fitted, m, method, threshold)
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 |
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 |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.