objectivematrices: Generate matrix-components for objective functions.

View source: R/objectivematrices.R

objectivematricesR Documentation

Generate matrix-components for objective functions.

Description

Generate objects of the correct structure for use in custom objective functions.

Usage

objectivematrices(
  data,
  factor.structure,
  capacity = NULL,
  matrices = c("lvcor"),
  n.random = 0,
  item.invariance = "congeneric",
  repeated.measures = NULL,
  long.invariance = "strict",
  mtmm = NULL,
  mtmm.invariance = "configural",
  grouping = NULL,
  group.invariance = "strict",
  comparisons = NULL,
  auxiliary = NULL,
  use.order = FALSE,
  software = "lavaan",
  cores = NULL,
  objective = NULL,
  ignore.errors = FALSE,
  analysis.options = NULL,
  suppress.model = FALSE,
  ...
)

Arguments

data

A data.frame containing all relevant data.

factor.structure

A list linking factors to items. The names of the list elements correspond to the factor names. Each list element must contain a character-vector of item names that are indicators of this factor.

capacity

A list containing the number of items per subtest. This must be in the same order as the factor.structure provided. If a single number, it is applied to all subtests. If NULL all items are evenly distributed among the subtests.

matrices

Which matrix to extract. Can be one of 'lvcor' (the default) for latent correlations, 'lambda', 'theta', 'psi', or 'alpha' for the model-implied matrices.

n.random

The number of random draws to base values on. If 0 (the default) values are in the matrices are set to 0 and can be overwritten later. If any value larger than 0, the mean from n.random random solutions is used.

item.invariance

A character vector of length 1 or the same length as factor.structure containing the desired invariance levels between items pertaining to the same subtest. Currently there are five options: 'congeneric', 'ess.equivalent', 'ess.parallel', 'equivalent', and 'parallel', the first being the default.

repeated.measures

A list linking factors that are repeated measures of each other. Repeated factors must be in one element of the list - other sets of factors in other elements of the list. When this is NULL (the default) a cross-sectional model is estimated.

long.invariance

A character vector of length 1 or the same length as repeated.measures containing the longitudinal invariance level of repeated items. Currently there are four options: 'configural', 'weak', 'strong', and 'strict'. Defaults to 'strict'. When repeated.measures=NULL this argument is ignored.

mtmm

A list linking factors that are measurements of the same construct with different methods. Measurements of the same construct must be in one element of the list - other sets of methods in other elements of the list. When this is NULL (the default) a single method model is estimated.

mtmm.invariance

A character vector of length 1 or the same length as mtmm containing the invariance level of MTMM items. Currently there are five options: 'none', 'configural', 'weak', 'strong', and 'strict'. Defaults to 'configural'. With 'none' differing items are allowed for different methods. When mtmm=NULL this argument is ignored.

grouping

The name of the grouping variable. The grouping variable must be part of data provided and must be a numeric variable.

group.invariance

A single value describing the assumed invariance of items across groups. Currently there are four options: 'configural', 'weak', 'strong', and 'strict'. Defaults to 'strict'. When grouping=NULL this argument is ignored.

comparisons

A character vector containing any combination of 'item', 'long', 'mtmm', and 'group' indicating which invariance should be assessed via model comparisons. The order of the vector dictates the sequence in which model comparisons are performed. Defaults to NULL meaning that no model comparisons are performed.

auxiliary

The names of auxiliary variables in data. These can be used in additional modeling steps that may be provided in analysis.options$model.

use.order

A logical indicating whether or not to take the selection order of the items into account. Defaults to FALSE.

software

The name of the estimation software. Can currently be 'lavaan' (the default) or 'Mplus'. Each option requires the software to be installed.

cores

The number of cores to be used in parallel processing. If NULL (the default) the result of detectCores will be used. On Unix-y machines parallel processing is implemented via mclapply, on Windows machines it is realized via parLapply.

objective

A function that converts the results of model estimation into a pheromone. See 'details' for... details.

ignore.errors

A logical indicating whether or not to ignore estimation problems (such as non positive-definite latent covariance matrices). Defaults to FALSE.

analysis.options

A list additional arguments to be passed to the estimation software. The names of list elements must correspond to the arguments changed in the respective estimation software. E.g. analysis.options$model can contain additional modeling commands - such as regressions on auxiliary variables.

suppress.model

A logical indicating whether to suppress the default model generation. If TRUE a model must be provided in analysis.options$model.

...

Additional arguments passed either to randomsamples or to lavaan.

Value

Returns an object of class stuartFixedObjective

Author(s)

Martin Schultze

See Also

empiricalobjective, extractobjective, objectivematrices

Examples


# Extract latent correlation matric
# requires lavaan
# number of cores set to 1 in all examples
data(sups)
fs <- list(pro = names(sups)[2:13],
 fee = names(sups)[14:20])

mats <- objectivematrices(sups, fs, 3,
  cores = 1)
mats

mats$lvcor$use[,] <- FALSE
mats$lvcor$use[2, 1] <- TRUE

mats$lvcor$use


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