Hi all,

I am trying to run following stan code with CmdStanR to estimate parameters.

These are the several equations in my model

D_{1,t_{0}}=\beta(t_{0})\int_{0}^{t_{0}}w(x)Q(t_{0}-x)dx

D_{k,t_{0}}=\beta(t_{k-1})\Bigg\{\sum_{i=0}^{k-2}[1-\beta(t_{i})]...[1-\beta(t_{k-2})]\int_{t_{i-1}}^{t_{i}}w(x)Q(t_{k-1}-x)dx +\int_{t_{k-2}}^{t_{k-1}}w(x)Q(t_{k-1}-x)dx \Bigg\}

I_{k,t_{0}}(t)=\sum_{i=0}^{k-1}[1-\beta(t_{i})]...[1-\beta(t_{k-1})]\int_{t_{i-1}}^{t_{i}}w(x)q(t-x)dz +\int_{t_{K-1}}^{t}w(x)q(t-x)dz, \hspace{0.5cm} \forall t \in (t_{k-1},t_{k})

This is a sample data table used in my coding,

Data Table.csv (217 Bytes)

and stan file is

model.stan (5.0 KB)

I am getting errors because of the integrations in my model.

**Chain 1 Exception: integrate: error estimate of integral 3.53534 exceeds the given relative tolerance times norm of integral**

Could you please suggest a way to solve this issue, I have already simplified a bit according to previous suggestions by @bbbales2 . I want to use following uniform distributions for my initial values .

```
init_func <- function(){
list(b0=runif(1,0,4),mu=runif(1,4,4.5),sigma2=runif(1,0.01,0.05),lambda=runif(1,0.01,0.5),alpha=runif(1,1.5,4))
}
```

Here is the code

```
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
MT<- as.matrix(DataTable)
head(MT)
n=nrow(MT)
m=ncol(MT)
tstar = mean(MT[,1])
K=2
model_data<-list(MT=MT,n=n,m=m,K=K, tstar=tstar)
mod<-cmdstan_model("C:/Users/nanayaer/Documents/.cmdstanr/cmdstan-2.24.1/model.stan")
fit <- mod$sample(
data = model_data,
init = init_func,
chains = 1,
refresh = 500,
iter_warmup = 200,
max_treedepth=15 ,
adapt_delta = 0.99
)
```

THANK YOU !