pkmod_prior <- pkmod(pars_pk = c(cl = 10, q2 = 2, q3 =20, v = 15, v2 = 30, v3 = 50, ke0 = 1.2))
pkmod_true <- pkmod(pars_pk = c(cl = 16, q2 = 4, q3 =10, v = 20, v2 = 20, v3 = 80, ke0 = 0.8),
sigma_add = 0.1, log_response = TRUE)
target_vals <- c(2,3,4,3,3)
target_tms <- c(0,5,10,36,60)
obs_tms <- c(1,2,4,8,12,16,24,36,48)
sim <- olc(pkmod_prior, pkmod_true, target_vals, target_tms, obs_tms)
len <- 500
tms <- seq(0,60,length.out = len)
df <- data.frame(time = rep(tms,2),
value = c(predict(pkmod_true, sim$inf,tms)[,1],
predict(pkmod_prior, sim$inf,tms)[,1]),
type = c(rep("true",len),rep("prior",len)))
library(ggplot2)
ggplot(df, aes(x = time, y = value, color = type)) +
geom_step(data = data.frame(time = target_tms, value = target_vals),
aes(x = time, y = value), inherit.aes = FALSE) +
geom_line() +
geom_point(data = sim$obs, aes(x = time, y = obs), inherit.aes = FALSE)
Run the code above in your browser using DataLab