# 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
)
Run the code above in your browser using DataLab