Description Usage Arguments Value Warning Author(s) See Also Examples
Computes finite difference gradients and hessians for the log-likelihood
functions loglikeST
and loglikeSTnaive
.
Uses genGradient
and genHessian
to compute
finite difference derivatives of the log-likelihood function in
loglikeST
and loglikeSTnaive
.
1 2 3 4 5 6 7 8 9 | loglikeSTGrad(x, STmodel, type = "p", x.fixed = NULL, h = 0.001,
diff.type = 0)
loglikeSTHessian(x, STmodel, type = "p", x.fixed = NULL, h = 0.001)
loglikeSTnaiveGrad(x, STmodel, type = "p", x.fixed = NULL, h = 0.001,
diff.type = 0)
loglikeSTnaiveHessian(x, STmodel, type = "p", x.fixed = NULL, h = 0.001)
|
x |
Point at which to compute the gradient or hessian, see
|
STmodel |
|
type |
A single character indicating the type of log-likelihood to compute. Valid options are "f", "p", and "r", for full, profile or restricted maximum likelihood (REML). |
x.fixed |
Parameters to keep fixed, see |
h, diff.type |
Step length and type of finite difference to use when
computing gradients, see |
Returns the gradient or Hessian for the loglikeST
and loglikeSTnaive
functions.
loglikeSTnaiveGrad
and
loglikeSTnaiveHhessian
may take very long time to run,
use with extreme caution.
Johan Lindstrom
Other likelihood functions: loglikeST
Other numerical derivatives: genGradient
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
##load the data
data(mesa.model)
##Compute dimensions for the data structure
dim <- loglikeSTdim(mesa.model)
##Let's create random vectors of values
x <- runif(dim$nparam.cov)
x.all <- runif(dim$nparam)
##Compute the gradients
Gf <- loglikeSTGrad(x.all, mesa.model, "f")
Gp <- loglikeSTGrad(x, mesa.model, "p")
Gr <- loglikeSTGrad(x, mesa.model, "r")
##And the Hessian, this may take some time...
Hf <- loglikeSTHessian(x.all, mesa.model, "f")
Hp <- loglikeSTHessian(x, mesa.model, "p")
Hr <- loglikeSTHessian(x, mesa.model, "r")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.