Dear All,
 
I made some headways on my ODE problem in R2OpenBUGS, but got stuck again. 
Wonder if someone could help on the following:
 
I am running the following code:
 
library(R2OpenBUGS)
dosetotal <-c(500,250)
z <-c(4,2)
grid <-c(4,15)
n.grid <-2
tol <-0.001
dim <-2
T <-2
origin <-0
dosetime <-c("1/05/2013 0:00","1/06/2013 00:00")
dose <-tail(dosetotal, n=1)
dosetime <-as.POSIXct(dosetime,format='%m/%d/%Y %H:%M')
times 
<-matrix(c(difftime(dosetime[2],dosetime[1],units="hours"),difftime(dosetime[3],dosetime[2],units="hours"),difftime(dosetime[4],dosetime[3],units="hours"),difftime(dosetime[5],dosetime[4],units="hours"),difftime(dosetime[6],dosetime[5],units="hours")))
times[ is.na(times) ] <- 0
KSTART <-0.06
dosetotal 
<-matrix(c(dosetotal[1],dosetotal[2],dosetotal[3],dosetotal[4],dosetotal[5]))
dosetotal[ is.na(dosetotal) ] <- 0
initc <-if (times[1,]==0) 0 else 
dosetotal[1]*exp(-KSTART*(times[1]+times[2]+times[3]+times[4]+times[5]))+dosetotal[2]*exp(-KSTART*(times[2]+times[3]+times[4]+times[5]))+dosetotal[3]*exp(-KSTART*(times[3]+times[4]+times[5]))+dosetotal[4]*exp(-KSTART*(times[4]+times[5]))+dosetotal[5]*exp(-KSTART*times[5])-ifelse(dosetotal[2,]==0,0,dose)
model <- function() {
    for (i in 1:1) { 
    for (j in 1:T) {
    z[j] ~ dnorm(Cb[j], 100)
    Cb[j] <- solution[j, 2] / vb
  }
  solution[1:n.grid, 1:dim] <- ode(init[1:dim], grid[1:n.grid], D(A[1:2], 
t),origin,tol)
  D(A[1], t) <- -ka * A[1]
  D(A[2], t) <- ka * A[1] - ke * A[2]
  init[1] <- dose
  init[2] <- initc
  kea ~ dnorm(0,6.25)
  kaa ~ dnorm(0,6.25)
  vba ~ dnorm(0,6.25)
  theta1 <-0.06 
  theta2 <-1.5  
  theta3 <-50
  ke <-theta1*exp(kea)
  ka <-theta2*exp(kaa)
  vb <-theta3*exp(vba)  
}
}
res <- bugs(list(z = z, T = T,initc = initc, dose = dose,n.grid = n.grid, dim = 
dim, grid = grid, origin = origin, tol=tol), debug = FALSE,model.file = model, 
inits = NULL, parameters.to.save=c("ke", "ka", "vb"), n.chains=3, n.iter=10000)
finalfdsc <- res$summary
 
which will give me my well deserved results for the parameters I was looking 
for:-). My question is that is there a way to use the predict function somehow 
with the results generated to predict values for z at times let us say 0 to 10 
at 1 hour intervals? I know predict will take results of nls, but I am having 
difficulties getting results with the bugs data...
 
Apreciate the help,
 
sincerely,
 
Andras
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to