Learn R Programming

lavaSearch2 (version 1.0.0)

iid2: Extract i.i.d. decomposition from linear and latent variable models

Description

Extract i.i.d. decomposition from linear and latent variable models using leverage adjusted fitted residuals.

Usage

iid2(x, ...)

# S3 method for lm iid2(x, p = NULL, data = NULL, adjust.residuals = TRUE, ...)

# S3 method for gls iid2(x, p = NULL, data = NULL, adjust.residuals = TRUE, ...)

# S3 method for lme iid2(x, p = NULL, data = NULL, adjust.residuals = TRUE, ...)

# S3 method for lvmfit iid2(x, p = NULL, data = NULL, adjust.residuals = TRUE, ...)

Arguments

x

a linear model or a latent variable model

...

arguments to be passed to score2.

p

[optional] the fitted parameters.

data

[optional] the data set.

adjust.residuals

Should the leverage-adjusted residuals be used to compute the score? Otherwise the raw residuals will be used.

Value

A matrix.

Details

Leverage-adjusted residuals have been shown to improve the coverage of robust standard errors in small samples. They are computed according to the formula: \(e_adj = \frac{e}{(1-h_{ii})^(1/2)}\)

References

Bell, R. M., & McCaffrey, D. F. Bias reduction in standard errors for linear regression with multi-stage samples. Survey Methodology, 28(2), 169-181 (2002). Kauermann G. and Carroll R. J. A note on the efficiency of sandwich covariance matrix estimation. Journal of the American Statistical Association. Vol. 96, No. 456 (2001).

Examples

Run this code
# NOT RUN {
n <- 5e1
p <- 3
X.name <- paste0("X",1:p)
link.lvm <- paste0("Y~",X.name)
formula.lvm <- as.formula(paste0("Y~",paste0(X.name,collapse="+")))

m <- lvm(formula.lvm)
distribution(m,~Id) <- sequence.lvm(0)
set.seed(10)
d <- sim(m,n)

## linear model
e.lm <- lm(formula.lvm,data=d)
iid.tempo <- iid2(e.lm, adjust.residuals = FALSE)
range(iid.tempo[,1:4]-iid(e.lm))

## latent variable model
e.lvm <- estimate(lvm(formula.lvm),data=d)
iid.tempo <- iid2(e.lvm, adjust.residuals = FALSE)
range(iid.tempo-iid(e.lvm))
## difference due to the use of the observed info matrix vs. the expected one.

# }

Run the code above in your browser using DataLab