pValueNested {simsem} | R Documentation |
Find p-values (1 - percentile) for a nested model comparison
Description
This function will provide p value from comparing the differences in fit indices between nested models with the simulation results of both parent and nested models when the nested model is true.
Usage
pValueNested(outNested, outParent, simNested, simParent, usedFit = NULL,
nVal = NULL, pmMCARval = NULL, pmMARval = NULL, df = 0)
Arguments
outNested |
|
outParent |
|
simNested |
|
simParent |
|
usedFit |
Vector of names of fit indices that researchers wish to getCutoffs from. The default is to getCutoffs of all fit indices. |
nVal |
The sample size value that researchers wish to find the p value from. |
pmMCARval |
The percent missing completely at random value that researchers wish to find the p value from. |
pmMARval |
The percent missing at random value that researchers wish to find the the p value from. |
df |
The degree of freedom used in spline method in predicting the fit indices by the predictors. If |
Details
In comparing fit indices, the p value is the proportion of the number of replications that provide less preference for nested model (e.g., larger negative difference in CFI values or larger positive difference in RMSEA values) than the analysis result from the observed data.
Value
This function provides a vector of p values based on the comparison of the difference in fit indices from the real data with the simulation result. The p values of fit indices are provided, as well as two additional values: andRule
and orRule
. The andRule
is based on the principle that the model is retained only when all fit indices provide good fit. The proportion is calculated from the number of replications that have all fit indices indicating a better model than the observed data. The proportion from the andRule
is the most stringent rule in retaining a hypothesized model. The orRule
is based on the principle that the model is retained only when at least one fit index provides good fit. The proportion is calculated from the number of replications that have at least one fit index indicating a better model than the observed data. The proportion from the orRule
is the most lenient rule in retaining a hypothesized model.
Author(s)
Sunthud Pornprasertmanit (psunthud@gmail.com)
See Also
-
SimResult
to run a simulation study
Examples
## Not run:
library(lavaan)
# Nested Model: Linear growth curve model
LY <- matrix(1, 4, 2)
LY[,2] <- 0:3
PS <- matrix(NA, 2, 2)
TY <- rep(0, 4)
AL <- rep(NA, 2)
TE <- diag(NA, 4)
nested <- estmodel(LY=LY, PS=PS, TY=TY, AL=AL, TE=TE, modelType="CFA",
indLab=paste("t", 1:4, sep=""))
# Parent Model: Unconditional growth curve model
LY2 <- matrix(1, 4, 2)
LY2[,2] <- c(0, NA, NA, 3)
parent <- estmodel(LY=LY2, PS=PS, TY=TY, AL=AL, TE=TE, modelType="CFA",
indLab=paste("t", 1:4, sep=""))
# Analyze the output
outNested <- analyze(nested, Demo.growth)
outParent <- analyze(parent, Demo.growth)
# Create data template from the nested model with small misfit on the linear curve
loadingMis <- matrix(0, 4, 2)
loadingMis[2:3, 2] <- "runif(1, -0.1, 0.1)"
datamodel <- model.lavaan(outNested, LY=loadingMis)
# Get the sample size
n <- nrow(Demo.growth)
# The actual replications should be much greater than 30.
simNestedNested <- sim(30, n=n, nested, generate=datamodel)
simNestedParent <- sim(30, n=n, parent, generate=datamodel)
# Find the p-value comparing the observed fit indices against the simulated
# sampling distribution of fit indices
pValueNested(outNested, outParent, simNestedNested, simNestedParent)
## End(Not run)