fitHRegLS: LS Fit for Four Parameter Harmonic Regression

Description Usage Arguments Details Value Author(s) 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 NID mean zero and constant variance. The default algorithm is enumerative.

Usage

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

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.

exactQ,

default setting is FALSE. It indicates whether nolinear optimizer is used to obtain the final estimate of the frequency.

Details

The QR decomposition is used to efficiently compute the residual sum of squares on the grid. When exactQ=TRUE, a NLS algorithm is used and NLS is indicated in the output title.

Value

list with the following components

Author(s)

Yuanhao Lai and A.I. McLeod

See Also

qr

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)
fitHRegLS(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 <- fitHRegLS(z)) #0.06 sec on my computer
system.time(ans2 <- fitHRegLS(z, ncpu=8)) #1.67 sec 
identical(ans1, ans2)

## End(Not run)

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