I was torn whether to make a new post or reply in a comment ton my last, but since it could be an issue with anything in my code, I decided to make a new post.
I am attempting to run my 1st DDM in brms
.
x1 is a continuous predictor of drift rate that ranges in the data from -2 to 3.
x2 is a categorical feature of the stimulus with three levels, treatment-coded, which I am also using to prdict drift rate.
I also intend to fix all other parameters (starting point, etc.).
I have excluded all trials with RTs under 200ms.
Here is my code so far:
formula <- brms::bf(
# drift rate formula
rt | dec(response) ~ x1+ x2+ (x2|p|subID) + (1|Stimulus),
# boundary separation formula
bs ~ 1 + (1|p|subID),
# non-decision time formula
ndt ~ 1 + (1|p|subID),
# starting point formula
bias ~ 1 + (1|p|subID)
)
#-----Set priors
#Now we are going to set our own priors while incorporating some of the base priors
get_prior(formula,
data = data,
family = wiener)
family <- wiener()
#Set priors
prior <- c(
set_prior("normal(-2, 2)", coef = "x2level2", class="b"),
set_prior("normal(-2, 2)", coef = "x2level3", class="b"),
set_prior("normal(-2, 2)", coef = "x1", class = "b")
) |> brms::validate_prior(formula,
family = family,
data = data)
#We should set a lower and upper bound on NDT
#Set a lower bound of 50ms on NDT
prior[prior$dpar=="ndt" & prior$coef==""& prior$class=="Intercept", "lb"]=0.050
#Set an upper bound of 100ms on NDT (all trials with rts under 200ms were dropped: smallest rt is # just above 200ms now
prior[prior$dpar=="ndt" & prior$coef=="" & prior$class=="Intercept", "ub"]=0.1
#Write the STAN code
make_stancode(formula,
family = wiener(),
data = data,
prior = prior)
tmp_dat <- make_standata(formula,
family = wiener(),
data = data, prior = prior)
fit_wiener <- brm(formula,
data = data,
family = family,
prior = prior,
iter = 1000, warmup = 500,
chains = 4, cores = 4)
I get the following error:
Compiling Stan program...
Start sampling
here are whatever error messages were returned
[[1]]
Stan model 'anon_model' does not contain samples.
[[2]]
Stan model 'anon_model' does not contain samples.
[[3]]
Stan model 'anon_model' does not contain samples.
[[4]]
Stan model 'anon_model' does not contain samples.
Warning message:
In .local(object, ...) :
some chains had errors; consider specifying chains = 1 to debug
My priors look like this:
prior | class | coef | group | resp | dpar | nlpar | lb | ub | source |
---|---|---|---|---|---|---|---|---|---|
b | default | ||||||||
normal(-2, 2) | b | X2level2 | user | ||||||
normal(-2, 2) | b | X2level3 | user | ||||||
normal(-2, 2) | b | x1 | user | ||||||
student_t(3, 0.9, 2.5) | Intercept | default | |||||||
logistic(0, 1) | Intercept | bias | default | ||||||
normal(-0.6, 1.3) | Intercept | bs | default | ||||||
Intercept | ndt | 0.05 | 0.1 | default | |||||
lkj_corr_cholesky(1) | L | default | |||||||
L | subID | default | |||||||
student_t(3, 0, 2.5) | sd | 0 | default | ||||||
student_t(3, 0, 2.5) | sd | bias | 0 | default | |||||
student_t(3, 0, 2.5) | sd | bs | 0 | default | |||||
student_t(3, 0, 2.5) | sd | ndt | 0 | default | |||||
sd | Stimulus | default | |||||||
sd | Intercept | Stimulus | default | ||||||
sd | subID | default | |||||||
sd | x2level2 | subID | default | ||||||
sd | x2level3 | subID | default | ||||||
sd | Intercept | subID | default | ||||||
sd | subID | bias | default | ||||||
sd | Intercept | subID | bias | default | |||||
sd | subID | bs | default | ||||||
sd | Intercept | subID | bs | default | |||||
sd | subID | ndt | default | ||||||
sd | Intercept | subID | ndt | default |
When setting the prior for ndt
where class == sd
, creating the stan code was not possible (I should have recored the exact error wording, my bad). So, I only put the priors where class == Intercept
. I’m not sure if this is what is causing the error, or if it is something else concerning my priors or model. What exactly does this mean? Any insight is appreciated!