data <- data.frame(ID = 1:3, AGE = c(20,30,40), TBW = c(60,70,80),
HGT = c(150,160,170), MALE = c(TRUE,FALSE,TRUE))
pkmod_prior <- poppkmod(data, drug = "ppf", model = "eleveld")
pkmod_true <- poppkmod(data, drug = "ppf", model = "eleveld", sample = TRUE)
obs_tms <- seq(1/6,10,1/6)
update_tms <- c(2,4,6,8)
target_vals = c(75,60,50,50)
target_tms = c(0,3,6,10)
if (FALSE) {
sim <- simulate_clc(pkmod_prior, pkmod_true, target_vals, target_tms, obs_tms,
update_tms, seed = 200)
len <- 500
tms <- seq(0,10,length.out = len)
resp <- data.frame(rbind(predict(pkmod_true, sim$inf, tms),
predict(pkmod_prior, sim$inf, tms),
predict(sim$pkmod_post, sim$inf, tms)))
resp$type = c(rep("true",len*3),rep("prior",len*3),rep("posterior",len*3))
library(ggplot2)
ggplot(resp) + geom_line(aes(x = time, y = pdresp, color = factor(id))) +
facet_wrap(~type) + labs(x = "Hours", y = "Bispectral Index") +
geom_step(data = data.frame(time = target_tms, value = target_vals),
aes(x = time, y = value), inherit.aes = FALSE)
}
Run the code above in your browser using DataLab