I have trouble when I set priors for ndt for a shifted_lognormal model.
Here is an example that shows my problem:
df = data.frame(measure = c(2,2.1,2.5,3,3,3,5))
#this works
fit1= brm(
prior = prior(uniform(0, 2), class = ndt),
data = df,
family = shifted_lognormal,
formula = measure ~ 1,
chains = 1
)
#this does not work. the only difference is the upper bound on the uniform prior
fit2= brm(
prior = prior(uniform(0, 1.99), class = ndt),
data = df,
family = shifted_lognormal,
formula = measure ~ 1,
chains = 1
)
fit1 works and fit2 does not. this is because in fit2, the upper bound for the prior for ndt is smaller than the minimum of the data (1.99 vs. 2).
I am using a uniform prior because that seems to be the default for ndt in shifted_lognormal models.
I get the following output:
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can't start sampling from this initial value.
[....]
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] "Error in sampler$call_sampler(args_list[[i]]) : Initialization failed."
error occurred during calling the sampler; sampling not done
When I add
inits = list(list(ndt = 0.001))
fit1 still runs, but for fit2, the error message stays the same.
I have tried different values for the inital values, but none seem to work.
If the value is outside the interval [0,2], I get the following error message_
Chain 1: Unrecoverable error evaluating the log probability at the initial value.
Chain 1: Exception: Error transforming variable ndt: lub_free: Bounded variable is *value I set*, but must be in the interval [0, 2] (in 'model37715100cad_cd50431a01cb874ee5792d00a9b7836f' at line 15)
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Exception: Error transforming variable ndt: lub_free: Bounded variable is -1, but must be in the interval [0, 2] (in 'model37715100cad_cd50431a01cb874ee5792d00a9b7836f' at line 15)"
I run R version 3.6.2 and brms 2.14.4 on macOS Mojave 10.14.5
What is the problem here? Any hints are appreciated.