Perform simulations for VPC plot
Usage
sg_vpc_sim(
fpath_i,
gco = NULL,
model = NULL,
time_col = "TIME",
outputs = NULL,
npop = 100
)Arguments
- fpath_i
String, GFO, or a named list with a
GFOcomponent (and optionallyGCO). If a string is given, the path to a.RDataor.jsonfile with a fit object is expected.- gco
GCO. Either an R list or path to an RData/json file. Either
gcoormodelshould be specified for model specification. Default isNULL.- model
GMO. RxODE2 model used when
gcois not supplied. Default isNULL.- time_col
String. The column to use as a time column. Currently, can be only
TIME. Default isTIME.- outputs
Vector of strings. Names of the model variables to output. If
NULL, all variables returned. Default isNULL.- npop
Integer specifying the number of virtual subjects to simulate per original individual. Higher values provide more robust percentile estimates but increase computation time. Default is
100
Value
GSO: a data frame with simulation results.
Examples
# \donttest{
library(rxode2)
library(tibble)
fpath_i <- system.file("extdata", "simurg_object", "Warfarin_PK.RData", package = "SimuRg")
#> Warning: cannot open compressed file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/DESCRIPTION', probable reason 'No such file or directory'
# Simulate VPC from with generalized model object
mod <- rxode2::rxode2({
ka_pop = 0.1;
Vd_pop = 10;
Cl_pop = 0.5;
omega_ka = 0;
omega_Vd = 0;
omega_Cl = 0;
Cc_b = 0;
ka_tv = exp(ka_pop);
Vd_tv = exp(Vd_pop);
Cl_tv = exp(Cl_pop);
ka = ka_tv * exp(omega_ka);
Vd = Vd_tv * exp(omega_Vd);
Cl = Cl_tv * exp(omega_Cl);
Cc = Ac / Vd;
Ad(0) = 0;
Ac(0) = 0;
d/dt(Ad) = -ka * Ad;
d/dt(Ac) = ka * Ad - Cl * Cc;
Cc_ResErr = Cc * (1 + Cc_b);
})
#>
#>
sg_vpc_sim(fpath_i, model=mod, outputs = "Cc_ResErr")
#> Error: cannot open file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/R/SimuRg.rdb': No such file or directory
# Make VPC plot with the generalized control object
model <- system.file("extdata", "models", "rxode", "model_PK_1c.txt", package = "SimuRg")
#> Warning: cannot open compressed file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/DESCRIPTION', probable reason 'No such file or directory'
data <- system.file("extdata", "datasets", "dspk-warf.csv", package = "SimuRg")
#> Warning: cannot open compressed file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/DESCRIPTION', probable reason 'No such file or directory'
headers <- list(list(name = "ID", use = "identifier", type = NULL),
list(name = "TIME", use = "time", type = NULL),
list(name = "DV", use = "observation", type = "continuous"),
list(name = "DVID", use = "observationtype", type = NULL),
list(name = "ADM", use = "administration", type = NULL),
list(name = "AMT", use = "amount", type = NULL),
list(name = "EVID", use = "eventidentifier", type = NULL),
list(name = "MDV", use = "missingdependentvariable", type = NULL),
list(name = "AGE", use = "covariate", type = "continuous"),
list(name = "AGE_centered", use = "covariate", type = "continuous"),
list(name = "SEX", use = "covariate", type = "categorical"),
list(name = "WEIGHT", use = "covariate", type = "continuous"),
list(name = "BMI", use = "covariate", type = "continuous"))
theta <- tribble(~NAME, ~TRANS, ~INIT, ~LB, ~UB, ~EST,
"Cl", "logNormal", 0.2, NA, NA, TRUE,
"V", "logNormal", 20, NA, NA, TRUE,
"ka", "logNormal", 0.2, NA, NA, TRUE
)
ruv <- list(YNAME = "y1", DVID = 1, TRANS = "normal", PRED = "Cc",
ERR = "combined1", INIT = c(1, 1), EST = c(TRUE, TRUE), BLQM = NULL)
re <- list(init = tribble(~Cl, ~V, ~ka,
1, 0, 0,
0, 1, 0,
0, 0, 1) %>% as.matrix(),
est = tribble(~Cl, ~V, ~ka,
TRUE, NA, NA,
NA, TRUE, NA,
NA, NA, TRUE) %>% as.matrix())
occ <- list(init = tribble(~Cl, ~V, ~ka,
0, 0, 0,
0, 0, 0,
0, 0, 0) %>% as.matrix(),
est = tribble(~Cl, ~V, ~ka,
NA, NA, NA,
NA, NA, NA,
NA, NA, NA) %>% as.matrix())
covs <- list(list(PAR = "V", COVNAME = "AGE", FUNC = "linear",
TRANS = "median", INIT = 1, EST = TRUE),
list(PAR = "ka", COVNAME = "SEX", REF = 0, INIT = 1, EST = TRUE))
gco <-list(headers = headers, data = data, model = model, task_opt = "",
covs = covs, project_name = "test-proj", theta = theta,
ruv = ruv, re = re, occ = occ, modelText = "")
res <- sg_vpc_sim(fpath_i, gco = gco, output = "Cc")
#> Warning: restarting interrupted promise evaluation
#> Error: cannot open file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/R/SimuRg.rdb': No such file or directory
# }
