harmonicfit: Harmonic Fit to Time Series

harmonicfitR Documentation

Harmonic Fit to Time Series

Description

This function fit an k-harmonic function to time series data.

Usage

harmonicfit(x, ...)

Arguments

x

An object of class 'utilities', or 'NULL' (the default). When 'x' is 'NULL' or omitted, the 'utilities' object is created internally, so 'harmonicfit(data = clcep, f1 = f1)' is the recommended usage.

...

Additional arguments for pairing time series:

data

A data frame with three columns corresponding to the time, values, and standard errors of the irregularly observed time series.

f1

frequency (1 / period) of the time series.

nham

Number of harmonic components in the model.

weighted

logical; if true, a weighted least squares (WLS) estimation is performed using weights based on the standard deviations of the errors. Default is 'FALSE'.

remove_trend

logical; if true, the linear trend of time series will be removed before the the harmonic model is fitted.

Details

The function fits a harmonic regression model with 'nham' components to the input time series, optionally removing a linear trend and allowing for weighted estimation when standard errors are available.

Value

An object of class 'utilities' with the slots:

fitted_values

Fitted values from the harmonic model.

residuals

Residuals from the harmonic model.

coef

Estimated coefficients of the harmonic model.

summary

A summary object containing detailed model information.

References

\insertRef

Elorrieta_2021iAR

Examples

data(clcep)
f1=0.060033386
o1=harmonicfit(data=clcep,f1=f1)
head(o1@fitted_values)
head(o1@residuals)

iAR documentation built on Oct. 27, 2026, 5:11 p.m.