Hello!
I am trying to model a behavioral task using brms. There are two independent variables (each with two levels), and I am interested mostly in the interaction effect (var1*var2). Task responses were made on a discrete scale so I chose cumulative().
model_fit <- brm(response ~ var1*var2 + (var1*var2|participant), data = data, family = cumulative(), iter = 5000, chains = 4)
After fitting the model, I checked the stan function call and the stan model using make_standata() and stancode(). The two variables were coded as 0 and 1 instead of mean-centered -0.5 and 0.5 in the stan() function call. The predictors were then centered inside the stan model.
transformed data {
matrix[N, Kc] Xc; // centered version of X
vector[Kc] means_X; // column means of X before centering
for (i in 1:K) {
means_X[i] = mean(X[, i]);
Xc[, i] = X[, i] - means_X[i];
}
}
Centered predictors (Xc) were used for the group-level parameters (b), but uncentered predictors (Z_1_1 to Z_1_4) were used for individual-level parameters.
vector[N] mu = rep_vector(0.0, N);
mu += Xc * b; // centered, group-level
for (n in 1:N) {
// add more terms to the linear predictor
mu[n] += r_1_1[J_1[n]] * Z_1_1[n] + r_1_2[J_1[n]] * Z_1_2[n] + r_1_3[J_1[n]] * Z_1_3[n] + r_1_4[J_1[n]] * Z_1_4[n]; // uncentered, individual-level
}
for (n in 1:N) {
target += ordered_logistic_lpmf(Y[n] | mu[n], Intercept);
}
So just wondering what the reason is for using different predictors for group- and individual-level parameters? And will this difference significantly impact the fitting results?
Thanks for answering my question!