workhorse {pcme} | R Documentation |
Prepare a closure for the maximum entropy task at hand. This is a relatively low-level function.
f.pcentropy(r, tau, method, autoshrink = TRUE)
r |
a numeric matrix of autocovariances, see Details. |
tau |
a numeric matrix of the same size as r or a list of
season-lag pairs. Indicates the missingness status of
autocovariances, see Details. |
method |
"nlm" or "stabilNewton", indicate method for numerical optimisation, see Details. |
autoshrink |
if TRUE automaticallly reduce the number of parameters for non-linear optimisation, see Details. |
This is a relatively low-level function.
For normal use pcme
should suffice.
r
is a matrix with T rows such that r[k,l]
is
equal to R_k(l-1) but the value r[k,l]=NA
designates the
season-lag pair (k,l) as missing.
tau
is a matrix having the same size as r
indicating the status of each element of r
:
tau[k,l+1] = 1
if R_k(l) is given,
tau[k,l+1] = 0
if R_k(l) corresponds to a gap, and
tau[k,l+1] = 2
if R_k(l) is missing but (k,l) is not
a gap. tau
may be set to 0 for all missing season-lag pairs. By
default the types of the missing values (gaps or not gaps) are
determined automatically, see argument autoshrink
which controls
this.
tau
may also be a list. Each element of this list is a
season-lag pair specifying a missing value.
If method
is "nlm", then the core R function nlm
is used
for non-linear optimisation, otherwise an implementation of the
modified Newton method provided by this package is used.
If autoshrink
is TRUE, then determine the order of the ME model
in advance, classify the missing season-lag pairs as gaps or not gaps,
and optimise with respect to the gaps, see Boshnakov and
Lacroix (2009?) for more information. The acf values for the remaining
missing values are then obtained from the periodic Yule-Walker
equations.
If autoshrink
is not TRUE the order of all seasons is set to
ncol(r)-1
. The two methods give the same values (numerically)
for the missing autocovariances but the non-linear optimisation in the
second one is in larger dimension. Also, the model fitted with
autoshrink=TRUE
is the "true" one, the excessive coefficients
in the second method are theoretically zero but numerically only close
to zero.
The list returned by f.pcentropy
contains functions of several
types.
mesolve
is the function to call to solve the ME problem. It can
be called without arguments. Argument xinit
is effectively
redundant as mesolve
has a very efficient way of locating
initial condition. xinit
was used for testing the behaviour of
the algorithm with extremely weird initial conditions. If xinit
is a scalar (usually 0), then all gaps are filled initially with this
scalar. In fact, f.pcentropy
initialises the gaps with whatever
value were found in the corresponding places in the autocovariance
function (??? does it deal with NA's?). Since the autocovariances have
two indices, it is important when giving initial values to put them in
the vector in the same order as mesolve
expects. If the length
of xinit
is greater than 1 and does not match the number of
gaps, it is ignored. In short, specifying xinit
is hardly
needed but cannot do any harm.
f,fg,fgh
implement the periodic Levinson-Durbin algorithm and
its extension to calculate the entropy, its gradient and Hessian.
f
calculates entropy only,
fg
entropy and gradient, and
fgh
all three. The value returned by these functions is a
scalar (the entropy) with attributtes "gradient" and "hessian" for the
derivatives.
x0
is an initial value and is normally omitted for the ME
problem.
pdq
tests if the current autocovariances are p.d. completable.
makepdq
makes sure that this is so by adding a sufficiently
large constant to the lag zero autocovariances.
ftau
and ftaufull
give the matrix tau
describing
the missingness of season-lag pairs. ftaufull
is the one
obtained after interpreting the input arguments, ftau
is the
one actually used for optimisation. ftau
may have fewer columns
if autoshrink=TRUE
.
findexgaps
and ffreelags
give the gaps and the non-gaps
missing season-lag pairs as two column matrices with each row
containing the position of a season-lag pair in ftau
(so the
corresponding lags are obtained by subtracting 1 from the second
column). (??? check this description!)
After a run of mesolve
, fent
contains the entropy at the
optimal point.
p
is the model order.
fnf
, fckvec
, and totalhistory
contin information
about the running of the algorithm.
(??? Add argument to suppress output and storage of this information.)
The function creates a closure for the maximum entropy task and returns a list whose elements give the user access to the relevant parts of this closure.
mesolve |
function that solves the ME problem. |
f |
the function being optimised. |
fg |
the function being optimised and its gradient. |
fgh |
the function being optimised, its gradient, and Hessian. |
x0 |
function that returns the initial value |
pdq |
function to check if an acf sequence is positive definite. |
makepd |
function that makes an acf positive definite. |
ftau |
a matrix describing the gaps. |
ftaufull |
a matrix describing the gaps. |
findexgaps |
??? |
ffreelags |
??? |
fent |
a function returning the a history of the entropy during the optimisation process. |
p |
model order |
fnf |
function returning the number of evaluations of f . |
fckvec |
??? |
totalhistoty |
function returning comprehensive history of the calculation. |
Georgi Boshnakov
Boshnakov, Georgi and Lambert-Lacroix, Sophie (2009?) Maximum entropy for periodically correlated processes from nonconsecutive autocovariance coefficients. J. Time Series Anal. (to appear)
Lambert-Lacroix, Sophie (2005) Extension of autocovariance coefficients sequence for periodically correlated processes. Journal of Time Series Analysis, 26, No. 6, 423-435.