# Additive seasonal pattern
t <- seq(0, 20, length.out = 400)
X <- matrix(2 + 0.3 * t + sin(2 * pi * t / 2.5), nrow = 1)
fd <- fdata(X, argvals = t)
result <- decompose(fd, period = 2.5, method = "additive")
# plot(result$trend) # Linear trend
# plot(result$seasonal) # Sinusoidal seasonal
# plot(result$remainder) # Residual noise
# Multiplicative pattern (amplitude grows with level)
X_mult <- matrix((2 + 0.3 * t) * (1 + 0.3 * sin(2 * pi * t / 2.5)), nrow = 1)
fd_mult <- fdata(X_mult, argvals = t)
result_mult <- decompose(fd_mult, period = 2.5, method = "multiplicative")
Run the code above in your browser using DataLab