Rstan Initialization error

Hi all,

I’m currently working with an R package that uses rstan functions for model fitting, but I have been encountering errors that I’m unsure how to fix. Most errors I’ve come across are related to the model itself, but this one mentions “in string”, which seems different from the model error. I also tried to change my data from 1&2 to 0&1, and I encountered the second error below. Any help or suggestion on how to address this issue would be greatly appreciated. Thank you!

Chain 1: Rejecting initial value:
Chain 1:   Error evaluating the log probability at the initial value.
Chain 1: Exception: bernoulli_lpmf: n[1] is 2, but must be in the interval [0, 1] (in 'string', line 97, column 2 to column 54)
Chain 1: 
Chain 1: Initialization between (-2, 2) failed after 1 attempts. 
Chain 1:  Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] "Error : Initialization failed."
[1] "error occurred during calling the sampler; sampling not done"
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: 
Chain 1: Initialization between (-2, 2) failed after 1 attempts. 
Chain 1:  Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.

Hi. This indicates that stan has difficulty starting at random points. Without providing stan code, no one can give you suggestions on possibly improving the code to be more stable.

Given the line:

It would suggest to me that your theta value is incorrect, it should be between 0-1, and your value seems to be 2. The bernoulli_logit may be more appropriate, see the stan docs