Learn R Programming

lavaSearch2 (version 1.4)

leverage2: Extract Leverage Values

Description

Extract leverage values from a Gaussian linear model.

Usage

leverage2(object, ...)

# S3 method for lm leverage2(object, param = NULL, data = NULL, ...)

# S3 method for gls leverage2(object, param = NULL, data = NULL, ...)

# S3 method for lme leverage2(object, param = NULL, data = NULL, ...)

# S3 method for lvmfit leverage2(object, param = NULL, data = NULL, ...)

# S3 method for lm2 leverage2(object, param = NULL, data = NULL, ...)

# S3 method for gls2 leverage2(object, param = NULL, data = NULL, ...)

# S3 method for lme2 leverage2(object, param = NULL, data = NULL, ...)

# S3 method for lvmfit2 leverage2(object, param = NULL, data = NULL, ...)

Arguments

object

a lm2, gls2, lme2, or lvmfit2 object.

...

arguments to be passed to sCorrect.

param

[optional] the fitted parameters.

data

[optional] the data set.

Value

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

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).

If argument p or data is not null, then the small sample size correction is recomputed to correct the residuals.

References

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

See Also

sCorrect to obtain lm2, gls2, lme2, or lvmfit2 objects.

Examples

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

## standard linear model
e.lm <- lm(Y1~Y2, data = d)

sCorrect(e.lm) <- TRUE
range(as.double(leverage2(e.lm)) - influence(e.lm)$hat)

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

# }

Run the code above in your browser using DataLab