/ Home
S-Archive Download Script
lsfreq Least Squares Frequency Estimation
Estimates a sum of sinusoidal signals by separable least squares with Levenberg damping.
y numeric vector of observations. Missing values not allowed.
freq numeric vector of starting values for the frequencies.
x numeric vector of time points. The default is 0:(length(y)-1).
constant logical constant. True if a constant term or intercept is to be included in the model.
trace logical constant. If true frequencies and residual sum of squares are printed at each iteration.
freq numeric vector of estimated frequencies.
coef numeric vector of estimated coefficients.
fitted numeric vector of same length as y of fitted values.
residuals numeric vector of same length as y of residuals.
If constant = T then the assumed model is

y = a[1] + a[2]*cos(x*f[1]) + ... + a[p+1]*cos(x*f[p]) + a[p+2]*sin(x*f[1]) + ... + a[2*p+1]*sin(x*f[p])

where coef = a, freq = f and p = length(f). If constant = F then the model is

y = a[1]*cos(x*f[1]) + ... + a[p]*cos(x*f[p]) + a[p+1]*sin(x*f[1]) + ... + a[2*p]*sin(x*f[p])

The estimation algorithm is a Gauss-Newton algorithm in which the linear coefficients a[] are set to their known values conditional on the frequencies. Levenberg damping is used to ensure that each iteration reduces the residual sum of squares.

Smyth, G. K. (1996). Partitioned algorithms for maximum likelihood and other nonlinear estimation. Statistics and Computing, 6, 201-216. (PDF).
mmfreq, robfreq
Estimate the signal for the Variable Star data set. The pronyfreq function is used to obtain starting values. In this case the starting values are good enough!
> ora <- pronyfreq(star,nfreq=2)
> ora$freq
[1] 0.2166596 0.2617983
> ora$coef
[1] 17.0857822411  7.6477245734  0.0009274355  6.4906186247  7.0845674915
> out.ls <- lsfreq(star,freq=ora$freq,constant=T)
> out.ls$freq
[1] 0.2166595 0.2617983
> out.ls$coef
[1] 17.085781788  7.647776911  0.001107758  6.490566875  7.084562954


S-Archive Download Script

Gordon Smyth. Copyright © 1996-2016. Last modified: 10 February 2004