Learn R Programming

simsem (version 0.5-16)

pValue: Find p-values (1 - percentile) by comparing a single analysis output from the result object

Description

This function will provide p value from comparing a '>lavaan) or a OpenMx result from the simulation result (in '>SimResult).

Usage

pValue(target, dist, usedFit = NULL, nVal = NULL, pmMCARval = NULL, 
	pmMARval = NULL, df = 0)

Arguments

target

A value, multiple values, a lavaan object, or an OpenMx object used to find p values. This argument could be a cutoff of a fit index.

dist

The comparison distribution, which can be a vector of numbers, a data frame, or a result object.

usedFit

The vector of names of fit indices that researchers wish to find the p value from.

nVal

The sample size value that researchers wish to find the fit indices cutoffs from

pmMCARval

The percent missing completely at random value that researchers wish to find the fit indices cutoffs from.

pmMARval

The percent missing at random value that researchers wish to find the fit indices cutoffs from.

df

The degree of freedom used in spline method in predicting the fit indices by the predictors. If df is 0, the spline method will not be applied.

Value

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.

Details

In comparing fit indices, the p value is the proportion of the number of replications that provide poorer fit (e.g., less CFI value or greater RMSEA value) than the analysis result from the observed data.

See Also

  • '>SimResult to run a simulation study

Examples

Run this code
# NOT RUN {
# Compare an analysis result with a result of simulation study
library(lavaan)
loading <- matrix(0, 9, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 3] <- NA
targetmodel <- estmodel(LY=loading, modelType="CFA", indLab=paste("x", 1:9, sep=""))
out <- analyze(targetmodel, HolzingerSwineford1939)

loading.trivial <- matrix("runif(1, -0.2, 0.2)", 9, 3)
loading.trivial[is.na(loading)] <- 0
mismodel <- model.lavaan(out, std=TRUE, LY=loading.trivial)

# The actual number of replications should be much greater than 20.
simout <- sim(20, n=nrow(HolzingerSwineford1939), mismodel)

# Find the p-value comparing the observed fit indices against the simulated 
# sampling distribution of fit indices
pValue(out, simout)
# }

Run the code above in your browser using DataLab