Learn R Programming

simsem (version 0.2-8)

pValue: Find p-values (1 - percentile)

Description

This function will provide p value from comparing number and vector or the analytic result to the observed data (in SimModelOut) and the simulation result (in SimResult).

Usage

pValue(target, dist, ...)

Arguments

target
A value, multiple values, or a model output 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.
...
Other values that will be explained specifically for each class

Value

  • Mostly, this function provides a vector of p values based on the comparison. If the target is a model output object and dist is a result object, 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. If the target is a critical value (e.g., fit index cutoff) and the dist is the sampling distribution underlying the alternative hypothesis, this function can provide a statistical power.

See Also

  • SimModelOutto see how to get the analysis result of observed data
  • SimResultto run a simulation study
  • runFitto run a simulation study based on the parameter estimates from the analysis result of observed data

Examples

Run this code
# Compare number with a vector
pValue(0.5, rnorm(1000, 0, 1))

# Compare numbers with a data frame
pValue(c(0.5, 0.2), data.frame(rnorm(1000, 0, 1), runif(1000, 0, 1)))

# 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
model <- simParamCFA(LY=loading)
SimModel <- simModel(model, indLab=paste("x", 1:9, sep=""))
u2 <- simUnif(-0.2, 0.2)
loading.trivial <- matrix(NA, 9, 3)
loading.trivial[is.na(loading)] <- 0
LY.trivial <- simMatrix(loading.trivial, "u2")
mis <- simMisspecCFA(LY = LY.trivial)
out <- run(SimModel, HolzingerSwineford1939)
Output2 <- runFit(out, HolzingerSwineford1939, 20, mis)
pValue(out, Output2)

Run the code above in your browser using DataLab