Learn R Programming

lavaSearch2 (version 1.4)

skeleton: Pre-computation for the Score

Description

Pre-compute quantities that are necessary to compute the score of a lvm model.

Usage

skeleton(object, ...)

# S3 method for lvm skeleton(object, as.lava, name.endogenous, name.latent, ...)

# S3 method for lvmfit skeleton(object, param, data, name.endogenous, name.latent, ...)

skeletonDtheta(object, ...)

# S3 method for gls skeletonDtheta(object, class.cor, class.var, X, sigma2.base0, Msigma2.base0, M.corcoef, ref.group, index.lower.tri, indexArr.lower.tri, name.endogenous, n.endogenous, cluster, n.cluster, var.coef, name.varcoef, name.otherVar, n.varcoef, cor.coef, name.corcoef, n.corcoef, index.Omega, update.mean, update.variance, ...)

# S3 method for lme skeletonDtheta(object, name.endogenous, n.endogenous, name.rancoef, ...)

# S3 method for lvm skeletonDtheta(object, data, df.param.all, param2originalLink, name.endogenous, name.latent, ...)

# S3 method for lvmfit skeletonDtheta(object, name.endogenous, name.latent, ...)

skeletonDtheta2(object, ...)

# S3 method for gls skeletonDtheta2(object, dOmega = NULL, class.cor = NULL, class.var = NULL, M.corcoef = NULL, n.endogenous = NULL, index.lower.tri = NULL, indexArr.lower.tri = NULL, var.coef = NULL, name.otherVar = NULL, name.varcoef = NULL, n.varcoef = NULL, cor.coef = NULL, name.corcoef = NULL, ...)

# S3 method for lme skeletonDtheta2(object, dOmega = NULL, class.cor = NULL, class.var = NULL, M.corcoef = NULL, n.endogenous = NULL, index.lower.tri = NULL, indexArr.lower.tri = NULL, var.coef = NULL, name.otherVar = NULL, name.varcoef = NULL, n.varcoef = NULL, cor.coef = NULL, name.corcoef = NULL, ...)

# S3 method for lm skeletonDtheta2(object, ...)

# S3 method for lvm skeletonDtheta2(object, data, df.param.all, param2originalLink, name.latent, ...)

# S3 method for lvmfit skeletonDtheta2(object, ...)

Arguments

object

a lvm object.

...

[internal] only used by the generic method.

as.lava

[logical] should the name of the links be used to name the coefficient? Otherwise uses the labels (when defined) of each coefficient.

name.endogenous

[character vector] name of the endogenous variables

name.latent

[character vector] name of the latent variables

data

[data.frame, optional] data set.

df.param.all

[data.frame] output of coefType containing the type of each coefficient.

param2originalLink

[named character vector] matching between the name of the coefficient in lava and their label.

B, alpha.XGamma, Lambda, Psi

[matrix] pre-computed matrix.

OD

[list] the pre-computed quantities for the second derivatives.

p

[numeric vector, optional] vector of coefficients at which to evaluate the score.

Details

When the use specify names for the coefficients (e.g. Y1[mu:sigma]) or uses constrains (Y1~beta*X1), as.lava=FALSE will use the names specified by the user (e.g. mu, sigma, beta) while as.lava=TRUE will use the name of the first link defining the coefficient.

Examples

Run this code
# NOT RUN {
skeleton <- lavaSearch2::skeleton
skeleton.lvm <- lavaSearch2::skeleton.lvm
skeleton.lvmfit <- lavaSearch2::skeleton.lvmfit

## without constrain
m <- lvm(Y1~X1+X2+eta,Y2~X3+eta,Y3~eta)
latent(m) <- ~eta

e <- estimate(m, lava::sim(m,1e2))
M.data <- as.matrix(model.frame(e))

skeleton(e$model, as.lava = TRUE,
         name.endogenous = endogenous(e), n.endogenous = 3,
         name.latent = latent(e), 
         update.value = FALSE)
skeleton(e, data = M.data, p = pars(e), as.lava = TRUE,
         name.endogenous = endogenous(e), n.endogenous = 3,
         name.latent = latent(e), 
         update.value = TRUE)

## with constrains
m <- lvm(Y[mu:sigma] ~ beta*X1+X2)
e <- estimate(m, lava::sim(m,1e2))
M.data <- as.matrix(model.frame(e))

skeleton(e$model, as.lava = TRUE,
         name.endogenous = "Y", n.endogenous = 1,
         name.latent = NULL, 
         update.value = FALSE)$skeleton

skeleton(e, data = M.data, p = pars(e), as.lava = FALSE,
         name.endogenous = "Y", n.endogenous = 1,
         name.latent = NULL, 
         update.value = FALSE)$skeleton

# }

Run the code above in your browser using DataLab