harmonic function

Construct harmonic functions for fitting harmonic trend model

Construct harmonic functions for fitting harmonic trend model

The function creates a matrix of the first m pairs of harmonic functions for fitting a harmonic trend (cosine-sine trend, Fourier regresssion) models with the response being x, a time series.

harmonic(x, m = 1)

Arguments

  • x: a time series
  • m: the number of pairs of harmonic functions to be created; 2m must be less than or equal to the frequency of x

Returns

a matrix consisting of cos(2kπt),sin(2kπt),k=1,2,...,m,\cos(2k \pi t), \sin(2k \pi t), k=1,2,...,m,

excluding any zero functions.

Author(s)

Kung-Sik Chan

See Also

season

Examples

data(tempdub) # first creates the first pair of harmonic functions and then fit the model har.=harmonic(tempdub,1) model4=lm(tempdub~har.) summary(model4)