parameter_restriction {glinvci} | R Documentation |
Restrict the parameters space of OU and Brownian motion models.
Description
ou_diagH
, ou_diagH_fixedtheta_diagSig
, etc., restricts the OU model's
parameters. For example, ou_diagH
restricts the drift to diagonal matrix,
and
ou_diagH_fixedtheta_diagSig
further restricts theta to be a constant and
to be diagonal. A Brownian motion model can be made by these restriction.
Usage
avail_restrictions
brn_diagSig(parfn)
ou_logdiagH(parfn)
dou_logdiagH(jacfn)
hou_logdiagH(hessfn)
ou_logdiagH_diagSig(parfn)
ou_logspdH_fixedtheta(parfn, theta)
ou_spdH_fixedSig(parfn, Sig)
ou_fixedH_diagSig(parfn, H)
dou_logdiagH_diagSig(jacfn)
dou_logspdH_fixedtheta(jacfn, theta)
dou_spdH_fixedSig(jacfn, Sig)
dou_fixedH_diagSig(jacfn, H)
hou_logdiagH_diagSig(hessfn)
hou_logspdH_fixedtheta(hessfn, jacfn, theta)
hou_spdH_fixedSig(hessfn, jacfn, Sig)
hou_spdH_fixedtheta_fixedSig(hessfn, jacfn, theta, Sig)
hou_fixedH_diagSig(hessfn, H)
nparams_ou_logdiagH(k)
nparams_brn(k)
nparams_ou_spdH_fixedSig(k)
Arguments
parfn |
A function that maps from the user-parametrisation to the underlying Gaussian parameters.
Each of them returns a vector of concatenated |
jacfn |
A function that accepts the same arguments as |
hessfn |
A function that accepts the same arguments as |
H |
A numerical vector containing the (flattened) fixed parameter |
theta |
A numerical vector containing the (flattened) fixed parameter |
Sig |
A numerical vector containing the (flattened) fixed parameter |
k |
An integer. The total number of dimensions of the multivariate traits. |
Format
An object of class list
of length 4.
Details
How reparametrisation and restriction works
In the simplest form, without any restriction or reparametrisation, the user typically
needs to pass oupar
, oujac
, ouhess
, all of which are simply
functions which maps from the OU parameters to the Gaussian
paramters
for each node. For example:
mod.full = glinv(tree, x0, my_data, parfns = oupar, pardims = nparams_ou(k), parjacs = oujac, parhess = ouhess)
If one would like to restrict to only positively definite diagonal matrices,
then the call should become
mod.pddiag = glinv(tree, x0, my_data, parfns = ou_logdiagH(oupar), pardims = nparams_ou_logdiagH(k), parjacs = dou_logdiagH(oujac), parhess = hou_logdiagH(ouhess))
Note that there is a naming convention that ou_*
should be applied to 'oupar',
dou_*
to 'oujac', and hou_*
to 'ouhess'. d
stands for ‘derivative’
and h
stands for ‘Hessian’.
In the above call, ou_logdiagH(oupar) accepts the oupar
function as argument
and returns a new function. This new function behaves the same way as oupar itself,
except that it expects its first argument (which is the model parameters) to be of
lower dimension, only consisting of where
is the
diagonal vector of
. The following example should be illustrative:
f = ou_logdiagH(oupar) par.full = list(H = matrix(c(3,0,0,2),2,2), # diagonal matrix theta = c(4,5), sig_x = c(1,0.1,1)) par.restricted = list(H = log(diag(par.full$H)), theta = par.full$theta, sig_x = par.full$sig_x) print(all.equal(f(unlist(par.restricted),1,NULL,NULL), oupar(unlist(par.full),1,NULL,NULL))) # [1] TRUE
Pre-defined restrictions
The following table summarises all the pre-defined ou_*
functions. See oupar
for precise meaning of the mentioned below.
R function | Parameter Format after Restriction |
brn* | . The Brownian motion. and are zero, thus missing. |
*_diagH_* | , with , and H is a diagonal matrix |
*_logdiagH_* | , with , and H is a diagonal matrix |
*_symH_* | , with being lower-triangular part of the symmetric matrix
|
*_spdH_* | , with being Cholesky factor of the S.P.D. matrix
|
*_logspdH_* | where equals , except that on the diagonals =
|
*_fixedH_* | . is constant, hence missing |
*_fixedtheta_* | . is constant, hence missing |
*_fixedSig_* | . is constant, hence missing |
*_diagSig_* | where , with being a diagonal matrix.
|
By Cholesky factor, we mean the only the non-zero part of the lower-triangular Cholesky factor. Restricting to a diagonal matrix
means that
is also diagonal; and the variance of the Brownian motion is
. In other words, the diagonal
restriction is placed on
, not
.
Finding a list of these restriction functions
One can use print(avail_restrictions)
to see a list of all of these restriction function names.
Calling these restriction functions
All *ou_*
or *brn*
functions accepts the same arguemnts as ou_logdiagH
,
dou_logdiagH
, hou_logdiagH
, nparams_ou_logdiagH
as shown in the Usage
and Arguments section, except that:
If the reparametrisation contains any Cholesky decomposition (in other words, the function name contains
spd
orlogspd
) then in the Hessian-level reparameterisation function (namedhou_*
) an extra argumentjacfn
is required.If the reparametrisation contains any fixed parameters, extra arguments
H
,theta
, orSig
are required, depending what is fixed.
For example, in the Usage section, ou_logspdH_fixedtheta
takes an extra argument theta
because
of (2), and hou_spdH_fixedSig
takes extra argument two extra arguments because of both (1) and (2) are
true.