I’m trying to analyze response times (RTs) collected in a speech perception experiment, using the shifted_lognormal family. The first batch of code produces a a model which converges and which has no divergent chains, but which produces posterior predictions that deviate modestly from the data for individual participants and which produced posterior distributions of the standard deviations which deviate substantially from the observed standard deviation for many participants. The second batch of code tries to follow the recommended remedy found here, 5.2 A hierarchical model with a normal likelihood: The N400 effect | An Introduction to Bayesian Data Analysis for Cognitive Science, but doing so produces versions of this error, usually for all chains:
Chain 4 Rejecting initial value:
Chain 4 Error evaluating the log probability at the initial value.
Chain 4 Exception: lognormal_lpdf: Scale parameter[1] is -1.4789, but must be positive finite! (in ‘/var/folders/_2/27km6kjs38d49s497vbt7g7x888y_h/T/RtmpmvVLSO/model-11de818a8aec.stan’, line 116, column 4 to column 50)
Code that works:
rtPriorSLNa <- c(set_prior("normal(7, 2.5)", class = "Intercept"),
set_prior("normal(6, 1)", class = "Intercept", dpar = "ndt"),
set_prior("normal(0, 0.25)", class = "b"),
set_prior("normal(0, 0.25)", class = "sd"),
set_prior("normal(0, 0.25)", class = "Intercept", dpar = "sigma"),
set_prior("lkj(2)", class = "cor"))
dgRTSLN0a <- brm(formula = bf(rspTime ~ scDgRsp +
poly(scStep, 2) +
scContext +
scEnvelope +
scNative +
(1 + scDgRsp + poly(scStep, 2) + scContext + scEnvelope |p| participant),
ndt ~ 1 +
(1 |p| participant)),
data = dgRT,
family = shifted_lognormal(link = "identity",
link_sigma = "identity",
link_ndt = "identity"),
prior = rtPriorSLNa,
iter = 2500, chains = 4, warmup = 500,
control = list(adapt_delta = 0.99,
max_treedepth = 15))
Codes that produces the error:
rtPriorSLNb <- c(set_prior("normal(7, 2.5)", class = "Intercept"),
set_prior("normal(6, 1)", class = "Intercept", dpar = "ndt"),
set_prior("normal(0, 0.25)", class = "b"),
set_prior("normal(0, 0.25)", class = "sd"),
set_prior("normal(0, log(10))", class = "Intercept", dpar = "sigma"),
set_prior("normal(0, 1)", class = "sd", group = "participant", dpar = "sigma"),
set_prior("lkj(2)", class = "cor"))
dgRTSLN0b <- brm(formula = bf(rspTime ~ scDgRsp +
poly(scStep, 2) +
scContext +
scEnvelope +
scNative +
(1 + scDgRsp + poly(scStep, 2) + scContext + scEnvelope |p| participant),
ndt ~ 1 +
(1 |p| participant),
sigma ~ 1 +
(1 |p| participant)),
data = dgRT,
family = shifted_lognormal(link = "identity",
link_sigma = "identity",
link_ndt = "identity"),
prior = rtPriorSLNb,
iter = 2500, chains = 4, warmup = 500,
control = list(adapt_delta = 0.99,
max_treedepth = 15))
Any advice would be greatly appreciated.
- Operating System: Mac OS X Monterey
- brms Version: 2.17.0