Learn R Programming

lavaSearch2 (version 2.0.3)

leverage2: Leverage With Small Sample Correction.

Description

Extract leverage values from a latent variable model, with small sample correction.

Usage

leverage2(object, format, ssc, ...)

# S3 method for lvmfit leverage2(object, format = "wide", ssc = lava.options()$ssc, ...)

# S3 method for lvmfit2 leverage2(object, format = "wide", ...)

Value

a matrix containing the leverage relative to each sample (in rows) and each endogenous variable (in column).

Arguments

object

a lvmfit or lvmfit2 object (i.e. output of lava::estimate or lavaSearch2::estimate2).

format

[character] Use "wide" to return the residuals in the wide format (one row relative to each sample). Otherwise use "long" to return the residuals in the long format.

ssc

[character] method used to correct the small sample bias of the variance coefficients: no correction ("none"/FALSE/NA), correct the first order bias in the residual variance ("residual"), or correct the first order bias in the estimated coefficients "cox"). Only relevant when using a lvmfit object.

...

additional argument passed to estimate2 when using a lvmfit object.

Details

The leverage are defined as the partial derivative of the fitted values with respect to the observations. $$ leverage_i = \frac{\partial \hat{Y}_i}{\partial Y_i} $$ See Wei et al. (1998).

When argument object is a lvmfit object, the method first calls estimate2 and then extract the leverage.

References

Bo-Cheng Wei et al., Generalized Leverage and its applications (1998), Scandinavian Journal of Statistics 25:1:25-37.

See Also

estimate2 to obtain lvmfit2 objects.

Examples

Run this code
#### simulate data ####
set.seed(10)
m <- lvm(Y1~eta,Y2~eta,Y3~eta)
latent(m) <- ~eta
d <- lava::sim(m,20, latent = FALSE)

#### latent variable models ####
e.lvm <- estimate(m, data = d)
leverage2(e.lvm)

Run the code above in your browser using DataLab