Learn R Programming

lavaSearch2 (version 1.4)

score2: Extract The Individual Score

Description

Extract The Individual Score from a gaussian linear model.

Usage

score2(object, ...)

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

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

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

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

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

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

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

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

Arguments

object

a linear model or a latent variable model

...

arguments to be passed to sCorrect.

param

[optional] the fitted parameters.

data

[optional] 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.

Value

A matrix containing the score 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 <- lava::sim(m,n)

## linear model
e.lm <- lm(formula.lvm,data=d)
score.tempo <- score2(e.lm, bias.correct = FALSE)
colMeans(score.tempo)

## latent variable model
e.lvm <- estimate(lvm(formula.lvm),data=d)
score.tempo <- score2(e.lvm, bias.correct = FALSE)
range(score.tempo-score(e.lvm, indiv = TRUE))

# }

Run the code above in your browser using DataLab