I am analyzing a data set for someone in which participants make two binary decisions (related to art preference) in either one or two conditions each. Individual participants were tested across 6 experiments split between these designs. This results in some participants with 1 response in Condition A and 1 response in Condition B (within-subjects design), some participants with 2 responses in Condition A and some participants with 2 responses in Condition B (between-subjects design). In addition to assuming that participants will vary in their overall propensity to make one decision or the other (random intercept) it also seems reasonable to consider the possibility that they would vary in their response to the experimental manipulation (random slope). A similar argument might be made for variation in response at the level of the experiments as well. Therefore, the appropriate formula seems to be:
stan_glmer(decision ~ condition + (condition | participant_id) + (condition | experiment_id), data = data_frame, family = binomial, adapt_delta=.999)
This fits the model just fine, and the results look reasonable. However, it is interesting that this model *does* work so well. Trying variations of this model using glmer results in an error concerning identifiability, presumably because the model is trying to estimate random slopes for some participants that have no responses in one of the two conditions. I believe that rstanarm deals with those cases by imputing slopes based on the joint posterior: This means (roughly) that the random slopes for participants in the between-subject experiments will be based on the random slopes for participants in the within-subject experiments. This seems fine, and the specific random slopes for the between-subject experiments are not important. My question is whether this understanding is correct or whether I am missing some pernicious element of modelling the data in this manner. Further, we would ultimately like to compare performance across experimental design, for example using:
stan_glmer(decision ~ condition * design + (condition | participant_id) + (condition | experiment_id), data = data_frame, family = binomial, adapt_delta=.999)
Here, design refers to whether a given experiment employed a within- or between-subjects design. Again, the model fits and everything appears to be in order, but I am a little cautious in part due to earlier critiques of within/between-subject comparisons of this nature using more “traditional” techniques (for example, Erlebacher, 1977). I believe this sort of comparison to be a non-issue with stan_glmer, but I wanted a second opinion before committing.
Thanks in advance!
stan_glmer(decision ~ condition * design + (condition | participant_id) + (condition | experiment_id), data = data_frame, family = binomial, adapt_delta=.999)
dat = readRDS("sample_dat.rds")
glmer_model = stan_glmer(decision ~ condition * design + (condition | participant_id) + (condition | experiment_id), data = dat, family = binomial)
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/mBMwLjFGB6k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
simdat2 = readRDS('sample_dat2.rds')
simmod2 = stan_glmer(decision ~ condition + order + choices + relprefc1 + ici + bore + fat + (condition|participant_id), data = simdat2, family = binomial, adapt_delta=.999, prior_covariance=decov(scale=.5))sim_conditions = posterior_linpred(simmod2, re.form=NA, transform=TRUE, newdata=expand.grid(condition=c(-.5,.5), order=0, choices=0, relprefc1=0, ici=0, bore=0, fat=0))
apply(sim_conditions, 2, function(x){return(quantile(x, probs=c(.025,.5,.975)))})
# 1 2
# 2.5% 0.004359592 0.02508615
# 50% 0.032214613 0.10240261
# 97.5% 0.079338786 0.19666528library(dplyr)
summarize(group_by(simdat2, condition), mean=mean(decision))
# condition mean
# <dbl> <dbl>
#1 -0.5 0.08333333
#2 0.5 0.21875000y_rep <- posterior_predict(simmod2)
summary(apply(y_rep, 1, mean))
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.05729 0.13020 0.15100 0.15120 0.17190 0.27080 To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.