Fit an lspec
model
to a time-series or a periodogram.
lspec(data, period, penalty, minmass, knots, maxknots, atoms, maxatoms,
maxdim , odd = FALSE, updown = 3, silent = TRUE)
time series (exactly one of data
and period
should be specified).
If data
is specified, lspec
first computes the modulus
of the fast Fourier transform
of the series using the function
fft
, resulting in a periodogram of length
floor(length(data)/2)
.
value of the periodogram for a time series at frequencies
\(\frac{2\pi j}T\), for \(1\leq j \leq T/2\). If period is specified, odd should indicate
whether the length of the series T is odd (odd = TRUE)
or even (odd = FALSE)
.
Exactly one of data
and period
should be specified.
the parameter to be used in the AIC criterion. The method chooses
the number of basis
functions that minimizes -2 * loglikelihood + penalty * (number of basis
functions)
.
Default is to use a penalty parameter of penalty = log(length(period))
as in BIC.
threshold value for atoms. No atoms having smaller mass than minmass
are
included in the model. If minmass
takes its default value, in
95% of the samples, when data is Gaussian white noise, the model will not
contain atoms.
ordered vector of values, which forces the method to start with these knots.
If knots
is not specified, the program starts with one knot at zero and then
employs stepwise addition of knots and atoms.
maximum number of knots allowed in the model. Does not need to be
specified, since the program has a default for maxdim
and
the number of dimensions equals the number of knots plus the number of
atoms. If maxknots = 1
the fitted spectral density function is
constant.
ordered vector of values, which forces the method to start with discrete components at these frequencies. The values of atoms are rounded to the nearest multiple of \(\frac{2\pi}T\). If atoms is not specified, the program starts with no atoms and then performs stepwise addition of knots and atoms.
maximum number of discrete components allowed in the model. Does not need to be
specified, since the program has a default for maxdim
and
the number of dimensions equals the number of knots plus the number of
atoms. If maxatoms = 0
a continuous
spectral distribution is fit.
maximum number of basis functions allowed in the model (default is \(\max(15,4\times\mbox{length(period)}^{0.2})\)).
see period
. If period
is not specified, odd
is not relevant.
the maximal number of times that lspec
should go through a cycle of stepwise
addition and stepwise deletion until a stable solution is reached.
should printing of information be suppressed?
Object of class lspec
.
The output is organized to serve as input for plot.lspec
(summary plots),
summary.lspec
(summarizes fitting), clspec
(for
autocorrelations and autocovariances), dlspec
(for spectral density and line-spectrum,)
plspec
(for the spectral distribution), and rlspec
(for random time series with the same spectrum).
the command that was executed.
coefficients of the polynomial part of the spline.
the number of knots that were retained.
vector of the locations of the knots in the logspline model. Only the knots that were retained are in this vector.
coefficients of the knot part of the spline. The k-th coefficient is the coefficient of \((x-t(k))^3_+\).
the number of atoms that were retained.
vector of the locations of the atoms in the model. Only the atoms that were retained are in this vector.
The k-th coefficient is the mass at atom[k]
.
the log-likelihood of the model.
the penalty that was used.
the minimum mass for an atom that was allowed.
the sample size that was used, either computed as length(data)
or
as (2 * length(period))
when odd = FALSE
or as
(2 * length(period) + 1)
when odd = TRUE
.
the actual number of times that lspec
went through a cycle of
stepwise addition and stepwise deletion
until a stable solution was reached, or
minus the number of times that lspec went through a cycle of
stepwise addition and stepwise deletion until it decided to quit.
Charles Kooperberg, Charles J. Stone, and Young K. Truong (1995). Logspline Estimation of a Possibly Mixed Spectral Distribution. Journal of Time Series Analysis, 16, 359-388.
Charles J. Stone, Mark Hansen, Charles Kooperberg, and Young K. Truong. The use of polynomial splines and their tensor products in extended linear modeling (with discussion) (1997). Annals of Statistics, 25, 1371--1470.
# NOT RUN {
data(co2)
co2.detrend <- unstrip(lm(co2~c(1:length(co2)))$residuals)
fit <- lspec(co2.detrend)
# }
Run the code above in your browser using DataLab