add_local_dependence {latentFactoR} | R Documentation |
Adds Local Dependence to simulate_factors
Data
Description
Adds local dependence to simulated data from simulate_factors
.
See examples to get started
Usage
add_local_dependence(
lf_object,
method = c("correlate_residuals", "minor_factors", "threshold_shifts"),
proportion_LD,
proportion_LD_range = NULL,
add_residuals = NULL,
add_residuals_range = NULL,
allow_multiple = FALSE
)
Arguments
lf_object |
Data object from |
method |
Character (length = 1).
Method to generate local dependence between variables.
Only
|
proportion_LD |
Numeric (length = 1 or |
proportion_LD_range |
Numeric (length = 2).
Range of proportion of variables that are randomly selected from
a random uniform distribution. Accepts number of locally dependent values as well.
Defaults to |
add_residuals |
Numeric (length = 1, |
add_residuals_range |
Numeric (length = 2).
Range of the residuals to add to the correlation matrix are randomly selected from
a random uniform distribution.
Defaults to |
allow_multiple |
Boolean.
Whether a variable should be allowed to be locally dependent with
more than one other variable.
Defaults to |
Value
Returns a list containing:
data |
Simulated data from the specified factor model |
population_correlation |
Population correlation matrix with local dependence added |
original_correlation |
Original population correlation matrix before local dependence was added |
correlated_residuals |
A data frame with the first two columns specifying the variables that are locally dependent and the third column specifying the magnitude of the added residual for each locally dependent pair |
original_results |
Original |
Author(s)
Alexander P. Christensen <alexpaulchristensen@gmail.com>, Hudson Golino <hfg9s@virginia.edu>, Luis Eduardo Garrido <luisgarrido@pucmm.edu>
References
Christensen, A. P., Garrido, L. E., & Golino, H. (2023). Unique variable analysis: A network psychometrics method to detect local dependence. Multivariate Behavioral Research, 1–18.
Examples
# Generate factor data
two_factor <- simulate_factors(
factors = 2, # factors = 2
variables = 6, # variables per factor = 6
loadings = 0.55, # loadings between = 0.45 to 0.65
cross_loadings = 0.05, # cross-loadings N(0, 0.05)
correlations = 0.30, # correlation between factors = 0.30
sample_size = 1000 # number of cases = 1000
)
# Add local dependence
two_factor_LD <- add_local_dependence(
lf_object = two_factor,
proportion_LD = 0.25,
add_residuals = 0.20,
allow_multiple = FALSE
)
# Randomly vary proportions
two_factor_LD <- add_local_dependence(
lf_object = two_factor,
proportion_LD_range = c(0.10, 0.50),
add_residuals = 0.20,
allow_multiple = FALSE
)
# Randomly vary residuals
two_factor_LD <- add_local_dependence(
lf_object = two_factor,
proportion_LD = 0.25,
add_residuals_range = c(0.20, 0.40),
allow_multiple = FALSE
)
# Randomly vary proportions, residuals, and allow multiple
two_factor_LD <- add_local_dependence(
lf_object = two_factor,
proportion_LD_range = c(0.10, 0.50),
add_residuals_range = c(0.20, 0.40),
allow_multiple = TRUE
)