tape_smd | R Documentation |
For a parametric model family, the function tape_smd()
generates CppAD
tapes for the unnormalised log-density of the model family and of the score matching discrepancy function A(z) + B(z) + C(z)
(defined in scorematchingtheory
).
Three steps are performed by tape_smd()
: first an object that specifies the manifold and any transformation to another manifold is created; then a tape of the unnormalised log-density is created; finally a tape of A(z) + B(z) + C(z)
is created.
tape_smd(
start,
tran = "identity",
end = start,
ll,
ytape,
usertheta,
bdryw = "ones",
acut = 1,
thetatape_creator = function(n) {
seq(length.out = n)
},
verbose = FALSE
)
start |
The starting manifold. Used for checking that |
tran |
The name of a transformation. Available transformations are
|
end |
The name of the manifold that
|
ll |
An unnormalised log-density with respect to the metric of the starting manifold. |
ytape |
An example measurement value to use for creating the tapes. In the natural (i.e. |
usertheta |
A vector of parameter elements for the likelihood function. |
bdryw |
The name of the boundary weight function. "ones" for manifolds without boundary. For the simplex and positive orthant of the sphere, "prodsq" and "minsq" are possible - see |
acut |
A parameter passed to the boundary weight function |
thetatape_creator |
A function that accepts an integer |
verbose |
If |
Only some combinations of start
, tran
and end
are available because tran
must map between start
and end
.
These combinations of start
-tran
-end
are currently available:
sim-sqrt-sph
sim-identity-sim
sim-alr-Euc
sim-clr-Hn111
sph-identity-sph
Euc-identity-Euc
To build a tape for the score matching discrepancy function, the scorematchingad
first tapes the map from a point z
on the end
manifold to the value of the unnormalised log-density, where the independent variable is the z
, the dynamic parameter is a vector of the parameters to estimate, and the remaining model parameters are fixed and not estimated.
This tape is then used to generate a tape for the score matching discrepancy function where the parameters to estimate are the independent variable.
The transforms of the manifold must be implemented in C++
and selected by name.
Currently available unnormalised log-density functions are:
dirichlet
ppi
vMF
Bingham
FB
A list of:
an Rcpp_ADFun
object containing a tape of the unnormalised log-density using the metric of the "end
" manifold (that is the independent variable is on the end
manifold).
an Rcpp_ADFun
object containing a tape of the score matching discrepancy function with the non-fixed parameters of the model as the independent variable, and the measurements on the end
manifold as the dynamic parameter.
some information about the tapes
There is no checking of the inputs ytape
and usertheta
.
Other tape builders:
tape_Hessian()
,
tape_Jacobian()
,
tape_gradoffset()
,
tape_logJacdet()
,
tape_swap()
,
tape_uld()
Other generic score matching tools:
Windham()
,
cppad_closed()
,
cppad_search()
p <- 3
u <- rep(1/sqrt(p), p)
ltheta <- p #length of vMF parameter vector
intheta <- rep(NA, length.out = ltheta)
tapes <- tape_smd("sph", "identity", "sph", "vMF",
ytape = u,
usertheta = intheta,
"ones", verbose = FALSE
)
evaltape(tapes$lltape, u, runif(n = ltheta))
evaltape(tapes$smdtape, runif(n = ltheta), u)
u <- rep(1/3, 3)
tapes <- tape_smd("sim", "sqrt", "sph", "ppi",
ytape = u,
usertheta = ppi_paramvec(p = 3),
bdryw = "minsq", acut = 0.01,
verbose = FALSE
)
evaltape(tapes$lltape, u, rppi_egmodel(1)$theta)
evaltape(tapes$smdtape, rppi_egmodel(1)$theta, u)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.