Description Usage Arguments Details Value Note Author(s) See Also 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. Four estimation methods are available least-squares (LS), least absolute deviation (L1) and a robust regression methods (MM).
1 2 |
z |
series. |
method |
one of "LS", "L1", "MM"/ |
K |
number of subintervals. |
ncpu |
default 1. |
exactQ, |
default setting is FALSE. It indicates whether nolinear optimizer is used to obtain the final estimate of the frequency. |
The recommended setting of ncpu is 1 - see note.
The default setting for K is the 500 or the number of Fourier frequencies -
whichever is larger.
LS regression uses the QR algorithm directly to efficiently compute the
residual sum of squares.
L1-regression is fitted using the function rq.fit.br
in the package quantreg
.
Robust regression uses the robustbase
package function lmrob
.
The parallel package may be used to improve the efficiency for long time
series but when the series length is less than 100 using ncpu=1 with K=500
is much faster due to the overhead - despite using splitIndices
to balance the load on each compute note.
list with the following components
coefficients const, A, B, lambda
residuals
periodogram
z
t
K
model
lambdaRange
The parallel
package may be used to speed up the computation on the
frequency grid but on Windows machines the overhead for computation is so
large that this is not usually effective unless the series length is quite
long. See nottem
in the example section. It was surprising that the
overhead was so large despite using splitIndices
to balance
the load on each cpu.
Yuanhao Lai and A. I. McLeod
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | z<-c(0.42, 0.89, 1.44, 1.98, 2.21, 2.04, 0.82, 0.62, 0.56, 0.8, 1.33)
hreg(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 <- hreg(z)) #0.06 sec on my computer
system.time(ans2 <- hreg(z, ncpu=8)) #1.67 sec
system.time(ans3 <- hreg(z, method="L1")) #0.06 sec on my computer
system.time(ans4 <- hreg(z, method="L1", ncpu=8)) #4.11 sec
system.time(ans5 <- hreg(z, method="MM")) #2.89 sec on my computer
system.time(ans6 <- hreg(z, method="MM", ncpu=8)) #2.65 sec
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.