Getting a value error that my variable is neither int nor float nor list/array thereof

Please share your Stan program and accompanying data if possible.

When including Stan code in your post it really helps if you make it as readable as possible by using Stan code chunks (```stan) with clear spacing and indentation. For example, use

reinstatement_model = """
data {
    int<lower=0> n; // number policy term years
    int<lower=0> NonCatcvrcnt; // loss ratio
    int<lower=0, upper = 1> alertflag; //alert flag

parameters {
    real<lower=0> mu;
    real beta;
    real<lower = 0> sigma;

model {
       mu ~ normal(0,1);
       beta ~ normal(0,1);
       NonCatcvrcnt ~ poisson_log(mu + beta*alertflag);
//generated quantities {}

I’ve checked the data and it is an integer. These are insurance claims so there are a lot of zeros in the dataset. I’m not sure if that matters.

The specific error is “ValueError: Variable NonCatcvrcnt is neither int nor float nor list/array thereof”

Is there anything standard I could be doing wrong?

We’ll need some information

  • What platform is this (e.g., rstan, pystan, cmdstan)?
  • The statement you’re using to call stan
  • How your data is constructed/setup

Hello. I’m using pystan.

Below is the statment I am using.

fit = pystan.stan(model_code=reinstatement_model, 
data=df_group_dict, iter=1000, chains=1)

My data is in a dictionary. N is an integer, Noncatcvrcnt are integers and alertflags are integers.

Please disregard. The solution was to make sure my python dictionary was oriented as a list. It was a dictionary inside a dictionary before.