Error when using brms and shifted lognormal model

Hello everyone , I’m trying to fit a shifted lognormal model to a large data set of RT. But no matter how i fixed my code , I still could not run away of the error /(ㄒoㄒ)/.

Because the code was written by others,i could not understand all of them.

This is my code of the model
↓↓↓

""brms

fit_a <-  bf(RT~NumAsked + 
             (1 + NumAsked|p|UserID) +
             (1 + NumAsked|q|Question),
           ndt ~ 1,
           family = 'shifted_lognormal')    

fit_b <- bf(Confidence~NumAsked + RT + 
             (1 + NumAsked + RT|p|UserID) +
             (1 + NumAsked + RT|q|Question),
           family = 'cumulative')           

model_1 <- brm(fit_a + fit_b + set_rescor(FALSE),
              data = analyze_df2,                            
              prior = set_prior("normal(0,1)", class = "b"),
              sample_prior = TRUE,
              chains = 2,
              control = list(adapt_delta = 0.99,
                             max_treedepth = 20)) 


And this is the error I do not know how to deal with.
↓↓↓

Chain 1: Rejecting initial value:
Chain 1:   Error evaluating the log probability at the initial value.
Chain 1: Exception: lognormal_lpdf: Random variable[1] is -1.40192, but must be nonnegative! (in 'string', line 194, column 4 to column 62)
.
.
.
[1] "Error : Initialization failed."
[1] "error occurred during calling the sampler; sampling not done"

I really need your help ,cause I have been bothered by this annoying problem for almost 3 weeks.

/(ㄒoㄒ)/

Hi @Yang_Wang,
what is the result of min(analyze_df2$RT)? It sounds like you have a negative value while your family expects positive values (after the shift).

Hi @scholz
I am very honored with your help.
I do check the range of my RT data , but they are all positive.

summary(analyze_df2$RT)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.0398  1.3882  1.7639  2.5866  2.4335 55.2397 

You could try using other init values. I think the default value is 2, you could try setting it to 0.1 just to see if it works.
Alternatively, can you try to sample only from the prior and look at your prior predictive checks? You might need to help the model a little more with this kind of structure.

init = 0.1, sample_prior = "only" would be the arguments.

At which line (fit_a, fit_b, or model_1) does the problem first occur?

should be model1 as the sampling innitialization is failing. fit_a and fit_b just define brmsformula objects but don’t sample anything.

oh of course. sloppy me.

Sorry for the time difference!
I am going to try your advice , actually I have tried it but maybe I used wrong grammar of R.I will try to fix it again~Thank you!

Hello,I have tried the code fixed by you ,but console this mistake.

fit_a <- bf(RT~NumAsked + 
             (1 + NumAsked|p|UserID) +
             (1 + NumAsked|q|Question),
           ndt ~ 1,
           family = 'shifted_lognormal')

fit_b <- bf(Confidence~NumAsked + RT + 
             (1 + NumAsked + RT|p|UserID) +
             (1 + NumAsked + RT|q|Question),
           family = 'cumulative') 

model_1 <- brm(fit_a + fit_b + set_rescor(FALSE),
              data = analyze_df2,
              prior = set_prior("normal(0,1)", class = "b"),
              init = 0.1,
              sample_prior = "only",
              chains = 2,
              control = list(adapt_delta = 0.99,
                             max_treedepth = 20))
Error: Sampling from priors is not possible as some parameters have no proper priors. Error occurred for parameter 'b_RT'.

Could you try setting a prior on the parameter?

Thanks for your patience and kindness, I will try your advice , basically I have poor knowledge of brms and cognitive modeling …