subj_full <- sort(rep(subid, each = 1, times = 160))
trial_num_full <- rep(trial_num, each=1, 160)
trial_type_full <- rep(rep(trial_type, each = 1, times = 8), 160)
lab_full <- rep(lab, each=16, 160)
item_full <- rep(item, each=1, 160)
data_frame is set in a particular way, as each subject has half of the trials in group A and the other half of the trials in group B. Each subject has 16 trials num and 16 item. Each lab has 16 subject
Hello, I simulated some data based on the parameters of a pilot data set.
first, I created a dataframe, each subject(subid) has 16 data points, each lab has 16 subjects and we have 10 labs
The data_frame is 161610 = 2560 data point
subid <- c(1:16) trial_num <- factor(1:16) trial_type <- c("group_A", "group_B") lab <- c(1:10) item <- c(1:16)
subj_full <- sort(rep(subid, each = 1, times = 160)) trial_num_full <- rep(trial_num, each=1, 160) trial_type_full <- rep(rep(trial_type, each = 1, times = 8), 160) lab_full <- rep(lab, each=16, 160) item_full <- rep(item, each=1, 160)
data_frame is set in a particular way, as each subject has half of the trials in group A and the other half of the trials in group B. Each subject has 16 trials num and 16 item. Each lab has 16 subject
DB_sim <- data.frame(Subid=subj_full, Trial_type=factor(trial_type_full), Lab=lab_full, Item=item_full, Trial_num=trial_num_full) %>% select(Subid, Lab, Trial_type, Trial_num, Item)
fixed intercepts and slopes:
fixed <- c(2.187, -0.051, 0.106, -0.003)
random intercepts
rand <- list(0.1196, 0.0019, 0.0346)
random residual
res <- 0.6373
model <- makeLmer(y ~ Trial_num*Trial_type + (1|Subid) + (1|Lab) , fixef=fixed, VarCorr=rand, sigma=res, data=DB_sim)
When I ran the model, I received an error: Error in setParams(object, newparams) : length mismatch in beta (4!=16)
How should I fix it? Any advice will be appreciated!! Thanks!