Learn R Programming

FCO (version 2.0.0)

plot_fit2: Plotting the distributions of selected simulated fit indices

Description

Plotting the distributions of selected simulated fit indices

Usage

plot_fit2(
  fits = NULL,
  correct.fits = NULL,
  miss.fits = NULL,
  index = "CFI",
  alpha = 0.05,
  beta = 0.1
)

Value

A ggplot2 object with the simulated cutoffs for correct and misspecified models iterated across the number of indices provided.

Arguments

fits

The object returned from gen_fit2 which is a list of correct fit values and misspecified fit values.

correct.fits

For compatibility reasons, the correct fit values can be defined separately.

miss.fits

For compatibility reasons, the misspecified fit values can be defined separately.

index

A vector of length >= 1 with names of fit indices the user wishes to explore. Capitalization does not matter, either e.g., CFI or cfi are accepted. Default is CFI as it might be easier to understand.

alpha

The acceptable Type I error representing the empirical quantile p, see details in gen_fit2. Multiple values can be provided as a vector. Default is .05.

beta

The acceptable Type II error representing the empirical quantile p, see details in gen_fit2. Multiple values can be provided as a vector. Default is c(.05, .10).

Details

For details, please refer to gen_fit2. Please note that the results are only based on the simulation of the model specified and its misspecified variant under the conditions of the gen_fit2 function.

Examples

Run this code
#Simple example
library(lavaan)
library(dplyr)
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
             speed   =~ x7 + x8 + x9 '

fit <- cfa(
  HS.model,
  data = HolzingerSwineford1939
)
#Note: Demonstration only! Please use higher numbers of replications for your applications (>= 500).
fits <- gen_fit2(fit = fit, rep = 100)
#Default plot:
plot_fit2(fits)
#Changed alpha and beta values:
plot_fit2(fits, alpha = .05, beta = .05)
plot_fit2(fits, alpha = .10, beta = .20)
#Different fit indices:
plot_fit2(fits, index = c("CFI", "SRMR", "RMSEA"))

Run the code above in your browser using DataLab