View source: R/randomsamples.R
randomsamples | R Documentation |
Construct a defined number of random subtests from a given pool of items.
randomsamples(
data,
factor.structure,
capacity = NULL,
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,
seed = NULL,
request.override = 10000,
filename = NULL,
n = 1000,
percentile = 100
)
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 |
item.invariance |
A character vector of length 1 or the same length as |
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 |
long.invariance |
A character vector of length 1 or the same length as |
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 |
mtmm.invariance |
A character vector of length 1 or the same length as |
grouping |
The name of the grouping variable. The grouping variable must be part of |
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 |
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 |
auxiliary |
The names of auxiliary variables in |
use.order |
A logical indicating whether or not to take the selection order of the items into account. Defaults to |
software |
The name of the estimation software. Can currently be 'lavaan' (the default), 'Mplus', or 'Mplus Demo'. Each option requires the software to be installed. |
cores |
The number of cores to be used in parallel processing. If |
objective |
A function that converts the results of model estimation into a pheromone. See |
ignore.errors |
A logical indicating whether or not to ignore estimation problems (such as non positive-definite latent covariance matrices). Defaults to |
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. |
suppress.model |
A logical indicating whether to suppress the default model generation. If |
seed |
A random seed for the generation of random samples. See |
request.override |
The maximum number of combinations for which the estimation is performed immediately, without an additional override request. |
filename |
The stem of the filenames used to save inputs, outputs, and data files when |
n |
The number of random samples to be drawn. |
percentile |
The percentile of the final solution reported among the viable solutions. Defaults to 100 (the best solution found). |
The pheromone function provided via objective
is used to assess the quality of the solutions. These functions can contain any combination of the fit indices provided by the estimation software. When using Mplus these fit indices are 'rmsea', 'srmr', 'cfi', 'tli', 'chisq' (with 'df' and 'pvalue'), 'aic', 'bic', and 'abic'. With lavaan any fit index provided by inspect
can be used. Additionally 'crel' provides an aggregate of composite reliabilites, 'rel' provides a vector or a list of reliability coefficients for the latent variables, 'con' provides an aggregate consistency estimate for MTMM analyses, and 'lvcor' provides a list of the latent variable correlation matrices. For more detailed objective functions 'lambda', 'theta', 'psi', 'alpha', and 'nu' provide the model-implied matrices. Per default a pheromone function using 'crel', 'rmsea', and 'srmr' is used. Please be aware that the objective
must be a function with the required fit indices as (correctly named) arguments.
Using model comparisons via the comparisons
argument compares the target model to a model with one less degree of assumed invariance (e.g. if your target model contains strong invariance, the comparison model contain weak invariance). Adding comparisons will change the preset for the objective function to include model differences. With comparisons, a custom objective function (the recommended approach) can also include all model fit indices with a preceding delta.
to indicate the difference in this index between the two models. If more than one type of comparison is used, the argument of the objective function should end in the type of comparison requested (e.g. delta.cfi.group
to use the difference in CFI between the model comparison of invariance across groups).
Returns an object of the class stuartOutput
for which specific summary
and plot
methods are available. The results are a list.
call |
The called function. |
software |
The software used to fit the CFA models. |
parameters |
A list of the parameters used. |
analysis.options |
A list of the additional arguments passed to the estimation software. |
timer |
An object of the class |
log |
A |
log_mat |
A |
solution |
|
pheromones |
|
subtests |
A list containing the names of the selected items and their respective subtests. |
final |
The results of the estimation of the global-best solution. |
Martin Schultze
bruteforce
, mmas
, gene
# Random samples in a simple situation
# requires lavaan
# number of cores set to 1 in all examples
data(fairplayer)
fs <- list(si = names(fairplayer)[83:92])
# 10 random solutions, report median solution
sel <- randomsamples(fairplayer, fs, 4,
n = 10, percentile = 50,
seed = 55635, cores = 1)
summary(sel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.