PopED
16: stop("Discrete value supplied to continuous scale", call. = FALSE)
15: scales::train_continuous(x, self$range)
14: f(..., self = self)
13: self$range$train(x)
12: f(..., self = self)
11: self$train(df[[aesthetic]])
10: f(..., self = self)
9: scale$train_df(df = df)
8: FUN(X[[i]], ...)
7: lapply(scales$scales, function(scale) scale$train_df(df = df))
6: FUN(X[[i]], ...)
5: lapply(data, scales_train_df, scales = npscales)
4: ggplot_build.ggplot(x)
3: ggplot_build(x)
2: print.ggplot(x)
1: function (x, ...)
UseMethod("print")(x)
system.file("examples", package="PopED")
#> [1] "/Library/Frameworks/R.framework/Versions/3.4/Resources/library/PopED/examples"
library(PopED)
set.seed(1234)
ff <- function(model_switch,xt,parameters,poped.db){
with(as.list(parameters),{
N = floor(xt/TAU)+1
y=(DOSE*Favail/V)*(KA/(KA - CL/V)) *
(exp(-CL/V * (xt - (N - 1) * TAU)) * (1 - exp(-N * CL/V * TAU))/(1 - exp(-CL/V * TAU)) -
exp(-KA * (xt - (N - 1) * TAU)) * (1 - exp(-N * KA * TAU))/(1 - exp(-KA * TAU)))
return(list( y=y,poped.db=poped.db))
})
}
sfg <- function(x,a,bpop,b,bocc){
parameters=c( V=bpop[1]*exp(b[1]),
KA=bpop[2]*exp(b[2]),
CL=bpop[3]*exp(b[3]),
Favail=bpop[4],
DOSE=a[1],
TAU=a[2])
}
feps <- function(model_switch,xt,parameters,epsi,poped.db){
returnArgs <- ff(model_switch,xt,parameters,poped.db)
y <- returnArgs[[1]]
poped.db <- returnArgs[[2]]
y = y*(1+epsi[,1])+epsi[,2]
return(list(y=y,poped.db=poped.db))
}
poped.db <- create.poped.database(ff_fun=ff,
fg_fun=sfg,
fError_fun=feps,
bpop=c(V=72.8,KA=0.25,CL=3.75,Favail=0.9),
notfixed_bpop=c(1,1,1,0),
d=c(V=0.09,KA=0.09,CL=0.25^2),
sigma=c(0.04,5e-6),
notfixed_sigma=c(1,0),
m=2,
groupsize=20,
a=list(c(DOSE=20,TAU=24),c(DOSE=40, TAU=24)),
maxa=c(DOSE=200,TAU=24),
mina=c(DOSE=0,TAU=24),
xt=c( 1,2,8,240,245),
minxt=c(0,0,0,240,240),
maxxt=c(10,10,10,248,248),
bUseGrouped_xt=TRUE)
plot_model_prediction(poped.db, model_num_points=500, IPRED=T)
#> Don't know how to automatically pick scale for object of type NULL. Defaulting to continuous.
#> Error: Discrete value supplied to continuous scale
## Warfarin example from software comparison in:
## Nyberg et al., "Methods and software tools for design evaluation
## for population pharmacokinetics-pharmacodynamics studies",
## Br. J. Clin. Pharm., 2014.
library(PopED)
## find the parameters that are needed to define from the structural model ff.PK.1.comp.oral.md.CL
## -- parameter definition function
## -- names match parameters in function ff
sfg <- function(x,a,bpop,b,bocc){
parameters=c(CL=bpop[1]*exp(b[1]),
V=bpop[2]*exp(b[2]),
KA=bpop[3]*exp(b[3]),
Favail=bpop[4],
DOSE=a[1])
return(parameters)
}
## -- Define initial design and design space
poped.db <- create.poped.database(ff_file="ff.PK.1.comp.oral.sd.CL",
fg_file="sfg",
fError_file="feps.prop",
bpop=c(CL=0.15, V=8, KA=1.0, Favail=1),
notfixed_bpop=c(1,1,1,0),
d=c(CL=0.07, V=0.02, KA=0.6),
sigma=0.01,
groupsize=32,
xt=c( 0.5,1,2,6,24,36,72,120),
minxt=0,
maxxt=120,
a=70)
plot_model_prediction(poped.db,IPRED=TRUE,DV=TRUE)
#> Don't know how to automatically pick scale for object of type NULL. Defaulting to continuous.Created on 2018-05-15 by the reprex package (v0.2.0).
Created on 2018-05-15 by the reprex package (v0.2.0).
