Description Usage Arguments Details Value Author(s) Examples
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 absolute sum of errors is computed for each lambda on a grid of values and lambdaHat corresponds to the smallest. An efficient linear programming method is used to fit the model to equi-spaced frequencies in (0,0.5). The fitting algorithm minimizes the sum of the absolute residuals. The frequency is estimated by the model that has the best fit on the grid. The accuracy is controlled K, usually K=500, is sufficient.
1 2 |
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. |
The three parameter harmonic regression model is fitted by least absolute
deviation (LAD) 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.
Note that LAD is MLE when the errors are IID double exponential.
The LAD fitting uses the function rq.fit.br
from the
package quantreg
.
list with the following components
coefficients const, A, B, lambda
residuals
periodogram
z
t
K
model
lambdaRange
Yuanhao Lai and A.I. McLeod
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)
fitHRegL1(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 <- fitHRegL1(z)) #0.06 sec on my computer
system.time(ans2 <- fitHRegL1(z, ncpu=8)) #4.11 sec
identical(ans1, ans2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.