Learn R Programming

influence.SEM (version 2.4)

sem.fitres: Fitted values and residuals

Description

It calculates the expected values and the residuals of a sem model.

Usage

sem.fitres(object)
obs.fitres(object)
lat.fitres(object)

Value

Returns a data frame containing: 1) The observed model variables; 2) The expected values on dependent variables (indicated with hat.); 3) The residuals on dependent variables (indicated with e.)

Arguments

object

An object of class lavaan.

Author

Massimiliano Pastore

Details

The main function, sem.fitres(), calls one of the other two routines depending on the type of the model. If model does not contain latent variables, sem.fitres() calls the function obs.fitres(), otherwise calls the function lat.fitres().

The functions obs.fitres() and lat.fitres() are internal functions, do not use it directly.

Examples

Run this code
data("PDII")
model <- "
  F1 =~ y1+y2+y3+y4
"

fit0 <- sem(model, data=PDII)
out <- sem.fitres(fit0)
head(out)

par(mfrow=c(2,2))
plot(e.y1~hat.y1,data=out)
plot(e.y2~hat.y2,data=out)
plot(e.y3~hat.y3,data=out)
plot(e.y4~hat.y4,data=out)

qqnorm(out$e.y1); qqline(out$e.y1)
qqnorm(out$e.y2); qqline(out$e.y2)
qqnorm(out$e.y3); qqline(out$e.y3)
qqnorm(out$e.y4); qqline(out$e.y4)

Run the code above in your browser using DataLab