Learn R Programming

lavaSearch2 (version 1.4)

iid2: Extract corrected i.i.d. decomposition

Description

Extract corrected i.i.d. decomposition from a gaussian linear model.

Usage

iid2(object, ...)

# S3 method for lm iid2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for gls iid2(object, cluster = NULL, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for lme iid2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for lvmfit iid2(object, param = NULL, data = NULL, bias.correct = TRUE, ...)

# S3 method for lm2 iid2(object, cluster = NULL, param = NULL, data = NULL, robust = TRUE, ...)

# S3 method for gls2 iid2(object, cluster = NULL, param = NULL, data = NULL, robust = TRUE, ...)

# S3 method for lme2 iid2(object, cluster = NULL, param = NULL, data = NULL, robust = TRUE, ...)

# S3 method for lvmfit2 iid2(object, cluster = NULL, data = NULL, ...)

Arguments

object

a linear model or a latent variable model

...

arguments to be passed to sCorrect.

param

[named numeric vector] the fitted parameters.

data

[data.frame] the data set.

bias.correct

[logical] should the standard errors of the coefficients be corrected for small sample bias? Only relevant if the sCorrect function has not yet be applied to the object.

cluster

[integer vector] the grouping variable relative to which the observations are iid.

robust

[logical] if FALSE, the i.i.d. decomposition is rescaled such its the squared sum equals the model-based standard error (instead of the robust standard error).

Value

A matrix containing the 1st order influence function relative to each sample (in rows) and each model coefficient (in columns).

Details

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

See Also

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

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, bias.correct = 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, bias.correct = FALSE)
range(iid.tempo-iid(e.lvm))
## difference due to the use of the observed info matrix vs. the expected one.

## rescale i.i.d using model-based standard error
iid.tempo <- iid2(e.lvm, robust = FALSE, bias.correct = FALSE)
diag(crossprod(iid.tempo))-diag(vcov(e.lvm))

# }

Run the code above in your browser using DataLab