Deltachi: Chi-square difference.

View source: R/Deltachi.R

DeltachiR Documentation

Chi-square difference.

Description

Quantifies case influence on overall model fit by change in the test statistic

Δ_{χ^2_i}=χ^2-χ^2_{(i)}

where χ^2 and χ^2_{(i)} are the test statistics obtained from original and deleted i samples.

Usage

Deltachi(model, data, ..., scaled = FALSE)

Arguments

model

A description of the user-specified model using the lavaan model syntax. See lavaan for more information.

data

A data frame containing the observed variables used in the model. If any variables are declared as ordered factors, this function will treat them as ordinal variables.

...

Additional parameters for sem function.

scaled

Logical, if TRUE the function uses the scaled χ^2 (Rosseel, 2013).

Value

Returns a vector of Δ_{χ^2_i}.

Note

If for observation i model does not converge or yelds a solution with negative estimated variances, the associated value of Δ_{χ^2_i} is set to NA.

This function is a particular case of fitinfluence, see example below.

Author(s)

Massimiliano Pastore

References

Pek, J., MacCallum, R.C. (2011). Sensitivity Analysis in Structural Equation Models: Cases and Their Influence. Multivariate Behavioral Research, 46, 202-228.

Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48, 1-36.

Rosseel, Y. (2022). The lavaan tutorial. URL: https://lavaan.ugent.be/tutorial/.

Examples

## not run: this example take several minutes
data("PDII")
model <- "
  F1 =~ y1+y2+y3+y4
"

# fit0 <- sem(model, data=PDII)
# Dchi <- Deltachi(model,data=PDII)
# plot(Dchi,pch=19,xlab="observations",ylab="Delta chisquare")

## not run: this example take several minutes
## an example in which the deletion of a case yelds a solution 
## with negative estimated variances
model <- "
  F1 =~ x1+x2+x3
  F2 =~ y1+y2+y3+y4
  F3 =~ y5+y6+y7+y8
"

# fit0 <- sem(model, data=PDII)
# Dchi <- Deltachi(model,data=PDII)
# plot(Dchi,pch=19,xlab="observations",ylab="Delta chisquare",main="Deltachi function")

## the case that produces negative estimated variances
# sem(model,data=PDII[-which(is.na(Dchi)),])

## same results 
# Dchi <- fitinfluence("chisq",model,data=PDII)$Dind$chisq
# plot(Dchi,pch=19,xlab="observations",ylab="Delta chisquare",main="fitinfluence function")


influence.SEM documentation built on May 11, 2022, 9:05 a.m.