# Create a design object (simplified from design.R example)
ADmat <- matrix(c(-1/2,1/2),ncol=1,dimnames=list(NULL,"diff"))
matchfun_example <- function(d) d$S==d$lR # Example match function
example_design_obj <- design(
data = forstmann,
model= LBA,
matchfun=matchfun_example,
formula=list(v~lM,sv~lM,B~E+lR,A~1,t0~1),
contrasts=list(v=list(lM=ADmat)),
constants=c(sv=log(1)),
)
# SEM Factor names
# Make a copy of forstmann for example modification
forstmann_mod <- forstmann
set.seed(123) # for reproducibility
subj_trait_values <- stats::setNames(rnorm(length(levels(forstmann_mod$subjects))),
levels(forstmann_mod$subjects))
forstmann_mod$SubjTrait <- subj_trait_values[forstmann_mod$subjects]
my_cov_cols <- c("SubjTrait")
lambda_example_specs <- list(
Speed = c("v", "v_lMdiff"), # "v" will be fixed to 1
Caution = c("B", "B_Eneutral", "B_Eaccuracy", "B_lRright", "A") # "B" fixed to 1
)
b_example_specs <- list(Caution = "Speed")
k_example_specs <- list(t0 = "SubjTrait") # "SubjTrait" must be in my_cov_cols
g_example_specs <- list(Speed = "SubjTrait")
sem_settings_definition <- make_sem_structure(
data = forstmann_mod,
design = example_design_obj,
covariate_cols = my_cov_cols,
lambda_specs = lambda_example_specs,
b_specs = b_example_specs,
k_specs = k_example_specs,
g_specs = g_example_specs
)
print(sem_settings_definition$Lambda_mat)
print(sem_settings_definition$B_mat)
print(sem_settings_definition$K_mat)
print(sem_settings_definition$G_mat)
print(head(sem_settings_definition$covariates))
Run the code above in your browser using DataLab