data {
int <lower=1> nd; // nrow of data
real <lower=0> dose1[nd]; // dose1
real <lower=0> dose2[nd]; // dose2
int<lower=1> D; // number of all combinations
real<lower=0> Dose_set[D,2]; // dose amount by combination
real y[nd]; //response EFF 0.12,.13....
int n[nd]; //number of subject in each dose level
real<lower=0> a1;
real<lower=0> b1;
real<lower=0> a2;
real<lower=0> b2;
real<lower=0> a3;
real<lower=0> b3;
real<lower=0> a4;
real<lower=0> b4;
real a5;
real<lower=0> b5;
real<lower=0> a6;
real<lower=0> b6;
}
parameters {
real alpha; // interaction parameter
real<lower=0> Emax; // positive
real<lower=0> theta3; // IC50 for drug A
real<lower=0> theta4; // IC50 for drug B
real<lower=0> tau; // positive (gamma, slope of the sigmoid)
real<lower=0> phi; // positive
// real<lower=0> sigma;
}
transformed parameters{
real sigma;
sigma = 1 / sqrt(phi);
}
model {
vector[nd] mu;
vector[nd] X;
for (i in 1:nd) {
X[i] = (((dose1[i]/theta3)+(dose2[i]/theta4)+alpha*(dose1[i]/theta3)*(dose2[i]/theta4))^tau)/(1+((dose1[i]/theta3)+(dose2[i]/theta4)+alpha*(dose1[i]/theta3)*(dose2[i]/theta4))^tau);
mu[i] = Emax * X[i];
}
y ~ normal(mu,sigma);
// prior
Emax ~ gamma(a1, b1);
theta3 ~ gamma(a2, b2); //ic50A
theta4 ~ gamma(a3, b3); // IC50B
tau ~ gamma(a4, b4); // GAMMA SHAPE OF SIGMOID
alpha ~ lognormal(a5,b5); // INTERACTION
phi ~ gamma(a6, b6);
}
generated quantities {
real Y_mean[D];
real Y_pred[D];
vector[D] X2; // mean for each combination
for (i in 1:D) {
X2[i] =((((Dose_set[i,1]/theta3)+(Dose_set[i,2]/theta4)+alpha*(Dose_set[i,1]/theta3)*(Dose_set[i,2]/theta4))^tau)/
(1+((Dose_set[i,1]/theta3)+(Dose_set[i,2]/theta4)+alpha*(Dose_set[i,1]/theta3)*(Dose_set[i,2]/theta4))^tau));
Y_mean[i] = Emax * X2[i];
// predictive distribution
Y_pred[i] = normal_rng(Y_mean[i], sigma);
}
}
I am getting these errors
“Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Location parameter[1] is -nan, but must be finite! (in ‘modelc0fa23a89510_comboemaxdata’ at line 61)”
“Rejecting initial value:
Error evaluating the log probability at the initial value.
Exception: lognormal_lpdf: Random variable is -0.0436181, but must be >= 0! (in ‘modelc0fa23a89510_comboemaxdata’ at line 67)”
My initial values are:
data=list(dose1,dose2,y=EFF,n=N,D=nrow(d_ds),nd=7, Dose_set=as.matrix(d_ds),
a1=emax_m,b1=emax_v,
a2=ic50a_m,b2=ic50a_v,a3=ic50b_m,b3=ic50b_v,
a4=tau_m,b4=tau_v,
a5=alpha_m,b5=alpha_v,a6=phi_m,b6=phi_v)
dose1=c(rep(5,3),rep(10,4))
dose2=c(rep(1,3),rep(2.5,4))
Dose1=c(5,10,15,20,25,30,35)
Dose2=c(1, 2.5,5,8,10,12)
d_ds <- expand.grid(Dose1, Dose2)
EFF=c(0.120339186,0.134951636,0.137583534,0.347937291,0.328618659,0.34173274,0.832809641)
N=rep(1,7)
data=data.frame(dose1,dose2,EFF,N)
alpha_m=0.1
alpha_v=.3
ic50a_m=1.05
ic50a_v=.3
ic50b_m=1.05
ic50b_v=.3
tau_m=2.5 ###slope
tau_v=.45
emax_m=2.5 ###EMAX
emax_v=0.5
phi_m=0.0001
phi_v=0.0001
I am trying to make the priors noninformative. I really can’t figure out if there is a problem with my model or is it the initial value for lognormal that is making the difference. New to stan.
Please help. Rhat is 1<1.1