I want to fit a multilevel bayesian model to the data set from a category learning experiment. In the experiment, each student (indexed by subjID) go through 4 cycles of learning each consisting of a fixed number of classification trials. There are different categories of stimuli to be classified, each with a different level of classification difficulty. The dependent variable is the number of correct responses for each learning cycle and the key variable that is manipulated is the learning condition (i.e. cond variable with four levels GEE, GEA, GCP and CCP).
The dependent variable is sampled from a customized beta binomial distribution, as below:
beta_binomial_custom <- custom_family(
"beta_binomial_custom", dpars = c("mu", "kappa"),
links = c("logit", "identity"),
lb = c(0, 2), ub = c(1, NA),
type = "int", vars = "trials[n]"
)
stan_funs <- "
real beta_binomial_custom_lpmf(int y, real mu, real kappa, int T) {
return beta_binomial_lpmf(y | T, mu * kappa + 1, (1 - mu) * kappa + 1);
}
int beta_binomial_custom_rng(real mu, real kappa, int T) {
return beta_binomial_rng(T, mu * kappa + 1, (1 - mu) * kappa + 1);
}
"
stanvars <- stanvar(scode = stan_funs, block = "functions")
The key hypothesis I want to test is whether the learning rate (i.e. interaction between cond and cycle) is different across conditions. From looking at the empirical learning curves, it seems to me that the learning curve is nonlinear as it starts to level off on cycle 3, so I think it’d be more reasonable to model the cycle variable as a monotonic effect. But as you can see from my formula below, there is an interaction term between cycle and cond, which will cause separate estimation of simplex shape parameters of cycle for each level of cond.
N_corr | trials(N_trials) ~ 1 + mo(cycle, id = "cycle") + cond:mo(cycle, id = "cycle") + (1|cat) + (1|subjID)
#snippet of fit summary
Monotonic Simplex Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
mocycle1[1] 0.68 0.02 0.64 0.72 1.00 1885 2531
mocycle1[2] 0.20 0.02 0.16 0.24 1.00 2036 2443
mocycle1[3] 0.09 0.02 0.06 0.12 1.00 4836 3048
mocycle1[4] 0.03 0.01 0.01 0.05 1.00 3298 1735
mocycle:condGEA1[1] 0.37 0.18 0.02 0.70 1.00 989 1061
mocycle:condGEA1[2] 0.23 0.15 0.01 0.57 1.00 2524 2561
mocycle:condGEA1[3] 0.18 0.14 0.01 0.52 1.00 3315 2260
mocycle:condGEA1[4] 0.22 0.14 0.02 0.54 1.00 2259 2231
mocycle:condGCP1[1] 0.32 0.19 0.02 0.72 1.01 1295 1331
mocycle:condGCP1[2] 0.38 0.19 0.04 0.76 1.00 2350 1987
mocycle:condGCP1[3] 0.13 0.11 0.00 0.41 1.00 3291 2451
mocycle:condGCP1[4] 0.17 0.12 0.01 0.48 1.00 2673 2013
mocycle:condCCP1[1] 0.29 0.18 0.01 0.69 1.00 1518 2037
mocycle:condCCP1[2] 0.40 0.20 0.03 0.78 1.00 2470 2211
mocycle:condCCP1[3] 0.19 0.15 0.01 0.57 1.00 2628 2717
mocycle:condCCP1[4] 0.12 0.11 0.00 0.42 1.00 1930 2043
But what I want is just estimate separate scale parameters for the cycle effects between different conditions (i.e. condition-specific learning rate), in addition to the main effect of cycle (i.e. general learning rate), while controling for the random effect of subject and stimulus category on the overall accuracy. Specifying the id argument doesn’t really work. Is there a way to make this happen?
I run the latest version of brms on windows system.