smvalues {scorematchingad} | R Documentation |
Compute Score Matching Discrepancy Value, Gradient, and Hessian
Description
Computes a range of relevant information for investigating score matching estimators.
Usage
smvalues(smdtape, xmat, pmat, xcentres = NA * xmat, approxorder = 10)
smvalues_wsum(
tape,
xmat,
pmat,
w = NULL,
xcentres = NA * xmat,
approxorder = 10
)
Arguments
smdtape |
A taped score matching discrepancy. Most easily created by |
xmat |
A matrix of (multivariate) independent variables where each represents a single independent variable vector. Or a single independent variable vector that is used for all rows of |
pmat |
A matrix of dynamic parameters where each row specifies a new set of values for the dynamic parameters of |
xcentres |
A matrix of approximation for Taylor approximation centres for |
approxorder |
Order of Taylor approximation |
tape |
An |
w |
Weights to apply to each row of |
Details
Computes the score matching discrepancy function from scorematchingtheory
or weighted sum of the score matching discrepancy function.
The gradient and Hessian are returned as arrays of row-vectors with each row corresponding to a row in xmat
and pmat
.
Convert a Hessian row-vector to a matrix using matrix(ncol = length(smdtape$xtape))
.
Value
A list of
-
obj
the score matching discrepancy values -
grad
the gradient of the score matching discrepancy -
hess
the Hessian of the score matching discrepancy
See Also
Other tape evaluators:
evaltape()
,
quadratictape_parts()
,
testquadratic()
Examples
m <- rppi_egmodel(100)
smdtape <- buildsmdtape("sim", "sqrt", "sph", "ppi",
ytape = rep(1/m$p, m$p),
usertheta = ppi_paramvec(beta = m$beta),
bdryw = "minsq", acut = 0.01)$smdtape
smvalues(smdtape, xmat = m$sample, pmat = m$theta[1:5])
smvalues_wsum(smdtape, m$sample, m$theta[1:5])$grad/nrow(m$sample)