unused argument in plot_model_prediction()
UNCcrawler opened this issue · comments
Hi Professor Hooker:
I am new to your package. I was trying to prepare a template using RxODE and encountered two unexpected errors. Could you please help me?
-
The error is in bold
plot_model_prediction(design$poped.db, model_num_points = 500, PI = T)
Error in model_prediction(poped.db, model_num_points = model_num_points, :
unused argument (PI = T)
In addition, can we change the display of the plot? eg. color, label, legend title, etc -
In the output, the parameters were not named as defined in create.poped.database(d = c(KA = 0.09, CL = 0.25^2, V = 0.09)) as in your example
optimized.design$rse
bpop[1] bpop[2] bpop[3] D[1,1] D[2,2] D[3,3]
13.181201 4.887268 9.723204 95.296309 33.934192 51.834468
SIGMA[1,1] SIGMA[2,2]
39.510102 26.998621
The full code is below:
`library(PopED)
library(RxODE)
sessionInfo()
########################################################################################################
Define model using RxODE
########################################################################################################
model structure
mod = RxODE({
CP = CENT/V;
d/dt(DEPOT) = -KADEPOT;
d/dt(CENT) = KADEPOT - (CL/V)*CENT;
})
simulation function
xt=sampling time, p=parameter, poped.db = PopED database
ff = function(model_switch, xt, p, poped.db){
times_xt = drop(xt)
ev = et(time = 0, amt = p[["DOSE"]], ii = p[["TAU"]], until = max(times_xt))%>%
et(times_xt)
out = rxSolve(mod, p, ev)
return(list(y = matrix(out$CP, ncol =1), poped.db = poped.db))
}
define BSV
a = c(dose, dosing interval), bpop = theta, b = eta
sfg = function(x, a, bpop, b, bocc){
parameters = c(
KA = bpop[1]*exp(b[1]),
CL = bpop[2]*exp(b[2]),
V = bpop[3]*exp(b[3]),
DOSE = a[1],
TAU = a[2]
)
return(parameters)
}
define residual error
feps = function(model_switch, xt, parameters, epsi, poped.db){
y = do.call(poped.db$model$ff_pointer, list(model_switch, xt, parameters, poped.db))[[1]] # simulate to obtain F
y = y*(1+epsi[,1])+epsi[,2]
return(list(y = y, poped.db = poped.db))
}
create PopED databases
poped_db = create.poped.database(ff_fun = ff,
fg_fun = sfg,
fError_fun = feps,
bpop = c(KA = 0.25, CL = 3.75, V = 72.8), # population parameter
d = c(KA = 0.09, CL = 0.25^2, V = 0.09), # BSV variability in variance
sigma = c(prop = 0.04, add = 0.0025),
m = 2, # 2 groups
groupsize = 20, # each group has 20 subjects
xt = c(1, 2, 8, 240, 245), # initial design of sampling time
minxt = c(0, 0, 0, 240, 240), # 5 sampling timepoints, minimum for each
maxxt = c(10, 10, 10, 248, 248), # 5 sampling timespoints, maximum for each
bUseGrouped_xt = 1, # set both groups have same sampling time to true
a = cbind(DOSE = c(20, 40), TAU = c(24, 24)), # initial dosing for group 1 (dose 20, tau 24) and group 2 (dose 40, tau 24)
maxa = c(DOSE = 200, TAU = 24), # maximum dose and dosing interval
mina = c(DOSE = 0, TAU = 24)) # minimum dose and dosing interval
model prediction
pred = model_prediction(poped_db,
model_num_points = 500, # result in 505 observation for each group (+5 xt time points)
include_sample_times = T)
plot model prediction
plot_model_prediction(poped_db,
model_num_points = 500,
separate.groups = T)
plot_model_prediction(poped_db,
model_num_points = 500,
separate.groups = T,
PI = T)
evaluate design
intial.design = evaluate_design(poped_db)
intial.design$ofv
intial.design$rse
design optimization, time as continuous
design = poped_optim(poped_db, opt_xt = T)
plot_model_prediction(design$poped.db, model_num_points = 500)
optimized.design = evaluate_design(design$poped.db)
optimized.design$ofv
optimized.design$rse
`
sessioninfo as below:
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RxODE_0.9.2-0 PopED_0.4.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 pillar_1.4.4 compiler_3.6.3
[4] sys_3.2 PreciseSums_0.3 prettyunits_1.0.2
[7] remotes_2.1.1 tools_3.6.3 mvnfast_0.2.5
[10] testthat_2.3.2 digest_0.6.25 pkgbuild_1.0.6
[13] pkgload_1.0.2 tibble_3.0.1 memoise_1.1.0
[16] lifecycle_0.2.0 gtable_0.3.0 pkgconfig_2.0.2
[19] rlang_0.4.5 cli_2.0.2 rstudioapi_0.11
[22] curl_3.3 dplyr_0.8.5 withr_2.1.2
[25] vctrs_0.2.4 desc_1.2.0 fs_1.3.1
[28] devtools_2.3.0 tidyselect_0.2.5 rprojroot_1.3-2
[31] grid_3.6.3 data.table_1.12.8 glue_1.4.0
[34] R6_2.4.1 processx_3.4.0 fansi_0.4.1
[37] sessioninfo_1.1.1 dparser_0.1.8 purrr_0.3.4
[40] ggplot2_3.3.0 callr_3.4.3 magrittr_1.5
[43] units_0.6-3 backports_1.1.4 scales_1.0.0
[46] ps_1.3.0 ellipsis_0.3.0 usethis_1.6.1
[49] assertthat_0.2.1 colorspace_1.4-1 labeling_0.3
[52] lotri_0.2.1 munsell_0.5.0 crayon_1.3.4
Hi
The answer to both of your questions is to use the development version of PopED from GitHub.
All plots created by PopED are ggplot2 objects and can be manipulated as you would any other ggplot created plot.
Best regards,
Andrew