data <- data.frame(ID = 1:5, AGE = seq(20,60,by=10), TBW = seq(60,80,by=5),
HGT = seq(150,190,by=10), MALE = c(TRUE,TRUE,FALSE,FALSE,FALSE))
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)
target_vals = c(75,60,50,50)
target_tms = c(0,3,6,10)
sim <- simulate_olc(pkmod_prior, pkmod_true, target_vals, target_tms, obs_tms)
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)))
resp$type = c(rep("true",len*5),rep("prior",len*5))
library(ggplot2)
ggplot(resp) + geom_line(aes(x = time, y = pdresp, color = factor(id))) + facet_wrap(~type) +
labs(x = "Hours", y = "Bispectral Index") + theme_bw() +
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