find_opt: Find optimal number of fourier variables

View source: R/find_opt.R

find_optR Documentation

Find optimal number of fourier variables

Description

Performs a grid search over combinations of yearly and monthly Fourier (trigonometric) regressors and selects the number of terms that minimizes AIC, AICc, or BIC. Candidate models are fitted by OLS to a detrended series, where the trend is estimated using supsmu. Optional holiday/trading-day regressors (H) and additive-outlier regressors (AO) are included in every candidate specification if provided.

Usage

find_opt(
  x,
  dates,
  H = NULL,
  AO = NULL,
  method = "additive",
  l.max = 12,
  k.max = 42,
  by = 6
)

Arguments

x

Numeric vector containing the observed weekly time series.

dates

A vector of class "Date" corresponding to the observation dates.

H

Optional matrix of holiday and trading-day regressors with nrow(H) = length(x).

AO

Optional matrix of additive-outlier regressors with nrow(AO) = length(x).

method

Character string specifying the decomposition type. Either "additive" or "multiplicative". If "multiplicative", the series is log-transformed prior to detrending. Defaults to "additive".

l.max

Integer. Maximum number of monthly-cycle Fourier harmonics to consider. Defaults to 12.

k.max

Integer. Maximum number of yearly-cycle Fourier harmonics to consider. Defaults to 42.

by

Integer. Step size for the grid search over k and l. Defaults to 6.

Value

List with the optimal number of (yearly and monthly) fourier variables according to AIC, AICc and BIC.

Examples


data(gasoline.data)

res=find_opt(x=gasoline.data$y,dates=gasoline.data$date)
print(res)


boiwsa documentation built on Dec. 14, 2025, 5:06 p.m.