fitHRegLmrob: Robust Fitting of Four Parameter Harmonic Regression

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Estimates mu, A, B and lambda in the harmonic regression, y(t)=mu+A*cos(2*pi*lambda*t)+B*sin(2*pi*lambda*t)+e(t), where e(t) is assumed IID mean zero and constant variance. The robustbase::lmrob function is used to fit the three parameter harmonic regression of a frequency grid. The optimal frequency corresponds to the harmonic regression with the smallest deviance. The accuracy is controlled K, usually K=500, is sufficient.

Usage

1
2
fitHRegLmrob(z, t = 1:n, K = max(500, floor(length(z)/2)), ncpu = 1,
  lambdaRange = c(1/n, 0.45))

Arguments

z

series.

t

Time points.

K

number of subintervals.

ncpu

number of compute nodes for use with parallel.

lambdaRange

range of frequencies inside (0,0.5), see Details.

Details

The three parameter harmonic regression model is fitted for each frequency in the grid which is a subset of the equi-spaced point {j/(2K+1), j=1,…,K} possibly excluding low and high frequencies as specified by the lambdaRange argument. Frequencies lower than the first Fourier frequency, 1/n, where n is the length time series, n=length(z) are usually due to trend while high frequencies are often not of interest and the numerical algorithm for fitting the 3-parameter harmonic regression is sometimes inaccurate at high. The function lmrob uses the MM robust method which is also implemented in rlm. The algorithm implemented lmrob provides efficient computation. The MM robust regression method is robust as well as resistant to very large outliers.

Value

list with the following components

Author(s)

Yuanhao Lai and A.I. McLeod

References

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

See Also

lmrob, rlm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
z<-c(0.42, 0.89, 1.44, 1.98, 2.21, 2.04, 0.82, 0.62, 0.56, 0.8, 1.33)
fitHRegLmrob(z)
#
#on multicore pcs, more the package parallel may be used for the
#grid computation but unless n is very large this is not recommended.
## Not run:  #adjust ncpu
system.time(ans1 <- fitHRegLmrob(z)) #2.89 sec on my computer
system.time(ans2 <- fitHRegLmrob(z, ncpu=8)) #2.65 sec 
identical(ans1, ans2)

## End(Not run)

CliffordLai/harper documentation built on May 8, 2019, 1:53 p.m.