crossvalidate: Cross-Validate a Measurement Model

View source: R/crossvalidate.R

crossvalidateR Documentation

Cross-Validate a Measurement Model

Description

Cross-validate a measurement model obtained from STUART.

Usage

crossvalidate(
  selection,
  old.data,
  new.data,
  max.invariance = "strict",
  filename = NULL
)

Arguments

selection

An object of class stuartOutput.

old.data

A data.frame of the calibration sample.

new.data

A data.frame of the validation sample.

max.invariance

The maximum measurement invariance level which will be tested. Currently there are four options: 'configural', 'weak', 'strong', and 'strict' (the default). All levels below max.invariance are also tested.

filename

The stem of the filenames used to save inputs, outputs, and data files when software='Mplus'. This may include the file path. When NULL (the default) files will be saved to the temporary directory, which is deleted when the R session is ended.

Value

Returns a list containing the data.frame comparison and an object containing the model results of the four different invariance assumptions.

comparison

A data.frame with 4 observations, each observation representing a level of measurement invariance. The number of columns depends on the arguments of the objective used in the original selection. In addition to those columns, three additional columns with the (corrected) Likelihood-Ratio-Tests are reported.

models

A list of the four model results either of class lavaan or mplus.model, depending on the software-setting of the original selection.

Author(s)

Martin Schultze

See Also

holdout, mmas, bruteforce

Examples


# Split data into two halves
data(fairplayer)
half1 <- fairplayer[1:72,]
half2 <- fairplayer[73:143,]

# Simple example from bruteforce
fs <- list(ra = names(fairplayer)[53:57])
sel <- bruteforce(half1, fs, 3,
  cores = 1)  # number of cores set to 1

# Validation
crossvalidate(sel, half1, half2)

# Using the 'holdout' function for data split
data(fairplayer)
split <- holdout(fairplayer, seed = 55635)

# Simple example from bruteforce
fs <- list(ra = names(fairplayer)[53:57])
sel <- bruteforce(split, fs, 3,
  cores = 1)  # number of cores set to 1

# Validation
crossvalidate(sel, split)


stuart documentation built on June 7, 2023, 6:12 p.m.