# I am building a logistic growth model via stan and I don't know how to provide the data to stan to start the sampling

growthcode_v2=’

functions {

real[] logisticgrowth(real t,

``````              real[] y,

real[] theta,

real[] x_r,

int[] x_i

) {

real dydt[x_i[1]];

for (i in 1:x_i[1]){

dydt[i] = theta[1] * y[i] * (1-y[i]/theta[2]);

}

return dydt;
``````

}

}

data {

int<lower=1> T;

int<lower=1> n_days;

real y0[n_days];

real z[T,n_days];

real t0;

real ts[T];

}

transformed data {

real x_r[0];

int x_i[1];

x_i[1] = n_days;

}

parameters {

real<lower=0> theta[2];

real<lower=0> sigma;

}

model {

real y_hat[T,n_days];

theta ~ cauchy(0,2.5);

sigma ~ normal(0,0.01);

y_hat = integrate_ode_rk45(logisticgrowth, y0, t0, ts, theta, x_r, x_i);

for (t in 1:T) {

``````for (i in 1:n_days) {

z[t,i] ~ normal(y_hat[t,i], sigma);

}
``````

}

}

generated quantities{

real y_pred[T,n_days];

real z_pred[T,n_days];

y_pred = integrate_ode_rk45(logisticgrowth, y0, t0, ts, theta, x_r, x_i );

for (t in 1:T) {

``````for(i in 1:n_days){

z_pred[t,i] = y_pred[t,i] + normal_rng(0,sigma);

}
``````

}

}

mod_v2 = stan_model(model_name = ‘logistic_growth_stan’,model_code = growthcode_v2)

fit_logistic_growth ← sampling(mod_v2,

``````              data = list (

n_days = n_days,

y0 = y0[1:n_days],

z  = z[,1:n_days],

t0 = t0,

ts = ts

),

seed = 123,

chains = 4,

iter = 1000,

warmup = 500
``````

)

Error in FUN(X[[i]], …) : Stan does not support NA (in y0) in data

failed to preprocess the data; sampling not done

Looks like there is a lot of surrounding code missing?