# Script generated by the UniPV WinBUGS converter
# 'WinBUGSConverter' copyright (c) BMS - University of Pavia (2016)
# Converter Version: 1.0.0
# Source: PharmML 0.8.1
# Target: WINBUGS 1.4.3
# Run ID: run_id_0
# Model: Generated from MDL. MOG ID: rocchetti2013
# File: Executable_Rocchetti_2013_oncology_TGI_antiangiogenic_combo
# Dated: Sun Jul 31 14:50:13 CEST 2016

model {
  for (ind_subj in 1:N_subj) {
    for (ind_t in 1:N_t[ind_subj]) {
      Y_mean[ind_subj,ind_t] <- (WTOT[ind_subj,ind_t] + 0)
      Y_prec[ind_subj,ind_t] <- 1 / ((pow(((CV * WTOT[ind_subj,ind_t])),2))*SIGMA_RES_W)
      Y[ind_subj,ind_t] ~ dnorm(Y_mean[ind_subj,ind_t], Y_prec[ind_subj,ind_t])
      Y_res[ind_subj,ind_t] <- Y[ind_subj,ind_t]-Y_mean[ind_subj,ind_t]
    }
    LAMBDA0[ind_subj] <- POP_LAMBDA0
    LAMBDA1[ind_subj] <- POP_LAMBDA1
    K1[ind_subj] <- POP_K1
    K2[ind_subj] <- POP_K2
    IC50[ind_subj] <- POP_IC50
    IC50COMBO[ind_subj] <- POP_IC50COMBO
    W0[ind_subj] <- POP_W0
    der99wb_unipv[ind_subj,1:N_t[ind_subj], 1:9]<- function.model1(grid[ind_subj,1:N_t[ind_subj]], amt[ind_subj,1:N_t[ind_subj]],  rate[ind_subj,1:N_t[ind_subj]], ii[ind_subj,1:N_t[ind_subj]], evid[ind_subj,1:N_t[ind_subj]], cmt[ind_subj,1:N_t[ind_subj]], addl[ind_subj,1:N_t[ind_subj]], ss[ind_subj,1:N_t[ind_subj]], theta[ind_subj,])
    theta[ind_subj,1] <- POP_LAMBDA0
    theta[ind_subj,2] <- POP_LAMBDA1
    theta[ind_subj,3] <- POP_IC50
    theta[ind_subj,4] <- POP_K1
    theta[ind_subj,5] <- POP_K2
    theta[ind_subj,6] <- POP_IC50COMBO
    theta[ind_subj,7] <- 0 #IC Q0_A
    theta[ind_subj,8] <- 0 #IC Q1_A
    theta[ind_subj,9] <- 0 #IC Q0_B
    theta[ind_subj,10] <- 0 #IC Q1_B
    theta[ind_subj,11] <- 0 #IC Q2_B
    theta[ind_subj,12] <- W0[ind_subj] #IC Z0
    theta[ind_subj,13] <- 0 #IC Z1
    theta[ind_subj,14] <- 0 #IC Z2
    theta[ind_subj,15] <- 0 #IC Z3
    theta[ind_subj,16] <- 1 #F Q0_A
    theta[ind_subj,17] <- 1 #F Q1_A
    theta[ind_subj,18] <- 1 #F Q0_B
    theta[ind_subj,19] <- 1 #F Q1_B
    theta[ind_subj,20] <- 1 #F Q2_B
    theta[ind_subj,21] <- 1 #F Z0
    theta[ind_subj,22] <- 1 #F Z1
    theta[ind_subj,23] <- 1 #F Z2
    theta[ind_subj,24] <- 1 #F Z3
    theta[ind_subj,25] <- 0 #TLAG Q0_A
    theta[ind_subj,26] <- 0 #TLAG Q1_A
    theta[ind_subj,27] <- 0 #TLAG Q0_B
    theta[ind_subj,28] <- 0 #TLAG Q1_B
    theta[ind_subj,29] <- 0 #TLAG Q2_B
    theta[ind_subj,30] <- 0 #TLAG Z0
    theta[ind_subj,31] <- 0 #TLAG Z1
    theta[ind_subj,32] <- 0 #TLAG Z2
    theta[ind_subj,33] <- 0 #TLAG Z3
    for (ind_q in 1:N_t[ind_subj]) {
      Q0_A[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,1] + 0
      Q1_A[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,2] + 0
      Q0_B[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,3] + 0
      Q1_B[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,4] + 0
      Q2_B[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,5] + 0
      Z0[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,6] + W0[ind_subj]
      Z1[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,7] + 0
      Z2[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,8] + 0
      Z3[ind_subj,ind_q] <- der99wb_unipv[ind_subj,ind_q,9] + 0
      KA_A[ind_subj,ind_q] <- ((24 * (log(2))) / 6.19)
      KE_A[ind_subj,ind_q] <- ((log(2)) / 6.05)
      FV1_A[ind_subj,ind_q] <- (1 / 0.119)
      KA_B[ind_subj,ind_q] <- 18.8
      KE_B[ind_subj,ind_q] <- 49.2
      K21[ind_subj,ind_q] <- 10.4
      K12[ind_subj,ind_q] <- 141.1
      FV1_B[ind_subj,ind_q] <- (1 / 2.13)
      EMAX[ind_subj,ind_q] <- 1
      PSI[ind_subj,ind_q] <- 20
      C1_A[ind_subj,ind_q] <- (Q1_A[ind_subj,ind_q] * FV1_A[ind_subj,ind_q])
      C1_B[ind_subj,ind_q] <- (Q1_B[ind_subj,ind_q] * FV1_B[ind_subj,ind_q])
      K2INH[ind_subj,ind_q] <- (K2[ind_subj] * (1 - (C1_A[ind_subj,ind_q] / (C1_A[ind_subj,ind_q] + IC50COMBO[ind_subj]))))
      WTOT[ind_subj,ind_q] <- (((Z0[ind_subj,ind_q] + Z1[ind_subj,ind_q]) + Z2[ind_subj,ind_q]) + Z3[ind_subj,ind_q])
    }
  }
  par_CV1 <- 1
  par_CV2 <- 1
  par_IC50COMBO1 <- 1
  par_IC50COMBO2 <- 1
  POP_LAMBDA0 <- 0.14
  POP_LAMBDA1 <- 0.129
  POP_W0 <- 0.062
  POP_K1 <- 3.54
  POP_K2 <- 0.221
  POP_IC50 <- 2.02
  SIGMA_RES_W <- 1
  CV <- 0.1
  POP_IC50COMBO <- 1
  # PRIORS
}
