Title: | Interface to the 'Pharmpy' 'Pharmacometrics' Library |
---|---|
Description: | Interface to the 'Pharmpy' 'pharmacometrics' library. The 'Reticulate' package is used to interface Python from R. |
Authors: | Rikard Nordgren [aut, cre, cph], Stella Belin [aut, cph], Mats O. Karlsson [sad], Andrew C. Hooker [sad], Xiaomei Chen [sad], Sebastian Ueckert [sad] , Simon Buatois [rev], João A. Abrantes [rev], Emilie Schindler [rev], F. Hoffmann-La Roche Ltd. [fnd], Bayer AG [fnd] |
Maintainer: | Rikard Nordgren <[email protected]> |
License: | LGPL (>= 3) |
Version: | 1.3.0 |
Built: | 2024-11-20 15:36:24 UTC |
Source: | https://github.com/pharmpy/pharmr |
Add an admid column to the model dataset and datainfo. Dependent on the presence of a CMT column in order to add admid correctly.
When generated, admids of events in between doses is set to the last used admid.
add_admid(model)
add_admid(model)
model |
(Model) Pharmpy model |
(model : Model) Pharmpy model
get_admid : Get or create an admid column
get_cmt : Get or create a cmt column
Add allometric scaling of parameters
Add an allometric function to each listed parameter. The function will be P=P*(X/Z)**T where P is the parameter, X the allometric_variable, Z the reference_value and T is a theta. Default is to automatically use clearance and volume parameters.
If there already exists a covariate effect (or allometric scaling) on a parameter with the specified allometric variable, nothing will be added.
If no allometric variable is specified, it will be extracted from the dataset based on the descriptor "body weight".
add_allometry( model, allometric_variable = NULL, reference_value = 70, parameters = NULL, initials = NULL, lower_bounds = NULL, upper_bounds = NULL, fixed = TRUE )
add_allometry( model, allometric_variable = NULL, reference_value = 70, parameters = NULL, initials = NULL, lower_bounds = NULL, upper_bounds = NULL, fixed = TRUE )
model |
(Model) Pharmpy model |
allometric_variable |
(str or Expr (optional)) Value to use for allometry (X above) |
reference_value |
(numeric or str or Expr) Reference value (Z above) |
parameters |
(array(numeric or str or Expr) (optional)) Parameters to use or NULL (default) for all available CL, Q and V parameters |
initials |
(array(numeric) (optional)) Initial estimates for the exponents. Default is to use 0.75 for CL and Qs and 1 for Vs |
lower_bounds |
(array(numeric) (optional)) Lower bounds for the exponents. Default is 0 for all parameters |
upper_bounds |
(array(numeric) (optional)) Upper bounds for the exponents. Default is 2 for all parameters |
fixed |
(logical) Whether the exponents should be fixed |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- remove_covariate_effect(model, 'CL', 'WGT') model <- remove_covariate_effect(model, 'V', 'WGT') model <- add_allometry(model, allometric_variable='WGT') model$statements$before_odes ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_covariate_effect(model, 'CL', 'WGT') model <- remove_covariate_effect(model, 'V', 'WGT') model <- add_allometry(model, allometric_variable='WGT') model$statements$before_odes ## End(Not run)
Add bioavailability statement for the first dose compartment of the model. Can be added as a new parameter or otherwise it will be set to 1. If added as a parameter, a logit transformation can also be applied.
add_bioavailability(model, add_parameter = TRUE, logit_transform = FALSE)
add_bioavailability(model, add_parameter = TRUE, logit_transform = FALSE)
model |
(Model) Pharmpy model |
add_parameter |
(logical) Add new parameter representing bioavailability or not |
logit_transform |
(logical) Logit transform the added bioavailability parameter. |
(Model) Pharmpy model object
remove_bioavailability
## Not run: model <- load_example_model("pheno") model <- add_bioavailability(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_bioavailability(model) ## End(Not run)
Add a CMT column to the model dataset and datainfo if not existed
In case of multiple doses, this method is dependent on the presence of an admid column to correctly number each dose.
NOTE : Existing CMT is based on datainfo type being set to 'compartment' and a column named 'CMT' can be replaced
add_cmt(model)
add_cmt(model)
model |
(Model) Pharmpy model |
(model : Model) Pharmpy model
get_admid : Get or create an admid column
get_cmt : Get or create a cmt column
Adds covariate effect to :class:pharmpy.model
.
The following effects have templates:
Linear function for continuous covariates (lin)
Function:
(equation could not be rendered, see API doc on website)
Init: 0.001
Upper:
If median of covariate equals minimum: 100,000
Otherwise: (equation could not be rendered, see API doc on website)
Lower:
If median of covariate equals maximum: -100,000
Otherwise: (equation could not be rendered, see API doc on website)
Linear function for categorical covariates (cat)
Function:
If covariate is the most common category:
(equation could not be rendered, see API doc on website)
For each additional category:
(equation could not be rendered, see API doc on website)
Init: 0.001
Upper: 5
Lower: -1
(alternative) Linear function for categorical covariates (cat2)
Function:
If covariate is the most common category:
(equation could not be rendered, see API doc on website)
For each additional category:
(equation could not be rendered, see API doc on website)
Init: 0.001
Upper: 6
Lower: 0
Piecewise linear function/"hockey-stick", continuous covariates only (piece_lin)
Function:
If cov <= median:
(equation could not be rendered, see API doc on website)
If cov > median:
(equation could not be rendered, see API doc on website)
Init: 0.001
Upper:
For first state: (equation could not be rendered, see API doc on website)
Otherwise: 100,000
Lower:
For first state: -100,000
Otherwise: (equation could not be rendered, see API doc on website)
Exponential function, continuous covariates only (exp)
Function:
(equation could not be rendered, see API doc on website)
Init:
If lower > 0.001 or upper < 0.001: (equation could not be rendered, see API doc on website)
If estimated init is 0: (equation could not be rendered, see API doc on website)
Otherwise: 0.001
Upper:
If min - median = 0 or max - median = 0: 100
Otherwise:
(equation could not be rendered, see API doc on website)
Lower:
If min - median = 0 or max - median = 0: 0.01
Otherwise:
(equation could not be rendered, see API doc on website)
Power function, continuous covariates only (pow)
Function:
(equation could not be rendered, see API doc on website)
Init: 0.001
Upper: 100,000
Lower: -100
add_covariate_effect( model, parameter, covariate, effect, operation = "*", allow_nested = FALSE )
add_covariate_effect( model, parameter, covariate, effect, operation = "*", allow_nested = FALSE )
model |
(Model) Pharmpy model to add covariate effect to. |
parameter |
(str) Name of parameter to add covariate effect to. |
covariate |
(str) Name of covariate. |
effect |
(str) Type of covariate effect. May be abbreviated covariate effect (see above) or custom. |
operation |
(str) Whether the covariate effect should be added or multiplied (default). |
allow_nested |
(logical) Whether to allow adding a covariate effect when one already exists for the input parameter-covariate pair. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_covariate_effect(model, "CL", "APGR", "exp") model$statements$before_odes$full_expression("CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_covariate_effect(model, "CL", "APGR", "exp") model$statements$before_odes$full_expression("CL") ## End(Not run)
Add a derivative to be calculcated when running the model. Currently, only derivatives with respect to the prediction is supported. Default is to add all possible ETA and EPS derivatives. First order derivates are specied either by single string or single-element tuple. For instance with_respect_to = "ETA_1" or with_respect_to = ("ETA_1",)
Second order derivatives are specified by giving the two independent varibles in a tuple of tuples. For instance with_respect_to ((ETA_1, EPS_1),)
Multiple derivatives can be specified within a tuple. For instance ((ETA_1, EPS_1), "ETA_1")
Currently, only ETAs and EPSILONs are supported
add_derivative(model, with_respect_to = NULL)
add_derivative(model, with_respect_to = NULL)
model |
(Model) Pharmpy modeas. |
with_respect_to |
(array(array(str) or str) or str (optional)) Parameter name(s) to use as independent variables. Default is NULL. |
(Pharmpy model.)
Add an effect compartment.
Implemented PD models are:
Linear:
(equation could not be rendered, see API doc on website)
Emax:
(equation could not be rendered, see API doc on website)
Step effect:
(equation could not be rendered, see API doc on website)
Sigmoidal:
(equation could not be rendered, see API doc on website)
Log-linear:
(equation could not be rendered, see API doc on website)
(equation could not be rendered, see API doc on website)
add_effect_compartment(model, expr)
add_effect_compartment(model, expr)
model |
(Model) Pharmpy model |
expr |
(str) Name of the PD effect function. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_effect_compartment(model, "linear") model$statements$ode_system$find_compartment("EFFECT") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_effect_compartment(model, "linear") model$statements$ode_system$find_compartment("EFFECT") ## End(Not run)
Add estimation step
Adds estimation step for a model in a given index. Methods currently supported are: FO, FOCE, ITS, LAPLACE, IMPMAP, IMP, SAEM
add_estimation_step(model, method, idx = NULL, ...)
add_estimation_step(model, method, idx = NULL, ...)
model |
(Model) Pharmpy model |
method |
(str) estimation method to change to |
idx |
(numeric (optional)) index of estimation step (starting from 0), default is NULL (adds step at the end) |
... |
Arguments to pass to EstimationStep (such as interaction, evaluation) |
(Model) Pharmpy model object
set_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
set_evaluation_step
## Not run: model <- load_example_model("pheno") opts <- list('NITER'=1000, 'ISAMPLE'=100) model <- add_estimation_step(model, 'IMP', tool_options=opts) ests <- model$execution_steps length(ests) ests[2] ## End(Not run)
## Not run: model <- load_example_model("pheno") opts <- list('NITER'=1000, 'ISAMPLE'=100) model <- add_estimation_step(model, 'IMP', tool_options=opts) ests <- model$execution_steps length(ests) ests[2] ## End(Not run)
Adds IIVs to :class:pharmpy.model
.
Effects that currently have templates are:
Additive (add)
Proportional (prop)
Exponential (exp)
Logit (log)
Rescaled logit (re_log)
For all except exponential the operation input is not needed. Otherwise user specified input is supported. Initial estimates for new etas are 0.09.
Assuming a statement (equation could not be rendered, see API doc on website)
Additive: (equation could not be rendered, see API doc on website)
Proportional: (equation could not be rendered, see API doc on website)
Exponential: (equation could not be rendered, see API doc on website)
Logit: (equation could not be rendered, see API doc on website)
Rescaled logit: (equation could not be rendered, see API doc on website) with (equation could not be rendered, see API doc on website)
add_iiv( model, list_of_parameters, expression, operation = "*", initial_estimate = 0.09, eta_names = NULL )
add_iiv( model, list_of_parameters, expression, operation = "*", initial_estimate = 0.09, eta_names = NULL )
model |
(Model) Pharmpy model to add new IIVs to. |
list_of_parameters |
(array(str) or str) Name/names of parameter to add new IIVs to. |
expression |
(array(str) or str) Effect/effects on eta. Either abbreviated (see above) or custom. |
operation |
(str) Whether the new IIV should be added or multiplied (default). |
initial_estimate |
(numeric) Value of initial estimate of parameter. Default is 0.09 |
eta_names |
(array(str) (optional)) Custom name/names of new eta |
(Model) Pharmpy model object
add_pk_iiv
add_iov
remove_iiv
remove_iov
## Not run: model <- load_example_model("pheno") model <- remove_iiv(model, "CL") model <- add_iiv(model, "CL", "add") model$statements$find_assignment("CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_iiv(model, "CL") model <- add_iiv(model, "CL", "add") model$statements$find_assignment("CL") ## End(Not run)
Add indirect (turnover) effect
The concentration (equation could not be rendered, see API doc on website)
Production:
(equation could not be rendered, see API doc on website)
Degradation:
(equation could not be rendered, see API doc on website)
(equation could not be rendered, see API doc on website) Baseline (equation could not be rendered, see API doc on website)
Models:
Linear:
(equation could not be rendered, see API doc on website)
Emax:
(equation could not be rendered, see API doc on website)
Sigmoidal:
(equation could not be rendered, see API doc on website)
add_indirect_effect(model, expr, prod = TRUE)
add_indirect_effect(model, expr, prod = TRUE)
model |
(Model) Pharmpy model |
expr |
(str) Production (TRUE) (default) or degradation (FALSE) |
prod |
(logical) Name of PD effect function. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_indirect_effect(model, expr='linear', prod=TRUE) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_indirect_effect(model, expr='linear', prod=TRUE) ## End(Not run)
Add an individual or pk parameter to a model
add_individual_parameter(model, name)
add_individual_parameter(model, name)
model |
(Model) Pharmpy model |
name |
(str) Name of individual/pk parameter |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_individual_parameter(model, "KA") model$statements$find_assignment("KA") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_individual_parameter(model, "KA") model$statements$find_assignment("KA") ## End(Not run)
Adds IOVs to :class:pharmpy.model
.
Initial estimate of new IOVs are 10% of the IIV eta it is based on.
add_iov( model, occ, list_of_parameters = NULL, eta_names = NULL, distribution = "disjoint" )
add_iov( model, occ, list_of_parameters = NULL, eta_names = NULL, distribution = "disjoint" )
model |
(Model) Pharmpy model to add new IOVs to. |
occ |
(str) Name of occasion column. |
list_of_parameters |
(array(str) or str (optional)) List of names of parameters and random variables. Accepts random variable names, parameter names, or a mix of both. |
eta_names |
(array(str) or str (optional)) Custom names of new etas. Must be equal to the number of input etas times the number of categories for occasion. |
distribution |
(str) The distribution that should be used for the new etas. Options are 'disjoint' for disjoint normal distributions, 'joint' for joint normal distribution, 'explicit' for an explicit mix of joint and disjoint distributions, and 'same-as-iiv' for copying the distribution of IIV etas. |
(Model) Pharmpy model object
add_iiv
add_pk_iiv
remove_iiv
remove_iov
## Not run: model <- load_example_model("pheno") model <- add_iov(model, "TIME", "CL") model$statements$find_assignment("CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_iov(model, "TIME", "CL") model$statements$find_assignment("CL") ## End(Not run)
Add lag time to the dose compartment of model.
Initial estimate for lag time is set the previous lag time if available, otherwise it is set to the time of first observation/2.
add_lag_time(model)
add_lag_time(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_transit_compartments
remove_lag_time
## Not run: model <- load_example_model("pheno") model <- add_lag_time(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_lag_time(model) ## End(Not run)
Adds a metabolite compartment to a model
The flow from the central compartment to the metabolite compartment will be unidirectional.
Presystemic indicate that the metabolite compartment will be directly connected to the DEPOT. If a depot compartment is not present, one will be created.
add_metabolite(model, drug_dvid = 1, presystemic = FALSE)
add_metabolite(model, drug_dvid = 1, presystemic = FALSE)
model |
(Model) Pharmpy model |
drug_dvid |
(numeric) DVID for drug (assuming all other DVIDs being for metabolites) |
presystemic |
(logical) Decide wether or not to add metabolite as a presystemetic fixed drug. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_metabolite(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_metabolite(model) ## End(Not run)
Adds parameter uncertainty step to the final estimation step
add_parameter_uncertainty_step(model, parameter_uncertainty_method)
add_parameter_uncertainty_step(model, parameter_uncertainty_method)
model |
(Model) Pharmpy model |
parameter_uncertainty_method |
(str) Parameter uncertainty method to use |
(Model) Pharmpy model object
add_estimation_step
set_estimation_step
remove_estimation_step
append_estimation_step_options
remove_parameter_uncertainty_step
set_evaluation_step
## Not run: model <- load_example_model("pheno") model <- set_estimation_step(model, 'FOCE', parameter_uncertainty_method=NULL) model <- add_parameter_uncertainty_step(model, 'SANDWICH') ests <- model$execution_steps ests[1] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_estimation_step(model, 'FOCE', parameter_uncertainty_method=NULL) model <- add_parameter_uncertainty_step(model, 'SANDWICH') ests <- model$execution_steps ests[1] ## End(Not run)
Adds IIVs to all PD parameters in :class:pharmpy.model
.
add_pd_iiv(model, initial_estimate = 0.09)
add_pd_iiv(model, initial_estimate = 0.09)
model |
(Model) Pharmpy model to add new IIVs to. |
initial_estimate |
(numeric) Value of initial estimate of parameter. Default is 0.09 |
(Model) Pharmpy model object
add_iiv
add_iov
remove_iiv
remove_iov
## Not run: model <- load_example_model("pheno") model <- set_direct_effect(model, 'emax') model$statements$find_assignment("EC_50") model <- add_pd_iiv(model) model$statements$find_assignment("EC_50") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_direct_effect(model, 'emax') model$statements$find_assignment("EC_50") model <- add_pd_iiv(model) model$statements$find_assignment("EC_50") ## End(Not run)
Add a peripheral distribution compartment to model
The rate of flow from the central to the peripheral compartment will be parameterized as QPn / VC where VC is the volume of the central compartment. The rate of flow from the peripheral to the central compartment will be parameterized as QPn / VPn where VPn is the volumne of the added peripheral compartment.
If name is set, the peripheral compartment will be added to the compartment with the specified name instead.
Initial estimates:
== =================================================== n == =================================================== 1 (equation could not be rendered, see API doc on website) 2 (equation could not be rendered, see API doc on website) == ===================================================
add_peripheral_compartment(model, name = NULL)
add_peripheral_compartment(model, name = NULL)
model |
(Model) Pharmpy model |
name |
(str) Name of compartment to add peripheral to. |
(Model) Pharmpy model object
set_peripheral_compartment
remove_peripheral_compartment
## Not run: model <- load_example_model("pheno") model <- add_peripheral_compartment(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_peripheral_compartment(model) model$statements$ode_system ## End(Not run)
Adds IIVs to all PK parameters in :class:pharmpy.model
.
Will add exponential IIVs to all parameters that are included in the ODE.
add_pk_iiv(model, initial_estimate = 0.09)
add_pk_iiv(model, initial_estimate = 0.09)
model |
(Model) Pharmpy model to add new IIVs to. |
initial_estimate |
(numeric) Value of initial estimate of parameter. Default is 0.09 |
(Model) Pharmpy model object
add_iiv
add_iov
remove_iiv
remove_iov
## Not run: model <- load_example_model("pheno") model <- set_first_order_absorption(model) model$statements$find_assignment("MAT") model <- add_pk_iiv(model) model$statements$find_assignment("MAT") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_first_order_absorption(model) model$statements$find_assignment("MAT") model <- add_pk_iiv(model) model$statements$find_assignment("MAT") ## End(Not run)
Add a new population parameter to the model
add_population_parameter( model, name, init, lower = NULL, upper = NULL, fix = FALSE )
add_population_parameter( model, name, init, lower = NULL, upper = NULL, fix = FALSE )
model |
(Model) Pharmpy model |
name |
(str) Name of the new parameter |
init |
(numeric) Initial estimate of the new parameter |
lower |
(numeric (optional)) Lower bound of the new parameter |
upper |
(numeric (optional)) Upper bound of the new parameter |
fix |
(logical) Should the new parameter be fixed? |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_population_parameter(model, 'POP_KA', 2) model$parameters ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_population_parameter(model, 'POP_KA', 2) model$parameters ## End(Not run)
Add predictions and/or residuals
Add predictions to estimation step.
add_predictions(model, pred)
add_predictions(model, pred)
model |
(Model) Pharmpy model |
pred |
(array(str)) List of predictions (e.g. c('IPRED', 'PRED')) |
(Model) Pharmpy model object
remove_predictions
remove_residuals
set_estimation_step
add_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
## Not run: model <- load_example_model("pheno") model$execution_steps[-1].predictions model <- add_predictions(model, c('IPRED')) model$execution_steps[-1].predictions ## End(Not run)
## Not run: model <- load_example_model("pheno") model$execution_steps[-1].predictions model <- add_predictions(model, c('IPRED')) model$execution_steps[-1].predictions ## End(Not run)
Add predictions and/or residuals
Add residuals to estimation step.
Added redidual variable(s) need to be one of the following : c('RES', 'IRES', 'WRES', 'IWRES', 'CWRES')
add_residuals(model, res)
add_residuals(model, res)
model |
(Model) Pharmpy model |
res |
(array(str)) List of residuals (e.g. c('CWRES')) |
(Model) Pharmpy model object
remove_predictions
remove_residuals
set_estimation_step
add_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
## Not run: model <- load_example_model("pheno") model$execution_steps[-1].residuals model <- add_residuals(model, c('WRES')) model$execution_steps[-1].residuals ## End(Not run)
## Not run: model <- load_example_model("pheno") model$execution_steps[-1].residuals model <- add_residuals(model, c('WRES')) model$execution_steps[-1].residuals ## End(Not run)
Calculate and add a TAD column to the dataset
add_time_after_dose(model)
add_time_after_dose(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- add_time_after_dose(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_time_after_dose(model) ## End(Not run)
Append estimation step options
Appends options to an existing estimation step.
append_estimation_step_options(model, tool_options, idx)
append_estimation_step_options(model, tool_options, idx)
model |
(Model) Pharmpy model |
tool_options |
(list(str=any)) any additional tool specific options |
idx |
(numeric) index of estimation step (starting from 0) |
(Model) Pharmpy model object
add_estimation_step
set_estimation_step
remove_estimation_step
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
set_evaluation_step
## Not run: model <- load_example_model("pheno") opts <- list('NITER'=1000, 'ISAMPLE'=100) model <- append_estimation_step_options(model, tool_options=opts, idx=0) est <- model$execution_steps[1] length(est$tool_options) ## End(Not run)
## Not run: model <- load_example_model("pheno") opts <- list('NITER'=1000, 'ISAMPLE'=100) model <- append_estimation_step_options(model, tool_options=opts, idx=0) est <- model$execution_steps[1] length(est$tool_options) ## End(Not run)
Bin all observations on the independent variable
Available binning methods:
+—————+————————————————-+ | Method | Description | +===============+=================================================+ | equal_width | Bins with equal width based on the idv | +—————+————————————————-+ | equal_number | Bins containing an equal number of observations | +—————+————————————————-+
bin_observations(model, method, nbins)
bin_observations(model, method, nbins)
model |
(Model) Pharmpy model |
method |
(str) Name of the binning method to use |
nbins |
(numeric) The number of bins wanted |
(data.frame) A series of bin ids indexed on the original record index of the dataset vector A vector of bin edges
## Not run: model <- load_example_model("pheno") bins, boundaries <- bin_observations(model, method="equal_width", nbins=10) bins boundaries ## End(Not run)
## Not run: model <- load_example_model("pheno") bins, boundaries <- bin_observations(model, method="equal_width", nbins=10) bins boundaries ## End(Not run)
If the model name ends in a number increase it
If path is set increase the number until no file exists with the same name in path. If model name does not end in a number do nothing.
bump_model_number(model, path = NULL)
bump_model_number(model, path = NULL)
model |
(Model) Pharmpy model object |
path |
(str (optional)) Default is to not look for files. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- model$replace(name="run2") model <- bump_model_number(model) model$name ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- model$replace(name="run2") model <- bump_model_number(model) model$name ## End(Not run)
Calculate AIC
AIC = -2LL + 2*n_estimated_parameters
calculate_aic(model, likelihood)
calculate_aic(model, likelihood)
model |
(Model) Pharmpy model object |
likelihood |
(numeric) -2LL |
(numeric) AIC of model fit
Calculate BIC
Different variations of the BIC can be calculated:
| mixed (default) | BIC = -2LL + n_random_parameters * log(n_individuals) + | n_fixed_parameters * log(n_observations)
| fixed | BIC = -2LL + n_estimated_parameters * log(n_observations)
| random | BIC = -2LL + n_estimated_parameters * log(n_individuals)
| iiv | BIC = -2LL + n_estimated_iiv_omega_parameters * log(n_individuals)
calculate_bic(model, likelihood, type = "mixed")
calculate_bic(model, likelihood, type = "mixed")
model |
(Model) Pharmpy model object |
likelihood |
(numeric) -2LL to use |
type |
(str) Type of BIC to calculate. Default is the mixed effects. |
(numeric) BIC of model fit
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") ofv <- results$ofv calculate_bic(model, ofv) calculate_bic(model, ofv, type='fixed') calculate_bic(model, ofv, type='random') calculate_bic(model, ofv, type='iiv') ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") ofv <- results$ofv calculate_bic(model, ofv) calculate_bic(model, ofv, type='fixed') calculate_bic(model, ofv, type='random') calculate_bic(model, ofv, type='iiv') ## End(Not run)
Calculate correlation matrix from a covariance matrix
calculate_corr_from_cov(cov)
calculate_corr_from_cov(cov)
cov |
(data.frame) Covariance matrix |
(data.frame) Correlation matrix
calculate_se_from_cov : Standard errors from covariance matrix
calculate_se_from_prec : Standard errors from precision matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") cov <- results$covariance_matrix cov calculate_corr_from_cov(cov) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") cov <- results$covariance_matrix cov calculate_corr_from_cov(cov) ## End(Not run)
Calculate correlation matrix from a precision matrix
calculate_corr_from_prec(precision_matrix)
calculate_corr_from_prec(precision_matrix)
precision_matrix |
(data.frame) Precision matrix |
(data.frame) Correlation matrix
calculate_se_from_cov : Standard errors from covariance matrix
calculate_se_from_prec : Standard errors from precision matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
## Not run: results <- load_example_modelfit_results("pheno") prec <- results$precision_matrix prec calculate_corr_from_prec(prec) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") prec <- results$precision_matrix prec calculate_corr_from_prec(prec) ## End(Not run)
Calculate covariance matrix from a correlation matrix and standard errors
calculate_cov_from_corrse(corr, se)
calculate_cov_from_corrse(corr, se)
corr |
(data.frame) Correlation matrix |
se |
(array) Standard errors |
(data.frame) Covariance matrix
calculate_se_from_cov : Standard errors from covariance matrix
calculate_se_from_prec : Standard errors from precision matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") corr <- results$correlation_matrix se <- results$standard_errors corr calculate_cov_from_corrse(corr, se) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") corr <- results$correlation_matrix se <- results$standard_errors corr calculate_cov_from_corrse(corr, se) ## End(Not run)
Calculate covariance matrix from a precision matrix
calculate_cov_from_prec(precision_matrix)
calculate_cov_from_prec(precision_matrix)
precision_matrix |
(data.frame) Precision matrix |
(data.frame) Covariance matrix
calculate_se_from_cov : Standard errors from covariance matrix
calculate_se_from_prec : Standard errors from precision matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") prec <- results$precision_matrix prec calculate_cov_from_prec(prec) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") prec <- results$precision_matrix prec calculate_cov_from_prec(prec) ## End(Not run)
Calculate the symbolic expression for the epsilon gradient
This function currently only support models without ODE systems
calculate_epsilon_gradient_expression(model)
calculate_epsilon_gradient_expression(model)
model |
(Model) Pharmpy model object |
(Expression) Symbolic expression
calculate_eta_gradient_expression : Eta gradient
## Not run: model <- load_example_model("pheno_linear") calculate_epsilon_gradient_expression(model) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") calculate_epsilon_gradient_expression(model) ## End(Not run)
Calculate the symbolic expression for the eta gradient
This function currently only support models without ODE systems
calculate_eta_gradient_expression(model)
calculate_eta_gradient_expression(model)
model |
(Model) Pharmpy model object |
(Expression) Symbolic expression
calculate_epsilon_gradient_expression : Epsilon gradient
## Not run: model <- load_example_model("pheno_linear") calculate_eta_gradient_expression(model) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") calculate_eta_gradient_expression(model) ## End(Not run)
Calculate eta shrinkage for each eta
calculate_eta_shrinkage( model, parameter_estimates, individual_estimates, sd = FALSE )
calculate_eta_shrinkage( model, parameter_estimates, individual_estimates, sd = FALSE )
model |
(Model) Pharmpy model |
parameter_estimates |
(array) Parameter estimates |
individual_estimates |
(data.frame) Table of individual (eta) estimates |
sd |
(logical) Calculate shrinkage on the standard deviation scale (default is to calculate on the variance scale) |
(Series) Shrinkage for each eta
calculate_individual_shrinkage
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") pe <- results$parameter_estimates ie <- results$individual_estimates calculate_eta_shrinkage(model, pe, ie) calculate_eta_shrinkage(model, pe, ie, sd=TRUE) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") pe <- results$parameter_estimates ie <- results$individual_estimates calculate_eta_shrinkage(model, pe, ie) calculate_eta_shrinkage(model, pe, ie, sd=TRUE) ## End(Not run)
Calculate statistics for individual parameters
Calculate the mean (expected value of the distribution), variance (variance of the distribution) and standard error for individual parameters described by arbitrary expressions. Any dataset column or variable used in the model can be used in the expression. The exception being that variables that depends on the solution of the ODE system cannot be used. If covariates are used in the expression the statistics of the parameter is calculated at the median value of each covariate as well as at the 5:th and 95:th percentiles. If no parameter uncertainty is available for the model the standard error will not be calculated.
calculate_individual_parameter_statistics( model, expr_or_exprs, parameter_estimates, covariance_matrix = NULL, seed = NULL )
calculate_individual_parameter_statistics( model, expr_or_exprs, parameter_estimates, covariance_matrix = NULL, seed = NULL )
model |
(Model) A previously estimated model |
expr_or_exprs |
(array(BooleanExpr) or array(Expr) or array(str) or BooleanExpr or Expr or str) Parameter estimates |
parameter_estimates |
(array) Parameter uncertainty covariance matrix |
covariance_matrix |
(data.frame (optional)) expression or iterable of str or expressions Expressions or equations for parameters of interest. If equations are used the names of the left hand sides will be used as the names of the parameters. |
seed |
(numeric (optional)) Random number generator or integer seed |
(data.frame) A DataFrame of statistics indexed on parameter and covariate value.
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) pe <- results$parameter_estimates cov <- results$covariance_matrix calculate_individual_parameter_statistics(model, "K=CL/V", pe, cov, seed=rng) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) pe <- results$parameter_estimates cov <- results$covariance_matrix calculate_individual_parameter_statistics(model, "K=CL/V", pe, cov, seed=rng) ## End(Not run)
Calculate the individual eta-shrinkage
Definition: ieta_shr = (var(eta) / omega)
calculate_individual_shrinkage( model, parameter_estimates, individual_estimates_covariance )
calculate_individual_shrinkage( model, parameter_estimates, individual_estimates_covariance )
model |
(Model) Pharmpy model |
parameter_estimates |
(array) Parameter estimates of model |
individual_estimates_covariance |
(data.frame) Uncertainty covariance matrices of individual estimates |
(DataFrame) Shrinkage for each eta and individual
calculate_eta_shrinkage
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") pe <- results$parameter_estimates covs <- results$individual_estimates_covariance calculate_individual_shrinkage(model, pe, covs) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") pe <- results$parameter_estimates covs <- results$individual_estimates_covariance calculate_individual_shrinkage(model, pe, covs) ## End(Not run)
Scale parameter values from ucp to normal scale
calculate_parameters_from_ucp(model, scale, ucps)
calculate_parameters_from_ucp(model, scale, ucps)
model |
(Model) Pharmpy model |
scale |
(UCPScale) A parameter scale |
ucps |
(array or list(str=numeric)) Series of parameter values |
(data.frame) Parameters on the normal scale
calculate_ucp_scale : Calculate the scale for conversion from ucps
## Not run: model <- load_example_model("pheno") scale <- calculate_ucp_scale(model) values <- {'POP_CL': 0.1, 'POP_VC': 0.1, 'COVAPGR': 0.1, 'IIV_CL': 0.1, 'IIV_VC': 0.1, 'SIGMA': 0.1} calculate_parameters_from_ucp(model, scale, values) ## End(Not run)
## Not run: model <- load_example_model("pheno") scale <- calculate_ucp_scale(model) values <- {'POP_CL': 0.1, 'POP_VC': 0.1, 'COVAPGR': 0.1, 'IIV_CL': 0.1, 'IIV_VC': 0.1, 'SIGMA': 0.1} calculate_parameters_from_ucp(model, scale, values) ## End(Not run)
Calculate statistics for common pharmacokinetic parameters
Calculate the mean (expected value of the distribution), variance (variance of the distribution) and standard error for some individual pre-defined pharmacokinetic parameters.
calculate_pk_parameters_statistics( model, parameter_estimates, covariance_matrix = NULL, seed = NULL )
calculate_pk_parameters_statistics( model, parameter_estimates, covariance_matrix = NULL, seed = NULL )
model |
(Model) A previously estimated model |
parameter_estimates |
(array) Parameter estimates |
covariance_matrix |
(data.frame (optional)) Parameter uncertainty covariance matrix |
seed |
(numeric (optional)) Random number generator or seed |
(data.frame) A DataFrame of statistics indexed on parameter and covariate value.
calculate_individual_parameter_statistics : Calculation of statistics for arbitrary parameters
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) pe <- results$parameter_estimates cov <- results$covariance_matrix calculate_pk_parameters_statistics(model, pe, cov, seed=rng) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) pe <- results$parameter_estimates cov <- results$covariance_matrix calculate_pk_parameters_statistics(model, pe, cov, seed=rng) ## End(Not run)
Calculate precision matrix from a correlation matrix and standard errors
calculate_prec_from_corrse(corr, se)
calculate_prec_from_corrse(corr, se)
corr |
(data.frame) Correlation matrix |
se |
(array) Standard errors |
(data.frame) Precision matrix
calculate_se_from_cov : Standard errors from covariance matrix
calculate_se_from_prec : Standard errors from precision matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") corr <- results$correlation_matrix se <- results$standard_errors corr calculate_prec_from_corrse(corr, se) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") corr <- results$correlation_matrix se <- results$standard_errors corr calculate_prec_from_corrse(corr, se) ## End(Not run)
Calculate precision matrix from a covariance matrix
calculate_prec_from_cov(cov)
calculate_prec_from_cov(cov)
cov |
(data.frame) Covariance matrix |
(data.frame) Precision matrix
calculate_se_from_cov : Standard errors from covariance matrix
calculate_se_from_prec : Standard errors from precision matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") cov <- results$covariance_matrix cov calculate_prec_from_cov(cov) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") cov <- results$covariance_matrix cov calculate_prec_from_cov(cov) ## End(Not run)
Calculate standard errors from a covariance matrix
calculate_se_from_cov(cov)
calculate_se_from_cov(cov)
cov |
(data.frame) Input covariance matrix |
(data.frame) Standard errors
calculate_se_from_prec : Standard errors from precision matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") cov <- results$covariance_matrix cov calculate_se_from_cov(cov) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") cov <- results$covariance_matrix cov calculate_se_from_cov(cov) ## End(Not run)
Calculate standard errors from a precision matrix
calculate_se_from_prec(precision_matrix)
calculate_se_from_prec(precision_matrix)
precision_matrix |
(data.frame) Input precision matrix |
(data.frame) Standard errors
calculate_se_from_cov : Standard errors from covariance matrix
calculate_corr_from_cov : Correlation matrix from covariance matrix
calculate_cov_from_prec : Covariance matrix from precision matrix
calculate_cov_from_corrse : Covariance matrix from correlation matrix and standard errors
calculate_prec_from_cov : Precision matrix from covariance matrix
calculate_prec_from_corrse : Precision matrix from correlation matrix and standard errors
calculate_corr_from_prec : Correlation matrix from precision matrix
## Not run: results <- load_example_modelfit_results("pheno") prec <- results$precision_matrix prec calculate_se_from_prec(prec) ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") prec <- results$precision_matrix prec calculate_se_from_prec(prec) ## End(Not run)
Calculate a scale for unconstrained parameters for a model
The UCPScale object can be used to calculate unconstrained parameters back into the normal parameter space.
calculate_ucp_scale(model)
calculate_ucp_scale(model)
model |
(Model) Model for which to calculate an ucp scale |
(UCPScale) A scale object
calculate_parameters_from_ucp : Calculate parameters from ucp:s
## Not run: model <- load_example_model("pheno") scale <- calculate_ucp_scale(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") scale <- calculate_ucp_scale(model) ## End(Not run)
Check dataset for consistency across a set of rules
check_dataset(model, dataframe = FALSE, verbose = FALSE)
check_dataset(model, dataframe = FALSE, verbose = FALSE)
model |
(Model) Pharmpy model object |
dataframe |
(logical) TRUE to return a DataFrame instead of printing to the console |
verbose |
(logical) Print out all rules checked if TRUE else print only failed rules |
(data.frame) Only returns a DataFrame is dataframe=TRUE
Check for highly correlated parameter estimates
check_high_correlations(model, cor, limit = 0.9)
check_high_correlations(model, cor, limit = 0.9)
model |
(Model) Pharmpy model object |
cor |
(data.frame) Estimated correlation matrix |
limit |
(numeric) Lower limit for a high correlation |
(data.frame) Correlation values indexed on pairs of parameters for (absolute) correlations above limit
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") cor <- results$correlation_matrix check_high_correlations(model, cor, limit=0.3) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") cor <- results$correlation_matrix check_high_correlations(model, cor, limit=0.3) ## End(Not run)
Check if any estimated parameter value is close to its bounds
check_parameters_near_bounds( model, values, zero_limit = 0.001, significant_digits = 2 )
check_parameters_near_bounds( model, values, zero_limit = 0.001, significant_digits = 2 )
model |
(Model) Pharmpy model object |
values |
(array) Series of values with index a subset of parameter names. |
zero_limit |
(numeric) maximum distance to 0 bounds |
significant_digits |
(numeric) maximum distance to non-zero bounds in number of significant digits |
(data.frame) Logical Series with same index as values
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") check_parameters_near_bounds(model, results$parameter_estimates) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") check_parameters_near_bounds(model, results$parameter_estimates) ## End(Not run)
Checks whether Pharmpy and pharmr has the same version
check_pharmpy(pharmpy_version)
check_pharmpy(pharmpy_version)
pharmpy_version |
(str) version number as string |
Perform various cleanups of a model
This is what is currently done
Make model statements declarative, i.e. only one assignment per symbol
Inline all assignments of one symbol, e.g. X = Y
Remove all random variables with no variability (i.e. with omegas fixed to zero)
Put fixed thetas directly in the model statements
cleanup_model(model)
cleanup_model(model)
model |
(Model) Pharmpy model object |
(Model) Updated model
When creating NONMEM code from the cleaned model Pharmpy might need toadd certain assignments to make it in line with what NONMEM requires.
## Not run: model <- load_example_model("pheno") model$statements model <- cleanup_model(model) model$statements ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements model <- cleanup_model(model) model$statements ## End(Not run)
Convert model to other format
Note that the operation is not done inplace.
convert_model(model, to_format)
convert_model(model, to_format)
model |
(Model) Model to convert |
to_format |
(str) Name of format to convert into. Currently supported 'generic', 'nlmixr', 'nonmem', and 'rxode' |
(Model) New model object with new underlying model format
## Not run: model <- load_example_model("pheno") converted_model <- convert_model(model, "nlmixr") ## End(Not run)
## Not run: model <- load_example_model("pheno") converted_model <- convert_model(model, "nlmixr") ## End(Not run)
Creates a basic pk model of given type. The model will be a one compartment model, with first order elimination and in the case of oral administration first order absorption with no absorption delay. The elimination rate will be (equation could not be rendered, see API doc on website)
create_basic_pk_model( administration = "iv", dataset_path = NULL, cl_init = 0.01, vc_init = 1, mat_init = 0.1 )
create_basic_pk_model( administration = "iv", dataset_path = NULL, cl_init = 0.01, vc_init = 1, mat_init = 0.1 )
administration |
(str) Type of PK model to create. Supported are 'iv', 'oral' and 'ivoral' |
dataset_path |
(str (optional)) Optional path to a dataset |
cl_init |
(numeric) Initial estimate of the clearance parameter |
vc_init |
(numeric) Initial estimate of the central volume parameter |
mat_init |
(numeric) Initial estimate of the mean absorption time parameter (if applicable) |
(Model) Pharmpy model object
## Not run: model <- create_basic_pk_model('oral') ## End(Not run)
## Not run: model <- create_basic_pk_model('oral') ## End(Not run)
Create a basic config file template
If a configuration file already exists it will not be overwritten
create_config_template()
create_config_template()
## Not run: create_config_template() ## End(Not run)
## Not run: create_config_template() ## End(Not run)
Combines some or all etas into a joint distribution.
The etas must be IIVs and cannot be fixed. Initial estimates for covariance between the etas is dependent on whether the model has results from a previous run. In that case, the correlation will be calculated from individual estimates, otherwise correlation will be set to 10%.
create_joint_distribution(model, rvs = NULL, individual_estimates = NULL)
create_joint_distribution(model, rvs = NULL, individual_estimates = NULL)
model |
(Model) Pharmpy model |
rvs |
(array(str) (optional)) Sequence of etas or names of etas to combine. If NULL, all etas that are IIVs and non-fixed will be used (full block). NULL is default. |
individual_estimates |
(data.frame (optional)) Optional individual estimates to use for calculation of initial estimates |
(Model) Pharmpy model object
split_joint_distribution : split etas into separate distributions
## Not run: model <- load_example_model("pheno") model$random_variables$etas model <- create_joint_distribution(model, c('ETA_CL', 'ETA_VC')) model$random_variables$etas ## End(Not run)
## Not run: model <- load_example_model("pheno") model$random_variables$etas model <- create_joint_distribution(model, c('ETA_CL', 'ETA_VC')) model$random_variables$etas ## End(Not run)
Create standard report for results
The report will be an html created at specified path.
create_report(results, path)
create_report(results, path)
results |
(Results) Results for which to create report |
path |
(str) Path to report file |
Create a new random number generator
Pharmpy functions that use random sampling take a random number generator or seed as input. This function can be used to create a default new random number generator.
create_rng(seed = NULL)
create_rng(seed = NULL)
seed |
(numeric (optional)) Seed for the random number generator or NULL (default) for a randomized seed. If seed is generator it will be passed through. |
(Generator) Initialized numpy random number generator object
## Not run: rng <- create_rng(23) rng$standard_normal() ## End(Not run)
## Not run: rng <- create_rng(23) rng$standard_normal() ## End(Not run)
Create a new unique variable symbol given a model
create_symbol(model, stem, force_numbering = FALSE)
create_symbol(model, stem, force_numbering = FALSE)
model |
(Model) Pharmpy model object |
stem |
(str) First part of the new variable name |
force_numbering |
(logical) Forces addition of number to name even if variable does not exist, e.g. COVEFF → COVEFF1 |
(Symbol) Created symbol with unique name
## Not run: model <- load_example_model("pheno") create_symbol(model, "TEMP") create_symbol(model, "TEMP", force_numbering=TRUE) create_symbol(model, "CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") create_symbol(model, "TEMP") create_symbol(model, "TEMP", force_numbering=TRUE) create_symbol(model, "CL") ## End(Not run)
Deidentify a dataset
Two operations are performed on the dataset:
All ID numbers are randomized from the range 1 to n
All columns containing dates will have the year changed
The year change is done by letting the earliest year in the dataset be used as a reference and by maintaining leap years. The reference year will either be 1901, 1902, 1903 or 1904 depending on its distance to the closest preceeding leap year.
deidentify_data(df, id_column = "ID", date_columns = NULL)
deidentify_data(df, id_column = "ID", date_columns = NULL)
df |
(data.frame) A dataset |
id_column |
(str) Name of the id column |
date_columns |
(array(str) (optional)) Names of all date columns |
(data.frame) Deidentified dataset
Displays the ordinary differential equation system
display_odes(model)
display_odes(model)
model |
(Model) Pharmpy model |
(ODEDisplayer) A displayable object
## Not run: model <- load_example_model("pheno") display_odes(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") display_odes(model) ## End(Not run)
Drop columns from the dataset or mark as dropped
drop_columns(model, column_names, mark = FALSE)
drop_columns(model, column_names, mark = FALSE)
model |
(Model) Pharmpy model object |
column_names |
(array(str) or str) List of column names or one column name to drop or mark as dropped |
mark |
(logical) Default is to remove column from dataset. Set this to TRUE to only mark as dropped |
(Model) Pharmpy model object
drop_dropped_columns : Drop all columns marked as drop
undrop_columns : Undrop columns of model
## Not run: model <- load_example_model("pheno") model <- drop_columns(model, c('WGT', 'APGR')) vector(model$dataset$columns) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- drop_columns(model, c('WGT', 'APGR')) vector(model$dataset$columns) ## End(Not run)
Drop columns marked as dropped from the dataset
NM-TRAN date columns will not be dropped by this function even if marked as dropped. Columns not specified in the datainfo ($INPUT for NONMEM) will also be dropped from the dataset.
drop_dropped_columns(model)
drop_dropped_columns(model)
model |
(Model) Pharmpy model object |
(Model) Pharmpy model object
drop_columns : Drop specific columns or mark them as drop
## Not run: model <- load_example_model("pheno") model <- drop_dropped_columns(model) vector(model$dataset$columns) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- drop_dropped_columns(model) vector(model$dataset$columns) ## End(Not run)
Evaluate the numeric epsilon gradient
The gradient is evaluated at the current model parameter values or optionally at the given parameter values. The gradient is done for each data record in the model dataset or optionally using the dataset argument. The gradient is done at the current eta values or optionally at the given eta values.
This function currently only support models without ODE systems
evaluate_epsilon_gradient( model, etas = NULL, parameters = NULL, dataset = NULL )
evaluate_epsilon_gradient( model, etas = NULL, parameters = NULL, dataset = NULL )
model |
(Model) Pharmpy model |
etas |
(data.frame (optional)) Optional list of eta values |
parameters |
(list(str=numeric) (optional)) Optional list of parameters and values |
dataset |
(data.frame (optional)) Optional dataset |
(data.frame) Gradient
evaluate_eta_gradient : Evaluate the eta gradient
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") etas <- results$individual_estimates evaluate_epsilon_gradient(model, etas=etas) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") etas <- results$individual_estimates evaluate_epsilon_gradient(model, etas=etas) ## End(Not run)
Evaluate the numeric eta gradient
The gradient is evaluated at the current model parameter values or optionally at the given parameter values. The gradient is done for each data record in the model dataset or optionally using the dataset argument. The gradient is done at the current eta values or optionally at the given eta values.
This function currently only support models without ODE systems
evaluate_eta_gradient(model, etas = NULL, parameters = NULL, dataset = NULL)
evaluate_eta_gradient(model, etas = NULL, parameters = NULL, dataset = NULL)
model |
(Model) Pharmpy model |
etas |
(data.frame (optional)) Optional list of eta values |
parameters |
(list(str=numeric) (optional)) Optional list of parameters and values |
dataset |
(data.frame (optional)) Optional dataset |
(data.frame) Gradient
evaluate_epsilon_gradient : Evaluate the epsilon gradient
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") etas <- results$individual_estimates evaluate_eta_gradient(model, etas=etas) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") etas <- results$individual_estimates evaluate_eta_gradient(model, etas=etas) ## End(Not run)
Evaluate expression using model
Calculate the value of expression for each data record. The expression can contain dataset columns, variables in model and population parameters. If the model has parameter estimates these will be used. Initial estimates will be used for non-estimated parameters.
evaluate_expression(model, expression, parameter_estimates = NULL)
evaluate_expression(model, expression, parameter_estimates = NULL)
model |
(Model) Pharmpy model |
expression |
(str or numeric or Expr) Expression to evaluate |
parameter_estimates |
(list(str=numeric) (optional)) Parameter estimates to use instead of initial estimates |
(data.frame) A series of one evaluated value for each data record
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") pe <- results$parameter_estimates evaluate_expression(model, "TVCL*1000", parameter_estimates=pe) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") pe <- results$parameter_estimates evaluate_expression(model, "TVCL*1000", parameter_estimates=pe) ## End(Not run)
Evaluate the numeric individual prediction
The prediction is evaluated at the current model parameter values or optionally at the given parameter values. The evaluation is done for each data record in the model dataset or optionally using the dataset argument. The evaluation is done at the current eta values or optionally at the given eta values.
This function currently only support models without ODE systems
evaluate_individual_prediction( model, etas = NULL, parameters = NULL, dataset = NULL )
evaluate_individual_prediction( model, etas = NULL, parameters = NULL, dataset = NULL )
model |
(Model) Pharmpy model |
etas |
(data.frame (optional)) Optional list of eta values |
parameters |
(list(str=numeric) (optional)) Optional list of parameters and values |
dataset |
(data.frame (optional)) Optional dataset |
(data.frame) Individual predictions
evaluate_population_prediction : Evaluate the population prediction
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") etas <- results$individual_estimates evaluate_individual_prediction(model, etas=etas) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") etas <- results$individual_estimates evaluate_individual_prediction(model, etas=etas) ## End(Not run)
Evaluate the numeric population prediction
The prediction is evaluated at the current model parameter values or optionally at the given parameter values. The evaluation is done for each data record in the model dataset or optionally using the dataset argument.
This function currently only support models without ODE systems
evaluate_population_prediction(model, parameters = NULL, dataset = NULL)
evaluate_population_prediction(model, parameters = NULL, dataset = NULL)
model |
(Model) Pharmpy model |
parameters |
(list(str=numeric) (optional)) Optional list of parameters and values |
dataset |
(data.frame (optional)) Optional dataset |
(data.frame) Population predictions
evaluate_individual_prediction : Evaluate the individual prediction
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") pe <- results$parameter_estimates evaluate_population_prediction(model, parameters=list(pe)) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") pe <- results$parameter_estimates evaluate_population_prediction(model, parameters=list(pe)) ## End(Not run)
Evaluate the weighted residuals
The residuals is evaluated at the current model parameter values or optionally at the given parameter values. The residuals is done for each data record in the model dataset or optionally using the dataset argument.
This function currently only support models without ODE systems
evaluate_weighted_residuals(model, parameters = NULL, dataset = NULL)
evaluate_weighted_residuals(model, parameters = NULL, dataset = NULL)
model |
(Model) Pharmpy model |
parameters |
(list(str=numeric) (optional)) Optional list of parameters and values |
dataset |
(data.frame (optional)) Optional dataset |
(data.frame) WRES
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") parameters <- results$parameter_estimates evaluate_weighted_residuals(model, parameters=list(parameters)) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") results <- load_example_modelfit_results("pheno_linear") parameters <- results$parameter_estimates evaluate_weighted_residuals(model, parameters=list(parameters)) ## End(Not run)
Expand additional doses into separate dose records
expand_additional_doses(model, flag = FALSE)
expand_additional_doses(model, flag = FALSE)
model |
(Model) Pharmpy model object |
flag |
(logical) TRUE to add a boolean EXPANDED column to mark added records. In this case all columns in the original dataset will be kept. Care needs to be taken to handle the new dataset. |
(Model) Pharmpy model object
Filter dataset according to expr and return a model with the filtered dataset.
Example: "DVID == 1" will filter the dataset so that only the rows with DVID = 1 remain.
filter_dataset(model, expr)
filter_dataset(model, expr)
model |
(Model) Pharmpy model object |
expr |
(str) expression for dataset query |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$dataset model <- filter_dataset(model, 'WGT < 1.4') model$dataset ## End(Not run)
## Not run: model <- load_example_model("pheno") model$dataset model <- filter_dataset(model, 'WGT < 1.4') model$dataset ## End(Not run)
Find clearance parameters in model
find_clearance_parameters(model)
find_clearance_parameters(model)
model |
(Model) Pharmpy model |
(vector) A vector of clearance parameters
## Not run: model <- load_example_model("pheno") find_clearance_parameters(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") find_clearance_parameters(model) ## End(Not run)
Find volume parameters in model
find_volume_parameters(model)
find_volume_parameters(model)
model |
(Model) Pharmpy model |
(vector) A vector of volume parameters
## Not run: model <- load_example_model("pheno") find_volume_parameters(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") find_volume_parameters(model) ## End(Not run)
Fit models.
fit(model_or_models, esttool = NULL, path = NULL, context = NULL)
fit(model_or_models, esttool = NULL, path = NULL, context = NULL)
model_or_models |
(Model or array(Model)) List of models or one single model |
esttool |
(str (optional)) Estimation tool to use. NULL to use default |
path |
(str (optional)) Path to fit directory |
context |
(Context (optional)) Run in this context |
(ModelfitResults | vector of ModelfitResults) ModelfitResults for the model or models
run_tool
## Not run: model <- load_example_model("pheno") results <- fit(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- fit(model) ## End(Not run)
Fix or unfix parameters
Set fixedness of parameters to specified values
fix_or_unfix_parameters(model, parameters, strict = TRUE)
fix_or_unfix_parameters(model, parameters, strict = TRUE)
model |
(Model) Pharmpy model |
parameters |
(list(str=logical)) Set fix/unfix for these parameters |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
fix_parameters : Fix parameters
unfix_paramaters : Unfixing parameters
fix_paramaters_to : Fixing parameters and setting a new initial estimate in the same
function
unfix_paramaters_to : Unfixing parameters and setting a new initial estimate in the same
function
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- fix_or_unfix_parameters(model, list('POP_CL'=TRUE)) model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- fix_or_unfix_parameters(model, list('POP_CL'=TRUE)) model$parameters['POP_CL'] ## End(Not run)
Fix parameters
Fix all listed parameters
fix_parameters(model, parameter_names, strict = TRUE)
fix_parameters(model, parameter_names, strict = TRUE)
model |
(Model) Pharmpy model |
parameter_names |
(array(str) or str) one parameter name or a vector of parameter names |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
fix_or_unfix_parameters : Fix or unfix parameters (given boolean)
fix_parameters_to : Fixing and setting parameter initial estimates in the same function
unfix_paramaters : Unfixing parameters
unfix_paramaters_to : Unfixing parameters and setting a new initial estimate in the same
function
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- fix_parameters(model, 'POP_CL') model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- fix_parameters(model, 'POP_CL') model$parameters['POP_CL'] ## End(Not run)
Fix parameters to
Fix all listed parameters to specified value/values
fix_parameters_to(model, inits, strict = TRUE)
fix_parameters_to(model, inits, strict = TRUE)
model |
(Model) Pharmpy model |
inits |
(list(str=numeric)) Inits for all parameters to fix and set init |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
fix_parameters : Fix parameters
fix_or_unfix_parameters : Fix or unfix parameters (given boolean)
unfix_paramaters : Unfixing parameters
unfix_paramaters_to : Unfixing parameters and setting a new initial estimate in the same
function
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- fix_parameters_to(model, {'POP_CL': 0.5}) model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- fix_parameters_to(model, {'POP_CL': 0.5}) model$parameters['POP_CL'] ## End(Not run)
Get the admid from model dataset
If an administration column is present this will be extracted otherwise an admid column will be created based on the admids of the present doses. This is dependent on the presence of a CMT column to be generated correctly.
When generated, admids of events in between doses is set to the last used admid.
get_admid(model)
get_admid(model)
model |
(Model) Pharmpy model |
(data.frame) ADMID
Baselines for each subject.
Baseline is taken to be the first row even if that has a missing value.
get_baselines(model)
get_baselines(model)
model |
(Model) Pharmpy model |
(data.frame) Dataset with the baselines
## Not run: model <- load_example_model("pheno") get_baselines(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_baselines(model) ## End(Not run)
Get bioavailability of doses for all compartments
get_bioavailability(model)
get_bioavailability(model)
model |
(Model) Pharmpy model |
(list) Dictionary from compartment name to bioavailability expression
Get the volume and clearance parameters
get_central_volume_and_clearance(model)
get_central_volume_and_clearance(model)
model |
(Model) Pharmpy model |
(sympy.Symbol) Volume symbol sympy.Symbol Clearance symbol
## Not run: model <- load_example_model("pheno") get_central_volume_and_clearance(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_central_volume_and_clearance(model) ## End(Not run)
Get the cmt (compartment) column from the model dataset
If a cmt column is present this will be extracted otherwise a cmt column will be created. If created, multiple dose compartments are dependent on the presence of an admid type column, otherwise, dose/non-dose will be considered.
get_cmt(model)
get_cmt(model)
model |
(Model) Pharmpy model |
(data.frame) CMT
Create a dataframe with concentration parameters
Note that all values are directly calculated from the dataset
get_concentration_parameters_from_data(model)
get_concentration_parameters_from_data(model)
model |
(Model) Pharmpy model object |
(data.frame) Concentration parameters
## Not run: model <- load_example_model("pheno") get_concentration_parameters_from_data(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_concentration_parameters_from_data(model) ## End(Not run)
Returns path to the user config path
get_config_path()
get_config_path()
(str or NULL) Path to user config or NULL if file does not exist
## Not run: get_config_path() ## End(Not run)
## Not run: get_config_path() ## End(Not run)
Return a dataframe with baselines of all covariates for each id.
Baseline is taken to be the first row even if that has a missing value.
get_covariate_baselines(model)
get_covariate_baselines(model)
model |
(Model) Pharmpy model |
(data.frame) covariate baselines
get_baselines : baselines for all data columns
## Not run: model <- load_example_model("pheno") model <- set_covariates(model, c("WGT", "APGR")) get_covariate_baselines(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_covariates(model, c("WGT", "APGR")) get_covariate_baselines(model) ## End(Not run)
Return a list of all used covariates within a model
The list will have parameter name as key with a connected value as a vector of tuple(s) with (covariate, effect type, operator)
get_covariate_effects(model)
get_covariate_effects(model)
model |
(Model) Model to extract covariates from. |
(Dictionary : Dictionary of parameters and connected covariate(s))
Get a DOSEID series from the dataset with an id of each dose period starting from 1
If a a dose and observation exist at the same time point the observation will be counted towards the previous dose.
get_doseid(model)
get_doseid(model)
model |
(Model) Pharmpy model |
(data.frame) DOSEIDs
## Not run: model <- load_example_model("pheno") get_doseid(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_doseid(model) ## End(Not run)
Get a series of all doses
Indexed with ID and TIME
get_doses(model)
get_doses(model)
model |
(Model) Pharmpy model |
(data.frame) doses
## Not run: model <- load_example_model("pheno") get_doses(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_doses(model) ## End(Not run)
Get the symbol for a certain dvid or dv and check that it is valid
get_dv_symbol(model, dv = NULL)
get_dv_symbol(model, dv = NULL)
model |
(Model) Pharmpy model |
dv |
(Expr or str or numeric (optional)) Either a dv symbol, str or dvid. If NULL (default) return the only or first dv. |
(sympy.Symbol) DV symbol
## Not run: model <- load_example_model("pheno") get_dv_symbol(model, "Y") get_dv_symbol(model, 1) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_dv_symbol(model, "Y") get_dv_symbol(model, 1) ## End(Not run)
Get the evid from model dataset
If an event column is present this will be extracted otherwise an evid column will be created.
get_evid(model)
get_evid(model)
model |
(Model) Pharmpy model |
(data.frame) EVID
Retrieve a vector of all subject ids of the dataset
get_ids(model)
get_ids(model)
model |
(Model) Pharmpy model |
(vector) All subject ids
## Not run: model <- load_example_model("pheno") get_ids(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_ids(model) ## End(Not run)
Retrieves all individual parameters in a :class:pharmpy.model
.
By default all individual parameters will be found even ones having no random effect. The level arguments makes it possible to find only those having any random effect or only those having a certain random effect. Using the dv option will give all individual parameters affecting a certain dv. Note that the DV for PD in a PKPD model often also is affected by the PK parameters.
get_individual_parameters(model, level = "all", dv = NULL)
get_individual_parameters(model, level = "all", dv = NULL)
model |
(Model) Pharmpy model to retrieve the individuals parameters from |
level |
(str) The variability level to look for: 'iiv', 'iov', 'random' or 'all' (default) |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for all (default) |
(vectorc(str)) A vector of the parameter names as strings
get_pd_parameters
get_pk_parameters
get_rv_parameters
has_random_effect
## Not run: model <- load_example_model("pheno") get_individual_parameters(model) get_individual_parameters(model, 'iiv') get_individual_parameters(model, 'iov') ## End(Not run)
## Not run: model <- load_example_model("pheno") get_individual_parameters(model) get_individual_parameters(model, 'iiv') get_individual_parameters(model, 'iov') ## End(Not run)
Get the full symbolic expression for the modelled individual prediction
This function currently only support models without ODE systems
get_individual_prediction_expression(model)
get_individual_prediction_expression(model)
model |
(Model) Pharmpy model object |
(Expression) Symbolic expression
get_population_prediction_expression : Get full symbolic epression for the population prediction
## Not run: model <- load_example_model("pheno_linear") get_individual_prediction_expression(model) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") get_individual_prediction_expression(model) ## End(Not run)
Get initial conditions for the ode system
Default initial conditions at t=0 for amounts is 0
get_initial_conditions(model, dosing = FALSE)
get_initial_conditions(model, dosing = FALSE)
model |
(Model) Pharmpy model |
dosing |
(logical) Set to TRUE to add dosing as initial conditions |
(list) Initial conditions
## Not run: model <- load_example_model("pheno") get_initial_conditions(model) get_initial_conditions(model, dosing=TRUE) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_initial_conditions(model) get_initial_conditions(model, dosing=TRUE) ## End(Not run)
Get lag times for all compartments
get_lag_times(model)
get_lag_times(model)
model |
(Model) Pharmpy model |
(list) Dictionary from compartment name to lag time expression
Get MDVs from dataset
get_mdv(model)
get_mdv(model)
model |
(Model) Pharmpy model |
(data.frame) MDVs
Get the model code of the underlying model language
get_model_code(model)
get_model_code(model)
model |
(Model) Pharmpy model |
(str) Model code
## Not run: model <- load_example_model("pheno") get_model_code(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_model_code(model) ## End(Not run)
List of covariates used in model
A covariate in the model is here defined to be a data item affecting the model prediction excluding dosing items that are not used in model code.
get_model_covariates(model, strings = FALSE)
get_model_covariates(model, strings = FALSE)
model |
(Model) Pharmpy model |
strings |
(logical) Return strings instead of symbols? FALSE (default) will give symbols |
(vector) Covariate symbols or names
## Not run: model <- load_example_model("pheno") get_model_covariates(model) get_model_covariates(model, strings=TRUE) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_model_covariates(model) get_model_covariates(model, strings=TRUE) ## End(Not run)
Return Mu name connected to parameter
If the given parameter is not dependent on any Mu, NULL is returned
get_mu_connected_to_parameter(model, parameter)
get_mu_connected_to_parameter(model, parameter)
model |
(Model) Pharmpy model object. |
parameter |
(str) Name of parameter which to find Mu parameter for. |
(str) Name of Mu parameter or NULL
Retrieve the number of individuals in the model dataset
get_number_of_individuals(model)
get_number_of_individuals(model)
model |
(Model) Pharmpy model |
(integer) Number of individuals in the model dataset
For NONMEM models this is the number of individuals of the active dataset, i.e. after filteringof IGNORE and ACCEPT and removal of individuals with no observations.
get_number_of_observations : Get the number of observations in a dataset
get_number_of_observations_per_individual : Get the number of observations per individual in a
dataset
## Not run: model <- load_example_model("pheno") get_number_of_individuals(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_number_of_individuals(model) ## End(Not run)
Retrieve the total number of observations in the model dataset
get_number_of_observations(model)
get_number_of_observations(model)
model |
(Model) Pharmpy model |
(integer) Number of observations in the model dataset
For NONMEM models this is the number of observations of the active dataset, i.e. after filteringof IGNORE and ACCEPT and removal of individuals with no observations.
get_number_of_individuals : Get the number of individuals in a dataset
get_number_of_observations_per_individual : Get the number of observations per individual in a
dataset
## Not run: model <- load_example_model("pheno") get_number_of_observations(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_number_of_observations(model) ## End(Not run)
Number of observations for each individual
get_number_of_observations_per_individual(model)
get_number_of_observations_per_individual(model)
model |
(Model) Pharmpy model |
(data.frame) Number of observations in the model dataset
For NONMEM models this is the individuals and number of observations of the active dataset, i.e.after filtering of IGNORE and ACCEPT and removal of individuals with no observations.
get_number_of_individuals : Get the number of individuals in a dataset
get_number_of_observations_per_individual : Get the number of observations per individual in a
dataset
## Not run: model <- load_example_model("pheno") get_number_of_observations_per_individual(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_number_of_observations_per_individual(model) ## End(Not run)
Return the number of peripherals compartments connected to the central compartment
get_number_of_peripheral_compartments(model)
get_number_of_peripheral_compartments(model)
model |
(Model) Pharmpy model |
(integer) Number of peripherals compartments
Return the number of transit compartments in the model
get_number_of_transit_compartments(model)
get_number_of_transit_compartments(model)
model |
(Model) Pharmpy model |
(integer) Number of transit compartments
Get the full symbolic expression for the observation according to the model
This function currently only support models without ODE systems
get_observation_expression(model)
get_observation_expression(model)
model |
(Model) Pharmpy model object |
(Expression) Symbolic expression
## Not run: model <- load_example_model("pheno_linear") expr <- get_observation_expression(model) print(expr$unicode()) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") expr <- get_observation_expression(model) print(expr$unicode()) ## End(Not run)
Get observations from dataset
get_observations(model, keep_index = FALSE)
get_observations(model, keep_index = FALSE)
model |
(Model) Pharmpy model |
keep_index |
(logical) Set to TRUE if the original index should be kept. Otherwise a new index using ID and idv will be created. |
(data.frame) Observations indexed over ID and TIME
get_number_of_observations : get the number of observations
get_number_of_observations_per_individual : get the number of observations per individual
## Not run: model <- load_example_model("pheno") get_observations(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_observations(model) ## End(Not run)
Get all omegas (variability parameters) of a model
get_omegas(model)
get_omegas(model)
model |
(Model) Pharmpy model object |
(Parameters) A copy of all omega parameters
get_thetas : Get theta parameters
get_sigmas : Get sigma parameters
## Not run: model <- load_example_model("pheno") get_omegas(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_omegas(model) ## End(Not run)
Retrieves name of random variable in :class:pharmpy.model.Model
given a parameter.
get_parameter_rv(model, parameter, var_type = "iiv")
get_parameter_rv(model, parameter, var_type = "iiv")
model |
(Model) Pharmpy model to retrieve parameters from |
parameter |
(str) Name of parameter to retrieve random variable from |
var_type |
(str) Variability type: iiv (default) or iov |
(vectorc(str)) A vector of random variable names for the given parameter
get_rv_parameters
has_random_effect
get_pk_parameters
get_individual_parameters
## Not run: model <- load_example_model("pheno") get_parameter_rv(model, 'CL') ## End(Not run)
## Not run: model <- load_example_model("pheno") get_parameter_rv(model, 'CL') ## End(Not run)
Retrieves PD parameters in :class:pharmpy.model.Model
.
get_pd_parameters(model)
get_pd_parameters(model)
model |
(Model) Pharmpy model to retrieve the PD parameters from |
(vectorc(str)) A vector of the PD parameter names of the given model
get_pk_parameters
## Not run: model <- load_example_model("pheno") model <- set_direct_effect(model, "linear") get_pd_parameters(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_direct_effect(model, "linear") get_pd_parameters(model) ## End(Not run)
Retrieves PK parameters in :class:pharmpy.model.Model
.
get_pk_parameters(model, kind = "all")
get_pk_parameters(model, kind = "all")
model |
(Model) Pharmpy model to retrieve the PK parameters from |
kind |
(str) The type of parameter to retrieve: 'absorption', 'distribution', 'elimination', or 'all' (default). |
(vectorc(str)) A vector of the PK parameter names of the given model
get_individual_parameters
get_rv_parameters
## Not run: model <- load_example_model("pheno") get_pk_parameters(model) get_pk_parameters(model, 'absorption') get_pk_parameters(model, 'distribution') get_pk_parameters(model, 'elimination') ## End(Not run)
## Not run: model <- load_example_model("pheno") get_pk_parameters(model) get_pk_parameters(model, 'absorption') get_pk_parameters(model, 'distribution') get_pk_parameters(model, 'elimination') ## End(Not run)
Get the full symbolic expression for the modelled population prediction
This function currently only support models without ODE systems
get_population_prediction_expression(model)
get_population_prediction_expression(model)
model |
(Model) Pharmpy model object |
(Expression) Symbolic expression
get_individual_prediction_expression : Get full symbolic epression for the individual prediction
## Not run: model <- load_example_model("pheno_linear") get_population_prediction_expression(model) ## End(Not run)
## Not run: model <- load_example_model("pheno_linear") get_population_prediction_expression(model) ## End(Not run)
Retrieves parameters in :class:pharmpy.model.Model
given a random variable.
get_rv_parameters(model, rv)
get_rv_parameters(model, rv)
model |
(Model) Pharmpy model to retrieve parameters from |
rv |
(str) Name of random variable to retrieve |
(vectorc(str)) A vector of parameter names for the given random variable
has_random_effect
get_pk_parameters
get_individual_parameters
## Not run: model <- load_example_model("pheno") get_rv_parameters(model, 'ETA_CL') ## End(Not run)
## Not run: model <- load_example_model("pheno") get_rv_parameters(model, 'ETA_CL') ## End(Not run)
Get all sigmas (residual error variability parameters) of a model
get_sigmas(model)
get_sigmas(model)
model |
(Model) Pharmpy model object |
(Parameters) A copy of all sigma parameters
get_thetas : Get theta parameters
get_omegas : Get omega parameters
## Not run: model <- load_example_model("pheno") get_sigmas(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_sigmas(model) ## End(Not run)
Get all thetas (structural parameters) of a model
get_thetas(model)
get_thetas(model)
model |
(Model) Pharmpy model object |
(Parameters) A copy of all theta parameters
get_omegas : Get omega parameters
get_sigmas : Get sigma parameters
## Not run: model <- load_example_model("pheno") get_thetas(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_thetas(model) ## End(Not run)
Derive the physical unit of a variable in the model
Unit information for the dataset needs to be available. The variable can be defined in the code, a dataset olumn, a parameter or a random variable.
get_unit_of(model, variable)
get_unit_of(model, variable)
model |
(Model) Pharmpy model object |
variable |
(str) Find physical unit of this variable |
(Unit) A unit expression
## Not run: model <- load_example_model("pheno") get_unit_of(model, "Y") get_unit_of(model, "VC") get_unit_of(model, "WGT") ## End(Not run)
## Not run: model <- load_example_model("pheno") get_unit_of(model, "Y") get_unit_of(model, "VC") get_unit_of(model, "WGT") ## End(Not run)
Get zero order inputs for all compartments
get_zero_order_inputs(model)
get_zero_order_inputs(model)
model |
(Model) Pharmpy model |
(sympy.Matrix) Vector of inputs
## Not run: model <- load_example_model("pheno") get_zero_order_inputs(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") get_zero_order_inputs(model) ## End(Not run)
Convert to using greek letters for all population parameters
greekify_model(model, named_subscripts = FALSE)
greekify_model(model, named_subscripts = FALSE)
model |
(Model) Pharmpy model |
named_subscripts |
(logical) Use previous parameter names as subscripts. Default is to use integer subscripts |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$statements model <- greekify_model(cleanup_model(model)) model$statements ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements model <- greekify_model(cleanup_model(model)) model$statements ## End(Not run)
Check if a model has an additive error model
Multiple dependent variables are supported. By default the only (in case of one) or the first (in case of many) dependent variable is going to be checked.
has_additive_error_model(model, dv = NULL)
has_additive_error_model(model, dv = NULL)
model |
(Model) The model to check |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
(logical) TRUE if the model has an additive error model and FALSE otherwise
has_proportional_error_model : Check if a model has a proportional error model
has_combined_error_model : Check if a model has a combined error model
has_weighted_error_model : Check if a model has a weighted error model
## Not run: model <- load_example_model("pheno") has_additive_error_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_additive_error_model(model) ## End(Not run)
Check if a model has a combined additive and proportional error model
Multiple dependent variables are supported. By default the only (in case of one) or the first (in case of many) dependent variable is going to be checked.
has_combined_error_model(model, dv = NULL)
has_combined_error_model(model, dv = NULL)
model |
(Model) The model to check |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
(logical) TRUE if the model has a combined error model and FALSE otherwise
has_additive_error_model : Check if a model has an additive error model
has_proportional_error_model : Check if a model has a proportional error model
has_weighted_error_model : Check if a model has a weighted error model
## Not run: model <- load_example_model("pheno") has_combined_error_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_combined_error_model(model) ## End(Not run)
Tests if an instance of :class:pharmpy.model
has a given covariate
effect.
has_covariate_effect(model, parameter, covariate)
has_covariate_effect(model, parameter, covariate)
model |
(Model) Pharmpy model to check for covariate effect. |
parameter |
(str) Name of parameter. |
covariate |
(str) Name of covariate. |
(logical) Whether input model has a covariate effect of the input covariate on the input parameter.
## Not run: model <- load_example_model("pheno") has_covariate_effect(model, "CL", "APGR") ## End(Not run)
## Not run: model <- load_example_model("pheno") has_covariate_effect(model, "CL", "APGR") ## End(Not run)
Check if ode system describes a first order absorption
Currently defined as the central compartment having a unidirectional input flow from another compartment (such as depot or transit)
has_first_order_absorption(model)
has_first_order_absorption(model)
model |
(Model) Pharmpy model |
(Bool : TRUE if model has first order absorption)
Check if the model describes first order elimination
This function relies on heuristics and will not be able to detect all possible ways of coding the first order elimination.
has_first_order_elimination(model)
has_first_order_elimination(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has describes first order elimination
## Not run: model <- load_example_model("pheno") has_first_order_elimination(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_first_order_elimination(model) ## End(Not run)
Check if ode system describes a instantaneous absorption
Defined as being a instantaneous dose directly into the central compartment
has_instantaneous_absorption(model)
has_instantaneous_absorption(model)
model |
(Model) Pharmpy model |
(Bool : TRUE if model has instantaneous absorption)
Check if model has a linear ODE system
has_linear_odes(model)
has_linear_odes(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has an ODE system that is linear
has_odes
has_linear_odes_with_real_eigenvalues
## Not run: model <- load_example_model("pheno") has_linear_odes(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_linear_odes(model) ## End(Not run)
Check if model has a linear ode system with real eigenvalues
has_linear_odes_with_real_eigenvalues(model)
has_linear_odes_with_real_eigenvalues(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has an ODE system that is linear
has_odes
has_linear_odes
## Not run: model <- load_example_model("pheno") has_linear_odes_with_real_eigenvalues(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_linear_odes_with_real_eigenvalues(model) ## End(Not run)
Check if the model describes Michaelis-Menten elimination
This function relies on heuristics and will not be able to detect all possible ways of coding the Michaelis-Menten elimination.
has_michaelis_menten_elimination(model)
has_michaelis_menten_elimination(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has describes Michaelis-Menten elimination
## Not run: model <- load_example_model("pheno") has_michaelis_menten_elimination(model) model <- set_michaelis_menten_elimination(model) has_michaelis_menten_elimination(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_michaelis_menten_elimination(model) model <- set_michaelis_menten_elimination(model) has_michaelis_menten_elimination(model) ## End(Not run)
Check if the model describes mixed Michaelis-Menten and first order elimination
This function relies on heuristics and will not be able to detect all possible ways of coding the mixed Michalis-Menten and first order elimination.
has_mixed_mm_fo_elimination(model)
has_mixed_mm_fo_elimination(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has describes Michaelis-Menten elimination
## Not run: model <- load_example_model("pheno") has_mixed_mm_fo_elimination(model) model <- set_mixed_mm_fo_elimination(model) has_mixed_mm_fo_elimination(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_mixed_mm_fo_elimination(model) model <- set_mixed_mm_fo_elimination(model) has_mixed_mm_fo_elimination(model) ## End(Not run)
Check if model is Mu-reference or not.
Will return TRUE if each parameter with an ETA is dependent on a Mu parameter.
has_mu_reference(model)
has_mu_reference(model)
model |
(Model) Pharmpy model object |
(logical) Whether the model is mu referenced
Check if model has an ODE system
has_odes(model)
has_odes(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has an ODE system
has_linear_odes
has_linear_odes_with_real_eigenvalues
## Not run: model <- load_example_model("pheno") has_odes(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_odes(model) ## End(Not run)
Checks whether a model has a presystemic metabolite
If pre-systemic drug there will be a flow from DEPOT to METABOLITE as well as being a flow from the CENTRAL to METABOLITE
has_presystemic_metabolite(model)
has_presystemic_metabolite(model)
model |
(Model) Pharmpy model |
(logical) Whether a model has presystemic metabolite
## Not run: model <- load_example_model("pheno") model <- add_metabolite(model, presystemic=TRUE) has_presystemic_metabolite(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- add_metabolite(model, presystemic=TRUE) has_presystemic_metabolite(model) ## End(Not run)
Check if a model has a proportional error model
Multiple dependent variables are supported. By default the only (in case of one) or the first (in case of many) dependent variable is going to be checked.
has_proportional_error_model(model, dv = NULL)
has_proportional_error_model(model, dv = NULL)
model |
(Model) The model to check |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
(logical) TRUE if the model has a proportional error model and FALSE otherwise
has_additive_error_model : Check if a model has an additive error model
has_combined_error_model : Check if a model has a combined error model
has_weighted_error_model : Check if a model has a weighted error model
## Not run: model <- load_example_model("pheno") has_proportional_error_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_proportional_error_model(model) ## End(Not run)
Decides whether the given parameter of a :class:pharmpy.model
has a
random effect.
has_random_effect(model, parameter, level = "all")
has_random_effect(model, parameter, level = "all")
model |
(Model) Input Pharmpy model |
parameter |
(str) Input parameter |
level |
(str) The variability level to look for: 'iiv', 'iov', or 'all' (default) |
(logical) Whether the given parameter has a random effect
get_individual_parameters
get_rv_parameters
## Not run: model <- load_example_model("pheno") has_random_effect(model, 'S1') has_random_effect(model, 'CL', 'iiv') has_random_effect(model, 'CL', 'iov') ## End(Not run)
## Not run: model <- load_example_model("pheno") has_random_effect(model, 'S1') has_random_effect(model, 'CL', 'iiv') has_random_effect(model, 'CL', 'iov') ## End(Not run)
Check if ode system describes a sequential zero-order, first-order absorption
Defined as the model having both zero- and first-order absorption.
has_seq_zo_fo_absorption(model)
has_seq_zo_fo_absorption(model)
model |
(Model) DPharmpy model |
has_zero_order_absorption
has_first_order_absorption
Check if a model has a weighted error model
has_weighted_error_model(model)
has_weighted_error_model(model)
model |
(Model) The model to check |
(logical) TRUE if the model has a weighted error model and FALSE otherwise
has_additive_error_model : Check if a model has an additive error model
has_combined_error_model : Check if a model has a combined error model
has_proportional_error_model : Check if a model has a proportional error model
## Not run: model <- load_example_model("pheno") has_weighted_error_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_weighted_error_model(model) ## End(Not run)
Check if ode system describes a zero order absorption
currently defined as having Infusion dose with rate not in dataset
has_zero_order_absorption(model)
has_zero_order_absorption(model)
model |
(Model) Pharmpy model |
(logical) Whether the model has zero order absorption or not
## Not run: model <- load_example_model("pheno") has_zero_order_absorption(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_zero_order_absorption(model) ## End(Not run)
Check if the model describes zero-order elimination
This function relies on heuristics and will not be able to detect all possible ways of coding the zero-order elimination.
has_zero_order_elimination(model)
has_zero_order_elimination(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has describes zero order elimination
## Not run: model <- load_example_model("pheno") has_zero_order_elimination(model) model <- set_zero_order_elimination(model) has_zero_order_elimination(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") has_zero_order_elimination(model) model <- set_zero_order_elimination(model) has_zero_order_elimination(model) ## End(Not run)
Install the pharmpy-core python package into virtual environment. Uses the same Pharmpy version as pharmr.
install_pharmpy(envname = "r-reticulate", method = "auto")
install_pharmpy(envname = "r-reticulate", method = "auto")
envname |
(str) name of environment. Default is r-reticulate |
method |
(str) type of environment type (virtualenv, conda). Default is auto (virtualenv is not available on Windows) |
Install the pharmpy-core python package into virtual environment.
install_pharmpy_devel( envname = "r-reticulate", method = "auto", version = "devel" )
install_pharmpy_devel( envname = "r-reticulate", method = "auto", version = "devel" )
envname |
(str) name of environment. Default is r-reticulate |
method |
(str) type of environment type (virtualenv, conda). Default is auto (virtualenv is not available on Windows) |
version |
(str) which pharmpy version to use (use 'same' for most cases) |
Determine if a model is linearized
is_linearized(model)
is_linearized(model)
model |
(Model) Pharmpy model |
(logical) TRUE if model has been linearized and FALSE otherwise
## Not run: model1 <- load_example_model("pheno") is_linearized(model1) model2 <- load_example_model("pheno_linear") is_linearized(model2) ## End(Not run)
## Not run: model1 <- load_example_model("pheno") is_linearized(model1) model2 <- load_example_model("pheno_linear") is_linearized(model2) ## End(Not run)
Determine if an expression is real valued given constraints of a model
is_real(model, expr)
is_real(model, expr)
model |
(Model) Pharmpy model |
expr |
(numeric or str or Expr) Expression to test |
(logical or NULL) TRUE if expression is real, FALSE if not and NULL if unknown
## Not run: model <- load_example_model("pheno") is_real(model, "CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") is_real(model, "CL") ## End(Not run)
Takes a ModelfitResults object and a statement as input and returns TRUE/FALSE if the evaluation of the statement is TRUE/FALSE.
is_strictness_fulfilled(model, results, strictness)
is_strictness_fulfilled(model, results, strictness)
model |
(Model) Model for parameter specific strictness. |
results |
(ModelfitResults) ModelfitResults object |
strictness |
(str) A strictness expression |
(logical) A logical indicating whether the strictness criteria are fulfilled or not.
## Not run: res <- load_example_modelfit_results('pheno') model <- load_example_model('pheno') is_strictness_fulfilled(model, res, "minimization_successful or rounding_errors") ## End(Not run)
## Not run: res <- load_example_modelfit_results('pheno') model <- load_example_model('pheno') is_strictness_fulfilled(model, res, "minimization_successful or rounding_errors") ## End(Not run)
Return a vector of names of all time varying covariates
list_time_varying_covariates(model)
list_time_varying_covariates(model)
model |
(Model) Pharmpy model |
(vector) Names of all time varying covariates
get_covariate_baselines : get baselines for all covariates
## Not run: model <- load_example_model("pheno") list_time_varying_covariates(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") list_time_varying_covariates(model) ## End(Not run)
Load the dataset given datainfo
load_dataset(model)
load_dataset(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model with dataset removed
## Not run: model <- load_example_model("pheno") model <- unload_dataset(model) model$dataset is NULL model <- load_dataset(model) model$dataset ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- unload_dataset(model) model$dataset is NULL model <- load_dataset(model) model$dataset ## End(Not run)
Load an example model
Load an example model from models built into Pharmpy
load_example_model(name)
load_example_model(name)
name |
(str) Name of the model. Currently available models are "pheno" and "pheno_linear" |
(Model) Loaded model object
## Not run: model <- load_example_model("pheno") model$statements ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements ## End(Not run)
Load the modelfit results of an example model
Load the modelfit results of an example model built into Pharmpy
load_example_modelfit_results(name)
load_example_modelfit_results(name)
name |
(str) Name of the model. Currently available models are "pheno" and "pheno_linear" |
(ModelfitResults) Loaded modelfit results object
## Not run: results <- load_example_modelfit_results("pheno") results$parameter_estimates ## End(Not run)
## Not run: results <- load_example_modelfit_results("pheno") results$parameter_estimates ## End(Not run)
Make the model statments declarative
Each symbol will only be declared once.
make_declarative(model)
make_declarative(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$statements$before_odes model <- make_declarative(model) model$statements$before_odes ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements$before_odes model <- make_declarative(model) model$statements$before_odes ## End(Not run)
Convert model to use mu-referencing
Mu-referencing an eta is to separately define its actual mu (mean) parameter. For example: (equation could not be rendered, see API doc on website) normal distribution would give (equation could not be rendered, see API doc on website) (equation could not be rendered, see API doc on website)
mu_reference_model(model)
mu_reference_model(model)
model |
(Model) Pharmpy model object |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- mu_reference_model(model) model$statements$before_odes ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- mu_reference_model(model) model$statements$before_odes ## End(Not run)
Iterate over omissions of a certain group in a dataset. One group is omitted at a time.
omit_data(dataset_or_model, group, name_pattern = "omitted_{}")
omit_data(dataset_or_model, group, name_pattern = "omitted_{}")
dataset_or_model |
(data.frame or Model) Dataset or model for which to omit records |
group |
(str) Name of the column to use for grouping |
name_pattern |
(str) Name to use for generated datasets. A number starting from 1 will be put in the placeholder. |
(iterator) Iterator yielding tuples of models/dataframes and the omitted group
Plot \|CWRES\| vs IPRED
plot_abs_cwres_vs_ipred( model, predictions, residuals, stratify_on = NULL, bins = 8 )
plot_abs_cwres_vs_ipred( model, predictions, residuals, stratify_on = NULL, bins = 8 )
model |
(Model) Pharmpy model |
predictions |
(data.frame) DataFrame containing the predictions |
residuals |
(data.frame) DataFrame containing the residuals |
stratify_on |
(str (optional)) Name of parameter for stratification |
bins |
(numeric) Number of bins for stratification |
(alt.Chart) Plot
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_abs_cwres_vs_ipred(model, res$predictions, res$residuals) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_abs_cwres_vs_ipred(model, res$predictions, res$residuals, 'WGT', bins=4) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_abs_cwres_vs_ipred(model, res$predictions, res$residuals) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_abs_cwres_vs_ipred(model, res$predictions, res$residuals, 'WGT', bins=4) ## End(Not run)
Plot CWRES vs idv
plot_cwres_vs_idv(model, residuals, stratify_on = NULL, bins = 8)
plot_cwres_vs_idv(model, residuals, stratify_on = NULL, bins = 8)
model |
(Model) Pharmpy model |
residuals |
(data.frame) DataFrame containing CWRES |
stratify_on |
(str (optional)) Name of parameter for stratification |
bins |
(numeric) Number of bins for stratification |
(alt.Chart) Plot
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_cwres_vs_idv(model, res$residuals) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_cwres_vs_idv(model, res$residuals, 'WGT', bins=4) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_cwres_vs_idv(model, res$residuals) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_cwres_vs_idv(model, res$residuals, 'WGT', bins=4) ## End(Not run)
Plot DV vs IPRED
plot_dv_vs_ipred(model, predictions, stratify_on = NULL, bins = 8)
plot_dv_vs_ipred(model, predictions, stratify_on = NULL, bins = 8)
model |
(Model) Pharmpy model |
predictions |
(data.frame) DataFrame containing the predictions |
stratify_on |
(str (optional)) Name of parameter for stratification |
bins |
(numeric) Number of bins for stratification |
(alt.Chart) Plot
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_ipred(model, res$predictions) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_ipred(model, res$predictions, 'WGT', bins=4) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_ipred(model, res$predictions) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_ipred(model, res$predictions, 'WGT', bins=4) ## End(Not run)
Plot DV vs PRED
plot_dv_vs_pred(model, predictions, stratify_on = NULL, bins = 8)
plot_dv_vs_pred(model, predictions, stratify_on = NULL, bins = 8)
model |
(Model) Pharmpy model |
predictions |
(data.frame) DataFrame containing the predictions |
stratify_on |
(str (optional)) Name of parameter for stratification |
bins |
(numeric) Number of bins for stratification |
(alt.Chart) Plot
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_pred(model, res$predictions) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_pred(model, res$predictions, 'WGT', bins=4) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_pred(model, res$predictions) model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_dv_vs_pred(model, res$predictions, 'WGT', bins=4) ## End(Not run)
Plot eta distributions for all etas
plot_eta_distributions(model, individual_estimates)
plot_eta_distributions(model, individual_estimates)
model |
(Model) Previously run Pharmpy model. |
individual_estimates |
(data.frame) Individual estimates for etas |
(alt.Chart) Plot
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_eta_distributions(model, res$individual_estimates) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_eta_distributions(model, res$individual_estimates) ## End(Not run)
Plot DV and predictions grouped on individuals
plot_individual_predictions(model, predictions, individuals = NULL)
plot_individual_predictions(model, predictions, individuals = NULL)
model |
(Model) Previously run Pharmpy model. |
predictions |
(data.frame) One column for each type of prediction |
individuals |
(array(numeric) (optional)) A vector of individuals to include. NULL for all individuals |
(alt.Chart) Plot
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_individual_predictions(model, res$predictions, individuals=c(1, 2, 3, 4, 5)) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- load_example_modelfit_results("pheno") plot_individual_predictions(model, res$predictions, individuals=c(1, 2, 3, 4, 5)) ## End(Not run)
Plot individual OFV of two models against each other
plot_iofv_vs_iofv(iofv1, iofv2, name1, name2)
plot_iofv_vs_iofv(iofv1, iofv2, name1, name2)
iofv1 |
(array) Estimated iOFV of the first model |
iofv2 |
(array) Estimated iOFV of the second model |
name1 |
(str) Name of first model |
name2 |
(str) Name of second model |
(alt.Chart) Scatterplot
## Not run: res1 <- load_example_modelfit_results("pheno") res2 <- load_example_modelfit_results("pheno_linear") plot_iofv_vs_iofv(res1$individual_ofv, res2$individual_ofv, "nonlin", "linear") ## End(Not run)
## Not run: res1 <- load_example_modelfit_results("pheno") res2 <- load_example_modelfit_results("pheno_linear") plot_iofv_vs_iofv(res1$individual_ofv, res2$individual_ofv, "nonlin", "linear") ## End(Not run)
Plot transformed eta distributions for all transformed etas
plot_transformed_eta_distributions( model, parameter_estimates, individual_estimates )
plot_transformed_eta_distributions( model, parameter_estimates, individual_estimates )
model |
(Model) Previously run Pharmpy model. |
parameter_estimates |
(array or list(str=numeric)) Parameter estimates of model fit |
individual_estimates |
(data.frame) Individual estimates for etas |
(alt.Chart) Plot
Creates a VPC plot for a model
plot_vpc( model, simulations, binning = "equal_number", nbins = 8, qi = 0.95, ci = 0.95, stratify_on = NULL )
plot_vpc( model, simulations, binning = "equal_number", nbins = 8, qi = 0.95, ci = 0.95, stratify_on = NULL )
model |
(Model) Pharmpy model |
simulations |
(data.frame or str) DataFrame containing the simulation data or path to dataset. The dataset has to have one (index) column named "SIM" containing the simulation number, one (index) column named "index" containing the data indices and one dv column. See below for more information. |
binning |
(str) Binning method. Can be "equal_number" or "equal_width". The default is "equal_number". |
nbins |
(numeric) Number of bins. Default is 8. |
qi |
(numeric) Upper quantile. Default is 0.95. |
ci |
(numeric) Confidence interval. Default is 0.95. |
stratify_on |
(str (optional)) Parameter to use for stratification. Optional. |
(alt.Chart) Plot The simulation data should have the following format: +—–+——-+——–+ | SIM | index | DV | +=====+=======+========+ | 1 | 0 | 0.000 | +—–+——-+——–+ | 1 | 1 | 34.080 | +—–+——-+——–+ | 1 | 2 | 28.858 | +—–+——-+——–+ | 1 | 3 | 0.000 | +—–+——-+——–+ | 1 | 4 | 12.157 | +—–+——-+——–+ | 2 | 0 | 23.834 | +—–+——-+——–+ | 2 | 1 | 0.000 | +—–+——-+——–+ | ... | ... | ... | +—–+——-+——–+ | 20 | 2 | 0.000 | +—–+——-+——–+ | 20 | 3 | 31.342 | +—–+——-+——–+ | 20 | 4 | 29.983 | +—–+——-+——–+
## Not run: model <- load_example_model("pheno") sim_model <- set_simulation(model, n=100) sim_data <- run_simulation(sim_model) plot_vpc(model, sim_data) ## End(Not run)
## Not run: model <- load_example_model("pheno") sim_model <- set_simulation(model, n=100) sim_data <- run_simulation(sim_model) plot_vpc(model, sim_data) ## End(Not run)
Predict influential individuals for a model using a machine learning model.
Please refer to www.page-meeting.org/?abstract=10029 for more information on training and estimated precision and accuracy.
predict_influential_individuals(model, results, cutoff = 3.84)
predict_influential_individuals(model, results, cutoff = 3.84)
model |
(Model) Pharmpy model |
results |
(ModelfitResults) Results for model |
cutoff |
(numeric) Cutoff threshold for a dofv signalling an influential individual |
(data.frame) Dataframe over the individuals with a dofv
column containing the raw predicted delta-OFV and an influential
column with a boolean to tell whether the individual is influential or not.
predict_influential_outliers
predict_outliers
Predict influential outliers for a model using a machine learning model.
Please refer to www.page-meeting.org/?abstract=10029 for more information on training and estimated precision and accuracy.
predict_influential_outliers( model, results, outlier_cutoff = 3, influential_cutoff = 3.84 )
predict_influential_outliers( model, results, outlier_cutoff = 3, influential_cutoff = 3.84 )
model |
(Model) Pharmpy model |
results |
(ModelfitResults) Results for model |
outlier_cutoff |
(numeric) Cutoff threshold for a residual signaling an outlier |
influential_cutoff |
(numeric) Cutoff threshold for a dofv signaling an influential individual |
(data.frame) Dataframe over the individuals with a outliers
and dofv
columns containing the raw predictions and influential
, outlier
and influential_outlier
boolean columns.
predict_influential_individuals
predict_outliers
Predict outliers for a model using a machine learning model.
See the :ref:simeval <Individual OFV summary>
documentation for a definition of the residual
Please refer to www.page-meeting.org/?abstract=10029 for more information on training and estimated precision and accuracy.
predict_outliers(model, results, cutoff = 3)
predict_outliers(model, results, cutoff = 3)
model |
(Model) Pharmpy model |
results |
(ModelfitResults) ModelfitResults for the model |
cutoff |
(numeric) Cutoff threshold for a residual signaling an outlier |
(data.frame) Dataframe over the individuals with a residual
column containing the raw predicted residuals and a outlier
column with a boolean to tell whether the individual is an outlier or not.
predict_influential_individuals
predict_influential_outliers
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") predict_outliers(model, results) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") predict_outliers(model, results) ## End(Not run)
Print a summary of the model fit
print_fit_summary(model, modelfit_results)
print_fit_summary(model, modelfit_results)
model |
(Model) Pharmpy model object |
modelfit_results |
(ModelfitResults) Pharmpy ModelfitResults object |
Print the model code of the underlying model language
print_model_code(model)
print_model_code(model)
model |
(Model) Pharmpy model |
## Not run: model <- load_example_model("pheno") print_model_code(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") print_model_code(model) ## End(Not run)
Print all symbols defined in a model
Symbols will be in one of the categories thetas, etas, omegas, epsilons, sigmas, variables and data columns
print_model_symbols(model)
print_model_symbols(model)
model |
(Model) Pharmpy model object |
## Not run: model <- load_example_model("pheno") print_model_symbols(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") print_model_symbols(model) ## End(Not run)
Print the pharmpy version pharmr uses.
print_pharmpy_version()
print_pharmpy_version()
Read a dataset given a datainfo object or path to a datainfo file
read_dataset_from_datainfo(datainfo, datatype = NULL)
read_dataset_from_datainfo(datainfo, datatype = NULL)
datainfo |
(DataInfo or str) A datainfo object or a path to a datainfo object |
datatype |
(str (optional)) A string to specify dataset type |
(data.frame) The dataset
Read model from file
read_model(path, missing_data_token = NULL)
read_model(path, missing_data_token = NULL)
path |
(str) Path to model |
missing_data_token |
(str (optional)) Use this token for missing data. This option will override the token from the config. (This option was added in Pharmpy version 1.2.0) |
(Model) Read model object
read_model_from_database : Read model from database
read_model_from_string : Read model from string
## Not run: model <- read_model("/home/run1$mod") ## End(Not run)
## Not run: model <- read_model("/home/run1$mod") ## End(Not run)
Read model from the model code in a string
read_model_from_string(code)
read_model_from_string(code)
code |
(str) Model code to read |
(Model) Pharmpy model object
read_model : Read model from file
read_model_from_database : Read model from database
## Not run: s <- "$PROBLEM $INPUT ID DV TIME $DATA file$csv $PRED Y=THETA(1)+ETA(1)+ERR(1) $THETA 1 $OMEGA 0.1 $SIGMA 1 $ESTIMATION METHOD=1" read_model_from_string(s) ## End(Not run)
## Not run: s <- "$PROBLEM $INPUT ID DV TIME $DATA file$csv $PRED Y=THETA(1)+ETA(1)+ERR(1) $THETA 1 $OMEGA 0.1 $SIGMA 1 $ESTIMATION METHOD=1" read_model_from_string(s) ## End(Not run)
Read results from external tool for a model
read_modelfit_results(path, esttool = NULL)
read_modelfit_results(path, esttool = NULL)
path |
(str) Path to model file |
esttool |
(str) Set if other than the default estimation tool is to be used |
(ModelfitResults) Results object
Read results object from file
read_results(path)
read_results(path)
path |
(str) Path to results file |
(Results) Results object for tool
create_results
## Not run: res <- read_results("results$json") ## End(Not run)
## Not run: res <- read_results("results$json") ## End(Not run)
Remove bioavailability from the first dose compartment of model.
remove_bioavailability(model)
remove_bioavailability(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_bioavailability
## Not run: model <- load_example_model("pheno") model <- remove_bioavailability(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_bioavailability(model) ## End(Not run)
Remove a covariate effect from an instance of :class:pharmpy.model
.
remove_covariate_effect(model, parameter, covariate)
remove_covariate_effect(model, parameter, covariate)
model |
(Model) Pharmpy model from which to remove the covariate effect. |
parameter |
(str) Name of parameter. |
covariate |
(str) Name of covariate. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") has_covariate_effect(model, "CL", "WGT") model <- remove_covariate_effect(model, "CL", "WGT") has_covariate_effect(model, "CL", "WGT") ## End(Not run)
## Not run: model <- load_example_model("pheno") has_covariate_effect(model, "CL", "WGT") model <- remove_covariate_effect(model, "CL", "WGT") has_covariate_effect(model, "CL", "WGT") ## End(Not run)
Remove a derivative currently being calculcate when running model. Currently, only derivatives with respect to the prediction is supported. Default is to remove all that are present, First order derivates are specied either by single string or single-element tuple. For instance with_respect_to = "ETA_1" or with_respect_to = ("ETA_1",)
Second order derivatives are specified by giving the two independent varibles in a tuple of tuples. For instance with_respect_to ((ETA_1, EPS_1),)
Multiple derivatives can be specified within a tuple. For instance ((ETA_1, EPS_1), "ETA_1")
Currently, only ETAs and EPSILONs are supported
remove_derivative(model, with_respect_to = NULL)
remove_derivative(model, with_respect_to = NULL)
model |
(Model) Pharmpy modeas. |
with_respect_to |
(array(array(str) or str) or str (optional)) Parameter name(s) to use as independent variables. Default is NULL. |
(Pharmpy model.)
Remove error model.
remove_error_model(model)
remove_error_model(model)
model |
(Model) Remove error model for this model |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$statements$find_assignment("Y") model <- remove_error_model(model) model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements$find_assignment("Y") model <- remove_error_model(model) model$statements$find_assignment("Y") ## End(Not run)
Remove estimation step
remove_estimation_step(model, idx)
remove_estimation_step(model, idx)
model |
(Model) Pharmpy model |
idx |
(numeric) index of estimation step to remove (starting from 0) |
(Model) Pharmpy model object
add_estimation_step
set_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
set_evaluation_step
## Not run: model <- load_example_model("pheno") model <- remove_estimation_step(model, 0) ests <- model$execution_steps length(ests) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_estimation_step(model, 0) ests <- model$execution_steps length(ests) ## End(Not run)
Removes all IIV etas given a vector with eta names and/or parameter names.
remove_iiv(model, to_remove = NULL)
remove_iiv(model, to_remove = NULL)
model |
(Model) Pharmpy model to create block effect on. |
to_remove |
(array(str) or str (optional)) Name/names of etas and/or name/names of individual parameters to remove. If NULL, all etas that are IIVs will be removed. NULL is default. |
(Model) Pharmpy model object
remove_iov
add_iiv
add_iov
add_pk_iiv
## Not run: model <- load_example_model("pheno") model <- remove_iiv(model) model$statements$find_assignment("CL") model <- load_example_model("pheno") model <- remove_iiv(model, "VC") model$statements$find_assignment("VC") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_iiv(model) model$statements$find_assignment("CL") model <- load_example_model("pheno") model <- remove_iiv(model, "VC") model$statements$find_assignment("VC") ## End(Not run)
Removes all IOV etas given a vector with eta names.
remove_iov(model, to_remove = NULL)
remove_iov(model, to_remove = NULL)
model |
(Model) Pharmpy model to remove IOV from. |
to_remove |
(array(str) or str (optional)) Name/names of IOV etas to remove, e.g. 'ETA_IOV_1_1'. If NULL, all etas that are IOVs will be removed. NULL is default. |
(Model) Pharmpy model object
add_iiv
add_iov
remove_iiv
add_pk_iiv
## Not run: model <- load_example_model("pheno") model <- remove_iov(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_iov(model) ## End(Not run)
Remove lag time from the dose compartment of model.
remove_lag_time(model)
remove_lag_time(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_transit_compartments
add_lag_time
## Not run: model <- load_example_model("pheno") model <- remove_lag_time(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_lag_time(model) ## End(Not run)
Remove loq data records from the dataset
Does nothing if none of the limits are specified.
remove_loq_data( model, lloq = NULL, uloq = NULL, blq = NULL, alq = NULL, keep = 0 )
remove_loq_data( model, lloq = NULL, uloq = NULL, blq = NULL, alq = NULL, keep = 0 )
model |
(Model) Pharmpy model object |
lloq |
(numeric or str (optional)) Value or column name for lower limit of quantification. |
uloq |
(numeric or str (optional)) Value or column name for upper limit of quantification. |
blq |
(str (optional)) Column name for below limit of quantification indicator. |
alq |
(str (optional)) Column name for above limit of quantification indicator. |
keep |
(numeric (optional)) Number of loq records to keep for each run of consecutive loq records. |
(Model) Pharmpy model object
set_lloq_data
transform_blq
## Not run: model <- load_example_model("pheno") model <- remove_loq_data(model, lloq=10, uloq=40) length(model$dataset) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_loq_data(model, lloq=10, uloq=40) length(model$dataset) ## End(Not run)
Removes parameter uncertainty step from the final estimation step
remove_parameter_uncertainty_step(model)
remove_parameter_uncertainty_step(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
add_estimation_step
set_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
set_evaluation_step
## Not run: model <- load_example_model("pheno") model <- remove_parameter_uncertainty_step(model) ests <- model$execution_steps ests[1] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_parameter_uncertainty_step(model) ests <- model$execution_steps ests[1] ## End(Not run)
Remove a peripheral distribution compartment from model
If name is set, a peripheral compartment will be removed from the compartment with the specified name.
Initial estimates:
== =================================================== n == =================================================== 2 (equation could not be rendered, see API doc on website) 3 (equation could not be rendered, see API doc on website) == ===================================================
remove_peripheral_compartment(model, name = NULL)
remove_peripheral_compartment(model, name = NULL)
model |
(Model) Pharmpy model |
name |
(str) Name of compartment to remove peripheral compartment from. |
(Model) Pharmpy model object
set_peripheral_compartment
add_peripheral_compartment
## Not run: model <- load_example_model("pheno") model <- set_peripheral_compartments(model, 2) model <- remove_peripheral_compartment(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_peripheral_compartments(model, 2) model <- remove_peripheral_compartment(model) model$statements$ode_system ## End(Not run)
Remove predictions and/or residuals
Remove predictions from estimation step.
remove_predictions(model, to_remove = NULL)
remove_predictions(model, to_remove = NULL)
model |
(Model) Pharmpy model |
to_remove |
(array(str) (optional)) Predictions to remove |
(Model) Pharmpy model object
add_predictions
add_residuals
set_estimation_step
add_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
## Not run: model <- load_example_model("pheno") model <- remove_predictions(model) model$execution_steps[-1].predictions ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_predictions(model) model$execution_steps[-1].predictions ## End(Not run)
Remove residuals
Remove residuals from estimation step.
remove_residuals(model, to_remove = NULL)
remove_residuals(model, to_remove = NULL)
model |
(Model) Pharmpy model |
to_remove |
(array(str) (optional)) Residuals to remove |
(Model) Pharmpy model object
add_predictions
add_residuals
set_estimation_step
add_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
## Not run: model <- load_example_model("pheno") model <- remove_residuals(model) model$execution_steps[-1].residuals ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- remove_residuals(model) model$execution_steps[-1].residuals ## End(Not run)
Remove any parameters and rvs that are not used in the model statements
remove_unused_parameters_and_rvs(model)
remove_unused_parameters_and_rvs(model)
model |
(Model) Pharmpy model object |
(Model) Pharmpy model object
Rename symbols in the model
Make sure that no name clash occur.
rename_symbols(model, new_names)
rename_symbols(model, new_names)
model |
(Model) Pharmpy model object |
new_names |
(list(str or Expr=str or Expr)) From old name or symbol to new name or symbol |
(Model) Pharmpy model object
Replace all fixed thetas with constants in the model statements
replace_fixed_thetas(model)
replace_fixed_thetas(model)
model |
(Model) Pharmpy model |
(Model) A new model
Replace all random variables that are not actually random
Some random variables are constant. For example a normal distribution with the variance parameter fixed to 0 will always yield a single value when sampled. This function will find all such random variables and replace them with their constant value in the model.
replace_non_random_rvs(model)
replace_non_random_rvs(model)
model |
(Model) Pharmpy model |
(Model) A new model
Iterate over resamples of a dataset.
The dataset will be grouped on the group column then groups will be selected randomly with or without replacement to form a new dataset. The groups will be renumbered from 1 and upwards to keep them separated in the new dataset.
resample_data( dataset_or_model, group, resamples = 1, stratify = NULL, sample_size = NULL, replace = FALSE, name_pattern = "resample_{}", name = NULL )
resample_data( dataset_or_model, group, resamples = 1, stratify = NULL, sample_size = NULL, replace = FALSE, name_pattern = "resample_{}", name = NULL )
dataset_or_model |
(data.frame or Model) Dataset or Model to use |
group |
(str) Name of column to group by |
resamples |
(numeric) Number of resamples (iterations) to make |
stratify |
(str (optional)) Name of column to use for stratification. The values in the stratification column must be equal within a group so that the group can be uniquely determined. A ValueError exception will be raised otherwise. |
sample_size |
(numeric (optional)) The number of groups that should be sampled. The default is the number of groups. If using stratification the default is to sample using the proportion of the strata in the dataset. A list of specific sample sizes for each stratum can also be supplied. |
replace |
(logical) A boolean controlling whether sampling should be done with or without replacement |
name_pattern |
(str) Name to use for generated datasets. A number starting from 1 will be put in the placeholder. |
name |
(str (optional)) Option to name pattern in case of only one resample |
(iterator) An iterator yielding tuples of a resampled DataFrame and a vector of resampled groups in order
Reset index of dataframe.
Reset index from a multi indexed data.frame so that index is added as columns
reset_index(df)
reset_index(df)
df |
A data.frame converted from python using reticulate |
Resets indices in dataframes within Results-objects when needed
reset_indices_results(res)
reset_indices_results(res)
res |
A Pharmpy results object |
Retrieve models after a tool run
Any models created and run by the tool can be retrieved.
retrieve_models(source, names = NULL)
retrieve_models(source, names = NULL)
source |
(str or Context) Source where to find models. Can be a path (as str or Path), or a Context |
names |
(array(str) (optional)) List of names of the models to retrieve or NULL for all |
(vector) List of retrieved model objects
## Not run: tooldir_path <- 'path/to/tool/directory' models <- retrieve_models(tooldir_path, names=c('run1')) ## End(Not run)
## Not run: tooldir_path <- 'path/to/tool/directory' models <- retrieve_models(tooldir_path, names=c('run1')) ## End(Not run)
Run allometry tool. For more details, see :ref:allometry
.
run_allometry( model = NULL, results = NULL, allometric_variable = "WT", reference_value = 70, parameters = NULL, initials = NULL, lower_bounds = NULL, upper_bounds = NULL, fixed = TRUE, ... )
run_allometry( model = NULL, results = NULL, allometric_variable = "WT", reference_value = 70, parameters = NULL, initials = NULL, lower_bounds = NULL, upper_bounds = NULL, fixed = TRUE, ... )
model |
(Model (optional)) Pharmpy model |
results |
(ModelfitResults (optional)) Results for model |
allometric_variable |
(str or Expr) Name of the variable to use for allometric scaling (default is WT) |
reference_value |
(str or numeric or Expr) Reference value for the allometric variable (default is 70) |
parameters |
(array(str or Expr) (optional)) Parameters to apply scaling to (default is all CL, Q and V parameters) |
initials |
(array(numeric) (optional)) Initial estimates for the exponents. (default is to use 0.75 for CL and Qs and 1 for Vs) |
lower_bounds |
(array(numeric) (optional)) Lower bounds for the exponents. (default is 0 for all parameters) |
upper_bounds |
(array(numeric) (optional)) Upper bounds for the exponents. (default is 2 for all parameters) |
fixed |
(logical) Should the exponents be fixed or not. (default TRUE |
... |
Arguments to pass to tool |
(AllometryResults) Allometry tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_allometry(model=model, results=results, allometric_variable='WGT') ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_allometry(model=model, results=results, allometric_variable='WGT') ## End(Not run)
Run Automatic Model Development (AMD) tool
run_amd( input, results = NULL, modeltype = "basic_pk", administration = "oral", strategy = "default", cl_init = NULL, vc_init = NULL, mat_init = NULL, b_init = NULL, emax_init = NULL, ec50_init = NULL, met_init = NULL, search_space = NULL, lloq_method = NULL, lloq_limit = NULL, allometric_variable = NULL, occasion = NULL, path = NULL, resume = FALSE, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", dv_types = NULL, mechanistic_covariates = NULL, retries_strategy = "all_final", seed = NULL, parameter_uncertainty_method = NULL, ignore_datainfo_fallback = FALSE, .E = NULL )
run_amd( input, results = NULL, modeltype = "basic_pk", administration = "oral", strategy = "default", cl_init = NULL, vc_init = NULL, mat_init = NULL, b_init = NULL, emax_init = NULL, ec50_init = NULL, met_init = NULL, search_space = NULL, lloq_method = NULL, lloq_limit = NULL, allometric_variable = NULL, occasion = NULL, path = NULL, resume = FALSE, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", dv_types = NULL, mechanistic_covariates = NULL, retries_strategy = "all_final", seed = NULL, parameter_uncertainty_method = NULL, ignore_datainfo_fallback = FALSE, .E = NULL )
input |
(Model or str or data.frame) Starting model or dataset |
results |
(ModelfitResults (optional)) Reults of input if input is a model |
modeltype |
(str) Type of model to build. Valid strings are 'basic_pk', 'pkpd', 'drug_metabolite' and 'tmdd' |
administration |
(str) Route of administration. Either 'iv', 'oral' or 'ivoral' |
strategy |
(str) Run algorithm for AMD procedure. Valid options are 'default', 'reevaluation', 'SIR', 'SRI', and 'RSI'. |
cl_init |
(numeric (optional)) Initial estimate for the population clearance |
vc_init |
(numeric (optional)) Initial estimate for the central compartment population volume |
mat_init |
(numeric (optional)) Initial estimate for the mean absorption time (not for iv models) |
b_init |
(numeric (optional)) Initial estimate for the baseline (PKPD model) |
emax_init |
(numeric (optional)) Initial estimate for E_max (PKPD model) |
ec50_init |
(numeric (optional)) Initial estimate for EC_50 (PKPD model) |
met_init |
(numeric (optional)) Initial estimate for mean equilibration time (PKPD model) |
search_space |
(str (optional)) MFL for search space for structural and covariate model |
lloq_method |
(str (optional)) Method for how to remove LOQ data. See |
lloq_limit |
(numeric (optional)) Lower limit of quantification. If NULL LLOQ column from dataset will be used |
allometric_variable |
(str or Expr (optional)) Variable to use for allometry. This option is deprecated. Please use ALLOMETRY in the mfl instead. |
occasion |
(str (optional)) Name of occasion column |
path |
(str (optional)) Path to run AMD in |
resume |
(logical) Whether to allow resuming previous run |
strictness |
(str (optional)) Strictness criteria |
dv_types |
(list(str=numeric) (optional)) Dictionary of DV types for TMDD models with multiple DVs. |
mechanistic_covariates |
(array(str or list(str)) (optional)) List of covariates or tuple of covariate and parameter combination to run in a separate proioritized covsearch run. For instance c("WT", ("CRCL", "CL")). The effects are extracted from the search space for covsearch. |
retries_strategy |
(str) Whether or not to run retries tool. Valid options are 'skip', 'all_final' or 'final'. Default is 'final'. |
seed |
(numeric (optional)) Random number generator or seed to be used. |
parameter_uncertainty_method |
(str (optional)) Parameter uncertainty method. |
ignore_datainfo_fallback |
(logical) Ignore using datainfo to get information not given by the user. Default is FALSE |
.E |
(list(str=numeric or str) (optional)) EXPERIMENTAL FEATURE. Dictionary of different E-values used in mBIC. |
(AMDResults) Results for the run
run_iiv
run_tool
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") res <- run_amd(model, results=results) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") res <- run_amd(model, results=results) ## End(Not run)
Run bootstrap tool
run_bootstrap(model, results = NULL, resamples = 1, ...)
run_bootstrap(model, results = NULL, resamples = 1, ...)
model |
(Model) Pharmpy model |
results |
(ModelfitResults (optional)) Results for model |
resamples |
(numeric) Number of bootstrap resample |
... |
Arguments to pass to tool |
(BootstrapResults) Bootstrap tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_bootstrap(model, res, resamples=500) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_bootstrap(model, res, resamples=500) ## End(Not run)
Run COVsearch tool. For more details, see :ref:covsearch
.
run_covsearch( search_space, p_forward = 0.01, p_backward = 0.001, max_steps = -1, algorithm = "scm-forward-then-backward", results = NULL, model = NULL, max_eval = FALSE, adaptive_scope_reduction = FALSE, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", naming_index_offset = 0, nsamples = 10, .statsmodels = FALSE, .weighted_linreg = FALSE, .lin_filter = 0, ... )
run_covsearch( search_space, p_forward = 0.01, p_backward = 0.001, max_steps = -1, algorithm = "scm-forward-then-backward", results = NULL, model = NULL, max_eval = FALSE, adaptive_scope_reduction = FALSE, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", naming_index_offset = 0, nsamples = 10, .statsmodels = FALSE, .weighted_linreg = FALSE, .lin_filter = 0, ... )
search_space |
(str or ModelFeatures) MFL of covariate effects to try |
p_forward |
(numeric) The p-value to use in the likelihood ratio test for forward steps |
p_backward |
(numeric) The p-value to use in the likelihood ratio test for backward steps |
max_steps |
(numeric) The maximum number of search steps to make |
algorithm |
(str) The search algorithm to use. Currently, 'scm-forward' and 'scm-forward-then-backward' are supported. |
results |
(ModelfitResults (optional)) Results of model |
model |
(Model (optional)) Pharmpy model |
max_eval |
(logical) Limit the number of function evaluations to 3.1 times that of the base model. Default is FALSE. |
adaptive_scope_reduction |
(logical) Stash all non-significant parameter-covariate effects to be tested after all significant effects have been tested. Once all these have been tested, try adding the stashed effects once more with a regular forward approach. Default is FALSE |
strictness |
(str (optional)) Strictness criteria |
naming_index_offset |
(numeric (optional)) index offset for naming of runs. Default is 0. |
nsamples |
(numeric) Number of samples from individual parameter conditional distribution for linear covariate model selection.
|
.statsmodels |
(logical) Estimation tool for SAMBA linear covariate model fitting. 'TRUE' calls statsmodel's functionalities, whereas 'FALSE' calls nonmem. |
.weighted_linreg |
(logical) When using nonmem to run linear covariate models, 'TRUE' uses ETC as weight to run WLS. |
.lin_filter |
(numeric) Option to control the number of covariates passed to nonlinear selection |
... |
Arguments to pass to tool |
(COVSearchResults) COVsearch tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") search_space <- 'COVARIATE(c(CL, V), c(AGE, WT), EXP)' res <- run_covsearch(search_space, model=model, results=results) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") search_space <- 'COVARIATE(c(CL, V), c(AGE, WT), EXP)' res <- run_covsearch(search_space, model=model, results=results) ## End(Not run)
Run estmethod tool.
run_estmethod( algorithm, methods = NULL, solvers = NULL, parameter_uncertainty_methods = NULL, compare_ofv = TRUE, results = NULL, model = NULL, ... )
run_estmethod( algorithm, methods = NULL, solvers = NULL, parameter_uncertainty_methods = NULL, compare_ofv = TRUE, results = NULL, model = NULL, ... )
algorithm |
(str) The algorithm to use (can be 'exhaustive', 'exhaustive_with_update' or 'exhaustive_only_eval') |
methods |
(array(str) or str (optional)) List of estimation methods to test. Can be specified as 'all', a vector of estimation methods, or NULL (to not test any estimation method) |
solvers |
(array(str) or str (optional)) List of solvers to test. Can be specified as 'all', a vector of solvers, or NULL (to not test any solver) |
parameter_uncertainty_methods |
(array(str) or str (optional)) List of parameter uncertainty methods to test. Can be specified as 'all', a vector of uncertainty methods, or NULL (to not evaluate any uncertainty) |
compare_ofv |
(logical) Whether to compare the OFV between candidates. Comparison is made by evaluating using IMP |
results |
(ModelfitResults (optional)) Results for model |
model |
(Model (optional)) Pharmpy mode |
... |
Arguments to pass to tool |
(EstMethodResults) Estmethod tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") methods <- c('IMP', 'SAEM') parameter_uncertainty_methods <- NULL run_estmethod( 'reduced', methods=methods, solvers='all', parameter_uncertainty_methods=parameter_uncertainty_methods, results=results, model=model ) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") methods <- c('IMP', 'SAEM') parameter_uncertainty_methods <- NULL run_estmethod( 'reduced', methods=methods, solvers='all', parameter_uncertainty_methods=parameter_uncertainty_methods, results=results, model=model ) ## End(Not run)
Run IIVsearch tool. For more details, see :ref:iivsearch
.
run_iivsearch( algorithm = "top_down_exhaustive", iiv_strategy = "no_add", rank_type = "bic", linearize = FALSE, cutoff = NULL, results = NULL, model = NULL, keep = c("CL"), strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", correlation_algorithm = NULL, E_p = NULL, E_q = NULL, ... )
run_iivsearch( algorithm = "top_down_exhaustive", iiv_strategy = "no_add", rank_type = "bic", linearize = FALSE, cutoff = NULL, results = NULL, model = NULL, keep = c("CL"), strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", correlation_algorithm = NULL, E_p = NULL, E_q = NULL, ... )
algorithm |
(str) Which algorithm to run when determining number of IIVs. |
iiv_strategy |
(str) If/how IIV should be added to start model. Default is 'no_add'. |
rank_type |
(str) Which ranking type should be used. Default is BIC. |
linearize |
(logical) Wheter or not use linearization when running the tool. |
cutoff |
(numeric (optional)) Cutoff for which value of the ranking function that is considered significant. Default is NULL (all models will be ranked) |
results |
(ModelfitResults (optional)) Results for model |
model |
(Model (optional)) Pharmpy model |
keep |
(array(str) (optional)) List of IIVs to keep. Default is "CL" |
strictness |
(str (optional)) Strictness criteria |
correlation_algorithm |
(str (optional)) Which algorithm to run for the determining block structure of added IIVs. If NULL, the algorithm is determined based on the 'algorithm' argument |
E_p |
(numeric or str (optional)) Expected number of predictors for diagonal elements (used for mBIC). Must be set when using mBIC and when the argument 'algorithm' is not 'skip' |
E_q |
(numeric or str (optional)) Expected number of predictors for off-diagonal elements (used for mBIC). Must be set when using mBIC
and when the argument |
... |
Arguments to pass to tool |
(IIVSearchResults) IIVsearch tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_iivsearch('td_brute_force', results=results, model=model) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_iivsearch('td_brute_force', results=results, model=model) ## End(Not run)
Run IOVsearch tool. For more details, see :ref:iovsearch
.
run_iovsearch( column = "OCC", list_of_parameters = NULL, rank_type = "bic", cutoff = NULL, distribution = "same-as-iiv", results = NULL, model = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", E = NULL, ... )
run_iovsearch( column = "OCC", list_of_parameters = NULL, rank_type = "bic", cutoff = NULL, distribution = "same-as-iiv", results = NULL, model = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", E = NULL, ... )
column |
(str) Name of column in dataset to use as occasion column (default is 'OCC') |
list_of_parameters |
(array(str or array(str)) (optional)) List of parameters to test IOV on, if none all parameters with IIV will be tested (default) |
rank_type |
(str) Which ranking type should be used. Default is BIC. |
cutoff |
(numeric (optional)) Cutoff for which value of the ranking type that is considered significant. Default is NULL (all models will be ranked) |
distribution |
(str) Which distribution added IOVs should have (default is same-as-iiv) |
results |
(ModelfitResults (optional)) Results for model |
model |
(Model (optional)) Pharmpy model |
strictness |
(str (optional)) Strictness criteria |
E |
(numeric or str (optional)) Expected number of predictors (used for mBIC). Must be set when using mBI |
... |
Arguments to pass to tool |
(IOVSearchResults) IOVSearch tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_iovsearch('OCC', results=results, model=model) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_iovsearch('OCC', results=results, model=model) ## End(Not run)
Linearize a model
run_linearize( model = NULL, results = NULL, model_name = "linbase", description = "", ... )
run_linearize( model = NULL, results = NULL, model_name = "linbase", description = "", ... )
model |
(Model (optional)) Pharmpy model. |
results |
(ModelfitResults (optional)) Results of estimation of model |
model_name |
(str) New name of linearized model. The default is "linbase". |
description |
(str) Description of linearized model. The default is "" |
... |
Arguments to pass to tool |
(LinearizeResults) Linearize tool results object.
Run modelfit tool.
note::
For most use cases the :func:pharmpy.tools.fit
function is a more user friendly option for fitting a model.
run_modelfit(model_or_models = NULL, n = NULL, ...)
run_modelfit(model_or_models = NULL, n = NULL, ...)
model_or_models |
(Model or array(Model) (optional)) A vector of models are one single model object |
n |
(numeric (optional)) Number of models to fit. This is only used if the tool is going to be combined with other tools |
... |
Arguments to pass to tool |
(ModelfitResults) Modelfit tool result object
## Not run: model <- load_example_model("pheno") run_modelfit(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") run_modelfit(model) ## End(Not run)
Run Modelsearch tool. For more details, see :ref:modelsearch
.
run_modelsearch( search_space, algorithm, iiv_strategy = "absorption_delay", rank_type = "bic", cutoff = NULL, results = NULL, model = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs >= 0.1)", E = NULL, ... )
run_modelsearch( search_space, algorithm, iiv_strategy = "absorption_delay", rank_type = "bic", cutoff = NULL, results = NULL, model = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs >= 0.1)", E = NULL, ... )
search_space |
(str or ModelFeatures) Search space to test. Either as a string or a ModelFeatures object. |
algorithm |
(str) Algorithm to use. |
iiv_strategy |
(str) If/how IIV should be added to candidate models. Default is 'absorption_delay'. |
rank_type |
(str) Which ranking type should be used. Default is BIC. |
cutoff |
(numeric (optional)) Cutoff for which value of the ranking function that is considered significant. Default is NULL (all models will be ranked) |
results |
(ModelfitResults (optional)) Results for model |
model |
(Model (optional)) Pharmpy model |
strictness |
(str (optional)) Strictness criteria |
E |
(numeric or str (optional)) Expected number of predictors (used for mBIC). Must be set when using mBI |
... |
Arguments to pass to tool |
(ModelSearchResults) Modelsearch tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_modelsearch('ABSORPTION(ZO);PERIPHERALS(1)', 'exhaustive', results=results, model=model) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_modelsearch('ABSORPTION(ZO);PERIPHERALS(1)', 'exhaustive', results=results, model=model) ## End(Not run)
Run retries tool.
run_retries( model = NULL, results = NULL, number_of_candidates = 5, fraction = 0.1, use_initial_estimates = FALSE, strictness = "minimization_successful or (rounding_errors and sigdigs >= 0.1)", scale = "UCP", prefix_name = "", seed = NULL, ... )
run_retries( model = NULL, results = NULL, number_of_candidates = 5, fraction = 0.1, use_initial_estimates = FALSE, strictness = "minimization_successful or (rounding_errors and sigdigs >= 0.1)", scale = "UCP", prefix_name = "", seed = NULL, ... )
model |
(Model (optional)) Model object to run retries on. The default is NULL. |
results |
(ModelfitResults (optional)) Connected ModelfitResults object. The default is NULL. |
number_of_candidates |
(numeric) Number of retry candidates to run. The default is 5. |
fraction |
(numeric) Determines allowed increase/decrease from initial parameter estimate. Default is 0.1 (10%) |
use_initial_estimates |
(logical) Use initial parameter estimates instead of final estimates of input model when creating candidate models. |
strictness |
(str (optional)) Strictness criteria. The default is "minimization_successful or (rounding_errors and sigdigs >= 0.1)". |
scale |
(str (optional)) Which scale to update the initial values on. Either normal scale or UCP scale. |
prefix_name |
(str (optional)) Prefix the candidate model names with given string. |
seed |
(numeric (optional)) Random number generator or seed to be used |
... |
Arguments to pass to tool |
(RetriesResults) Retries tool results object.
Run the ruvsearch tool. For more details, see :ref:ruvsearch
.
run_ruvsearch( model = NULL, results = NULL, groups = 4, p_value = 0.001, skip = NULL, max_iter = 3, dv = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", ... )
run_ruvsearch( model = NULL, results = NULL, groups = 4, p_value = 0.001, skip = NULL, max_iter = 3, dv = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs>=0.1)", ... )
model |
(Model (optional)) Pharmpy model |
results |
(ModelfitResults (optional)) Results of model |
groups |
(numeric) The number of bins to use for the time varying models |
p_value |
(numeric) The p-value to use for the likelihood ratio test |
skip |
(array(str) (optional)) A vector of models to not attempt. |
max_iter |
(numeric) Number of iterations to run (1, 2, or 3). For models with BLQ only one iteration is supported. |
dv |
(numeric (optional)) Which DV to assess the error model for. |
strictness |
(str (optional)) Strictness criteri |
... |
Arguments to pass to tool |
(RUVSearchResults) Ruvsearch tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_ruvsearch(model=model, results=results) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_ruvsearch(model=model, results=results) ## End(Not run)
Run the simulation tool.
run_simulation(model = NULL, ...)
run_simulation(model = NULL, ...)
model |
(Model (optional)) Pharmpy mode |
... |
Arguments to pass to tool |
(SimulationResult) SimulationResults object
## Not run: model <- load_example_model("pheno") model <- set_simulation(model, n=10) run_simulations(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_simulation(model, n=10) run_simulations(model) ## End(Not run)
Run the structsearch tool. For more details, see :ref:structsearch
.
run_structsearch( type, model, results, search_space = NULL, b_init = NULL, emax_init = NULL, ec50_init = NULL, met_init = NULL, extra_model = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs >= 0.1)", extra_model_results = NULL, dv_types = NULL, ... )
run_structsearch( type, model, results, search_space = NULL, b_init = NULL, emax_init = NULL, ec50_init = NULL, met_init = NULL, extra_model = NULL, strictness = "minimization_successful or (rounding_errors and sigdigs >= 0.1)", extra_model_results = NULL, dv_types = NULL, ... )
type |
(str) Type of model. Currently only 'drug_metabolite' and 'pkpd' |
model |
(Model) Search space to test |
results |
(ModelfitResults) Initial estimate for the baseline for pkpd models. |
search_space |
(str or ModelFeatures (optional)) Initial estimate for E_MAX (for pkpd models only). |
b_init |
(numeric (optional)) Initial estimate for EC_50 (for pkpd models only). |
emax_init |
(numeric (optional)) Initial estimate for MET (for pkpd models only). |
ec50_init |
(numeric (optional)) Results for the start model |
met_init |
(numeric (optional)) Pharmpy start model |
extra_model |
(Model (optional)) Optional extra Pharmpy model to use in TMDD structsearch |
strictness |
(str (optional)) Results for the extra model |
extra_model_results |
(ModelfitResults (optional)) Strictness criteria |
dv_types |
(list(str=numeric) (optional)) Dictionary of DV types for TMDD models with multiple DV |
... |
Arguments to pass to tool |
(StructSearchResult) structsearch tool result object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_structsearch(model_type='pkpd', results=results, model=model) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") run_structsearch(model_type='pkpd', results=results, model=model) ## End(Not run)
Run tool workflow
note:: This is a general function that can run any tool. There is also one function for each specific tool. Please refer to the documentation of these for more specific information.
run_tool(name, ...)
run_tool(name, ...)
name |
(str) Name of tool to run |
... |
Arguments to pass to tool |
(Results) Results object for tool
## Not run: model <- load_example_model("pheno") res <- run_tool("ruvsearch", model) ## End(Not run)
## Not run: model <- load_example_model("pheno") res <- run_tool("ruvsearch", model) ## End(Not run)
Sample individual estimates given their covariance.
sample_individual_estimates( model, individual_estimates, individual_estimates_covariance, parameters = NULL, samples_per_id = 100, seed = NULL )
sample_individual_estimates( model, individual_estimates, individual_estimates_covariance, parameters = NULL, samples_per_id = 100, seed = NULL )
model |
(Model) Pharmpy model |
individual_estimates |
(data.frame) Individual estimates to use |
individual_estimates_covariance |
(data.frame) Uncertainty covariance of the individual estimates |
parameters |
(array(str) (optional)) A vector of a subset of individual parameters to sample. Default is NULL, which means all. |
samples_per_id |
(numeric) Number of samples per individual |
seed |
(numeric (optional)) Random number generator or seed |
(data.frame) Pool of samples in a DataFrame
sample_parameters_from_covariance_matrix : Sample parameter vectors using the
uncertainty covariance matrix
sample_parameters_uniformly : Sample parameter vectors using uniform distribution
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) ie <- results$individual_estimates iec <- results$individual_estimates_covariance sample_individual_estimates(model, ie, iec, samples_per_id=2, seed=rng) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) ie <- results$individual_estimates iec <- results$individual_estimates_covariance sample_individual_estimates(model, ie, iec, samples_per_id=2, seed=rng) ## End(Not run)
Sample parameter vectors using the covariance matrix
If parameters is not provided all estimated parameters will be used
sample_parameters_from_covariance_matrix( model, parameter_estimates, covariance_matrix, force_posdef_samples = NULL, force_posdef_covmatrix = FALSE, n = 1, seed = NULL )
sample_parameters_from_covariance_matrix( model, parameter_estimates, covariance_matrix, force_posdef_samples = NULL, force_posdef_covmatrix = FALSE, n = 1, seed = NULL )
model |
(Model) Input model |
parameter_estimates |
(array) Parameter estimates to use as means in sampling |
covariance_matrix |
(data.frame) Parameter uncertainty covariance matrix |
force_posdef_samples |
(numeric (optional)) Set to how many iterations to do before forcing all samples to be positive definite. NULL is default and means never and 0 means always |
force_posdef_covmatrix |
(logical) Set to TRUE to force the input covariance matrix to be positive definite |
n |
(numeric) Number of samples |
seed |
(numeric (optional)) Random number generator |
(data.frame) A dataframe with one sample per row
sample_parameters_uniformly : Sample parameter vectors using uniform distribution
sample_individual_estimates : Sample individual estiates given their covariance
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) cov <- results$covariance_matrix pe <- results$parameter_estimates sample_parameters_from_covariance_matrix(model, pe, cov, n=3, seed=rng) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) cov <- results$covariance_matrix pe <- results$parameter_estimates sample_parameters_from_covariance_matrix(model, pe, cov, n=3, seed=rng) ## End(Not run)
Sample parameter vectors using uniform sampling
Each parameter value will be randomly sampled from a uniform distribution with the bounds being estimate ± estimate * fraction.
sample_parameters_uniformly( model, parameter_estimates, fraction = 0.1, force_posdef_samples = NULL, n = 1, seed = NULL, scale = "normal" )
sample_parameters_uniformly( model, parameter_estimates, fraction = 0.1, force_posdef_samples = NULL, n = 1, seed = NULL, scale = "normal" )
model |
(Model) Pharmpy model |
parameter_estimates |
(array) Parameter estimates for parameters to use |
fraction |
(numeric) Fraction of estimate value to use for distribution bounds |
force_posdef_samples |
(numeric (optional)) Number of samples to reject before forcing variability parameters to give positive definite covariance matrices. |
n |
(numeric) Number of samples |
seed |
(numeric (optional)) Random number generator or seed |
scale |
(str) Scale to perform sampling on. Valid options are 'normal' and 'UCP' |
(data.frame) samples
sample_parameters_from_covariance_matrix : Sample parameter vectors using the
uncertainty covariance matrix
sample_individual_estimates : Sample individual estiates given their covariance
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) pe <- results$parameter_estimates sample_parameters_uniformly(model, pe, n=3, seed=rng) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") rng <- create_rng(23) pe <- results$parameter_estimates sample_parameters_uniformly(model, pe, n=3, seed=rng) ## End(Not run)
Set an additive error model. Initial estimate for new sigma is (equation could not be rendered, see API doc on website)
The error function being applied depends on the data transformation. The table displays some examples.
+————————+—————————————-+ | Data transformation | Additive error | +========================+========================================+ | (equation could not be rendered, see API doc on website) +————————+—————————————-+ | (equation could not be rendered, see API doc on website) +————————+—————————————-+
set_additive_error_model(model, dv = NULL, data_trans = NULL, series_terms = 2)
set_additive_error_model(model, dv = NULL, data_trans = NULL, series_terms = 2)
model |
(Model) Set error model for this model |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
data_trans |
(numeric or str or Expr (optional)) A data transformation expression or NULL (default) to use the transformation specified by the model. Series expansion will be used for approximation. |
series_terms |
(numeric) Number of terms to use for the series expansion approximation for data transformation. |
(Model) Pharmpy model object
set_proportional_error_model : Proportional error model
set_combined_error_model : Combined error model
## Not run: model <- load_example_model("pheno") model$statements$find_assignment("Y") model <- set_additive_error_model(model) model$statements$find_assignment("Y") model <- load_example_model("pheno") model$statements$find_assignment("Y") model <- set_additive_error_model(model, data_trans="log(Y)") model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements$find_assignment("Y") model <- set_additive_error_model(model) model$statements$find_assignment("Y") model <- load_example_model("pheno") model$statements$find_assignment("Y") model <- set_additive_error_model(model, data_trans="log(Y)") model$statements$find_assignment("Y") ## End(Not run)
Create baseline effect model.
Currently implemented baseline effects are:
Constant baseline effect (const):
(equation could not be rendered, see API doc on website)
set_baseline_effect(model, expr = "const")
set_baseline_effect(model, expr = "const")
model |
(Model) Pharmpy model |
expr |
(str) Name of baseline effect function. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_baseline_effect(model, expr='const') model$statements$find_assignment("E") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_baseline_effect(model, expr='const') model$statements$find_assignment("E") ## End(Not run)
Set a combined error model. Initial estimates for new sigmas are (equation could not be rendered, see API doc on website) proportional and 0.09 for additive.
The error function being applied depends on the data transformation.
+————————+—————————————————–+ | Data transformation | Combined error | +========================+=====================================================+ | (equation could not be rendered, see API doc on website) +————————+—————————————————–+ | (equation could not be rendered, see API doc on website) +————————+—————————————————–+
set_combined_error_model(model, dv = NULL, data_trans = NULL)
set_combined_error_model(model, dv = NULL, data_trans = NULL)
model |
(Model) Set error model for this model |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
data_trans |
(numeric or str or Expr (optional)) A data transformation expression or NULL (default) to use the transformation specified by the model. |
(Model) Pharmpy model object
set_additive_error_model : Additive error model
set_proportional_error_model: Proportional error model
## Not run: model <- remove_error_model(load_example_model("pheno")) model <- set_combined_error_model(model) model$statements$find_assignment("Y") model <- remove_error_model(load_example_model("pheno")) model <- set_combined_error_model(model, data_trans="log(Y)") model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- remove_error_model(load_example_model("pheno")) model <- set_combined_error_model(model) model$statements$find_assignment("Y") model <- remove_error_model(load_example_model("pheno")) model <- set_combined_error_model(model, data_trans="log(Y)") model$statements$find_assignment("Y") ## End(Not run)
Set columns in the dataset to be covariates in the datainfo
set_covariates(model, covariates)
set_covariates(model, covariates)
model |
(Model) Pharmpy model |
covariates |
(array(str)) List of column names |
(Model) Pharmpy model object
Load the dataset given datainfo
set_dataset(model, path_or_df, datatype = NULL)
set_dataset(model, path_or_df, datatype = NULL)
model |
(Model) Pharmpy model |
path_or_df |
(str or data.frame) Dataset path or dataframe |
datatype |
(str (optional)) Type of dataset (optional) |
(Model) Pharmpy model with new dataset and updated datainfo
## Not run: model <- load_example_model("pheno") model <- unload_dataset(model) dataset_path <- model$datainfo$path model$dataset is NULL model <- set_dataset(model, dataset_path, datatype='nonmem') model$dataset ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- unload_dataset(model) dataset_path <- model$datainfo$path model$dataset is NULL model <- set_dataset(model, dataset_path, datatype='nonmem') model$dataset ## End(Not run)
Set description of model object
set_description(model, new_description)
set_description(model, new_description)
model |
(Model) Pharmpy model |
new_description |
(str) New description of model |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$description model <- set_description(model, "PHENOBARB run 2") model$description ## End(Not run)
## Not run: model <- load_example_model("pheno") model$description model <- set_description(model, "PHENOBARB run 2") model$description ## End(Not run)
Add an effect to a model.
Implemented PD models are:
Linear:
(equation could not be rendered, see API doc on website)
Emax:
(equation could not be rendered, see API doc on website)
Step effect:
(equation could not be rendered, see API doc on website)
Sigmoidal:
(equation could not be rendered, see API doc on website)
Log-linear:
(equation could not be rendered, see API doc on website)
(equation could not be rendered, see API doc on website)
set_direct_effect(model, expr)
set_direct_effect(model, expr)
model |
(Model) Pharmpy model |
expr |
(str) Name of PD effect function. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_direct_effect(model, "linear") model$statements$find_assignment("E") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_direct_effect(model, "linear") model$statements$find_assignment("E") ## End(Not run)
Dynamic transform both sides
set_dtbs_error_model(model, fix_to_log = FALSE)
set_dtbs_error_model(model, fix_to_log = FALSE)
model |
(Model) Pharmpy model |
fix_to_log |
(logical) Set to TRUE to fix lambda and zeta to 0, i.e. emulating log-transformed data |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_dtbs_error_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_dtbs_error_model(model) ## End(Not run)
Set a column to act as DVID. Replace DVID if one is already set.
set_dvid(model, name)
set_dvid(model, name)
model |
(Model) Pharmpy model |
name |
(str) Name of DVID column |
(Model) Pharmpy model object
Set estimation step
Sets estimation step for a model. Methods currently supported are: FO, FOCE, ITS, LAPLACE, IMPMAP, IMP, SAEM, BAYES
set_estimation_step(model, method, idx = 0, ...)
set_estimation_step(model, method, idx = 0, ...)
model |
(Model) Pharmpy model |
method |
(str) estimation method to change to |
idx |
(numeric) index of estimation step, default is 0 (first estimation step) |
... |
Arguments to pass to EstimationStep (such as interaction, evaluation) |
(Model) Pharmpy model object
add_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
set_evaluation_step
## Not run: model <- load_example_model("pheno") opts <- list('NITER'=1000, 'ISAMPLE'=100) model <- set_estimation_step(model, 'IMP', evaluation=TRUE, tool_options=opts) model$execution_steps[1] ## End(Not run)
## Not run: model <- load_example_model("pheno") opts <- list('NITER'=1000, 'ISAMPLE'=100) model <- set_estimation_step(model, 'IMP', evaluation=TRUE, tool_options=opts) model$execution_steps[1] ## End(Not run)
Set estimation step
Sets estimation step for a model. Methods currently supported are: FO, FOCE, ITS, LAPLACE, IMPMAP, IMP, SAEM, BAYES
set_evaluation_step(model, idx = -1)
set_evaluation_step(model, idx = -1)
model |
(Model) Pharmpy model |
idx |
(numeric) Index of estimation step, default is -1 (last estimation step) |
(Model) Pharmpy model object
set_estimation_step
add_estimation_step
remove_estimation_step
append_estimation_step_options
add_parameter_uncertainty_step
remove_parameter_uncertainty_step
## Not run: model <- load_example_model("pheno") model <- set_evaluation_step(model) model$execution_steps[1] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_evaluation_step(model) model$execution_steps[1] ## End(Not run)
Set or change to first order absorption rate.
Initial estimate for absorption rate is set to the previous rate if available, otherwise it is set to the time of first observation/2.
If multiple doses is set to the affected compartment, currently only iv+oral doses (one of each) is supported
set_first_order_absorption(model)
set_first_order_absorption(model)
model |
(Model) Model to set or change to use first order absorption rate |
(Model) Pharmpy model object
set_instantaneous_absorption
set_zero_order_absorption
## Not run: model <- load_example_model("pheno") model <- set_first_order_absorption(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_first_order_absorption(model) model$statements$ode_system ## End(Not run)
Sets elimination to first order
set_first_order_elimination(model)
set_first_order_elimination(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_zero_order_elimination
set_michaelis_menten_elimination
## Not run: model <- load_example_model("pheno") model <- set_first_order_elimination(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_first_order_elimination(model) model$statements$ode_system ## End(Not run)
Multiplies epsilons with exponential (new) etas.
Initial variance for new etas is 0.09.
set_iiv_on_ruv( model, dv = NULL, list_of_eps = NULL, same_eta = TRUE, eta_names = NULL )
set_iiv_on_ruv( model, dv = NULL, list_of_eps = NULL, same_eta = TRUE, eta_names = NULL )
model |
(Model) Pharmpy model to apply IIV on epsilons. |
dv |
(str or Expr or numeric (optional)) Name/names of epsilons to multiply with exponential etas. If NULL, all epsilons will be chosen. NULL is default. |
list_of_eps |
(array(str) or str (optional)) Boolean of whether all RUVs from input should use the same new ETA or if one ETA should be created for each RUV. TRUE is default. |
same_eta |
(logical) Custom names of new etas. Must be equal to the number epsilons or 1 if same eta. |
eta_names |
(array(str) or str (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
(Model) Pharmpy model object
set_power_on_ruv
## Not run: model <- load_example_model("pheno") model <- set_iiv_on_ruv(model) model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_iiv_on_ruv(model) model$statements$find_assignment("Y") ## End(Not run)
Set an initial condition for the ode system
If the initial condition is already set it will be updated. If the initial condition is set to zero at time zero it will be removed (since the default is 0).
set_initial_condition(model, compartment, expression, time = 0)
set_initial_condition(model, compartment, expression, time = 0)
model |
(Model) Pharmpy model |
compartment |
(str) Name of the compartment |
expression |
(numeric or str or Expr) The expression of the initial condition |
time |
(numeric or str or Expr) Time point. Default 0 |
(model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_initial_condition(model, "CENTRAL", 10) get_initial_conditions(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_initial_condition(model, "CENTRAL", 10) get_initial_conditions(model) ## End(Not run)
Update initial parameter estimate for a model
Updates initial estimates of population parameters for a model. If the new initial estimates are out of bounds or NaN this function will raise.
set_initial_estimates( model, inits, move_est_close_to_bounds = FALSE, strict = TRUE )
set_initial_estimates( model, inits, move_est_close_to_bounds = FALSE, strict = TRUE )
model |
(Model) Pharmpy model to update initial estimates |
inits |
(list(str=numeric)) Initial parameter estimates to update |
move_est_close_to_bounds |
(logical) Move estimates that are close to bounds. If correlation >0.99 the correlation will be set to 0.9, if variance is <0.001 the variance will be set to 0.01. |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
fix_parameters_to : Fixing and setting parameter initial estimates in the same function
unfix_paramaters_to : Unfixing parameters and setting a new initial estimate in the same
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") model$parameters$inits model <- set_initial_estimates(model, results$parameter_estimates) model$parameters$inits model <- load_example_model("pheno") model <- set_initial_estimates(model, {'POP_CL': 2.0}) model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") model$parameters$inits model <- set_initial_estimates(model, results$parameter_estimates) model$parameters$inits model <- load_example_model("pheno") model <- set_initial_estimates(model, {'POP_CL': 2.0}) model$parameters['POP_CL'] ## End(Not run)
Set or change to instantaneous absorption rate.
Currently lagtime together with instantaneous absorption is not supported.
set_instantaneous_absorption(model)
set_instantaneous_absorption(model)
model |
(Model) Model to set or change absorption rate |
(Model) Pharmpy model object
set_zero_order_absorption
set_first_order_absorption
## Not run: model <- load_example_model("pheno") model <- set_instantaneous_absorption(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_instantaneous_absorption(model) model$statements$ode_system ## End(Not run)
Set a dv value for lloq data records
set_lloq_data(model, value, lloq = NULL, blq = NULL)
set_lloq_data(model, value, lloq = NULL, blq = NULL)
model |
(Model) Pharmpy model object |
value |
(str or numeric or Expr) The new dv value |
lloq |
(numeric or str (optional)) Value or column name for lower limit of quantification. |
blq |
(str (optional)) Column name for below limit of quantification indicator. |
(Model) Pharmpy model object
remove_loq_data
transform_blq
## Not run: model <- load_example_model("pheno") model <- set_lloq_data(model, 0, lloq=10) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_lloq_data(model, 0, lloq=10) ## End(Not run)
Set parameter lower bounds
set_lower_bounds(model, bounds, strict = TRUE)
set_lower_bounds(model, bounds, strict = TRUE)
model |
(Model) Pharmpy model |
bounds |
(list(str=numeric)) A list of parameter bounds for parameters to change |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
set_upper_bounds : Set parameter upper bounds
unconstrain_parameters : Remove all constraints of parameters
## Not run: model <- load_example_model("pheno") model <- set_lower_bounds(model, {'POP_CL': -10}) model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_lower_bounds(model, {'POP_CL': -10}) model$parameters['POP_CL'] ## End(Not run)
Sets elimination to Michaelis-Menten.
Note that the parametrization is not the usual, but is instead using a CLMM parameter.
Initial estimate for CLMM is set to CL and KM is set to (equation could not be rendered, see API doc on website)
set_michaelis_menten_elimination(model)
set_michaelis_menten_elimination(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_first_order_elimination
set_zero_order_elimination
## Not run: model <- load_example_model("pheno") model <- set_michaelis_menten_elimination(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_michaelis_menten_elimination(model) model$statements$ode_system ## End(Not run)
Sets elimination to mixed Michaelis-Menten and first order.
Initial estimate for CLMM is set to CL/2 and KM is set to (equation could not be rendered, see API doc on website)
set_mixed_mm_fo_elimination(model)
set_mixed_mm_fo_elimination(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_first_order_elimination
set_zero_order_elimination
set_michaelis_menten_elimination
## Not run: model <- load_example_model("pheno") model <- set_mixed_mm_fo_elimination(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_mixed_mm_fo_elimination(model) model$statements$ode_system ## End(Not run)
Set name of model object
set_name(model, new_name)
set_name(model, new_name)
model |
(Model) Pharmpy model |
new_name |
(str) New name of model |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$name model <- set_name(model, "run2") model$name ## End(Not run)
## Not run: model <- load_example_model("pheno") model$name model <- set_name(model, "run2") model$name ## End(Not run)
Sets ODE solver to use for model
Recognized solvers and their corresponding NONMEM advans:
+—————————-+——————+ | Solver | NONMEM ADVAN | +============================+==================+ | CVODES | ADVAN14 | +—————————-+——————+ | DGEAR | ADVAN8 | +—————————-+——————+ | DVERK | ADVAN6 | +—————————-+——————+ | IDA | ADVAN15 | +—————————-+——————+ | LSODA | ADVAN13 | +—————————-+——————+ | LSODI | ADVAN9 | +—————————-+——————+
set_ode_solver(model, solver)
set_ode_solver(model, solver)
model |
(Model) Pharmpy model |
solver |
(str) Solver to use or NULL for no preference |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_ode_solver(model, 'LSODA') ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_ode_solver(model, 'LSODA') ## End(Not run)
Sets the number of peripheral compartments for central compartment to a specified number.
If name is set, the peripheral compartment will be added to the compartment with the specified name instead.
set_peripheral_compartments(model, n, name = NULL)
set_peripheral_compartments(model, n, name = NULL)
model |
(Model) Pharmpy model |
n |
(numeric) Number of transit compartments |
name |
(str) Name of compartment to add peripheral to. |
(Model) Pharmpy model object
add_peripheral_compartment
remove_peripheral_compartment
## Not run: model <- load_example_model("pheno") model <- set_peripheral_compartments(model, 2) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_peripheral_compartments(model, 2) model$statements$ode_system ## End(Not run)
Applies a power effect to provided epsilons. If a dependent variable is provided, then only said epsilons affecting said variable will be changed.
Initial estimates for new thetas are 1 if the error model is proportional, otherwise they are 0.1.
NOTE : If no DVs or epsilons are specified, all epsilons with the same name will be connected to the same theta. Running the function per DV will give each epsilon a specific theta.
set_power_on_ruv( model, list_of_eps = NULL, dv = NULL, lower_limit = 0.01, ipred = NULL, zero_protection = FALSE )
set_power_on_ruv( model, list_of_eps = NULL, dv = NULL, lower_limit = 0.01, ipred = NULL, zero_protection = FALSE )
model |
(Model) Pharmpy model to create block effect on. |
list_of_eps |
(str or array (optional)) Name/names of epsilons to apply power effect. If NULL, all epsilons will be used. NULL is default. |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL will change the epsilon on all occurences regardless of affected dependent variable. |
lower_limit |
(numeric (optional)) Lower limit of power (theta). NULL for no limit. |
ipred |
(str or Expr (optional)) Symbol to use as IPRED. Default is to autodetect expression for IPRED. |
zero_protection |
(logical) Set to TRUE to add code protecting from IPRED=0 |
(Model) Pharmpy model object
set_iiv_on_ruv
## Not run: model <- load_example_model("pheno") model <- set_power_on_ruv(model) model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_power_on_ruv(model) model$statements$find_assignment("Y") ## End(Not run)
Set a proportional error model. Initial estimate for new sigma is 0.09.
The error function being applied depends on the data transformation.
+————————+—————————————-+ | Data transformation | Proportional error | +========================+========================================+ | (equation could not be rendered, see API doc on website) +————————+—————————————-+ | (equation could not be rendered, see API doc on website) +————————+—————————————-+
set_proportional_error_model( model, dv = NULL, data_trans = NULL, zero_protection = TRUE )
set_proportional_error_model( model, dv = NULL, data_trans = NULL, zero_protection = TRUE )
model |
(Model) Set error model for this model |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
data_trans |
(numeric or str or Expr (optional)) A data transformation expression or NULL (default) to use the transformation specified by the model. |
zero_protection |
(logical) Set to TRUE to add code protecting from IPRED=0 |
(Model) Pharmpy model object
set_additive_error_model : Additive error model
set_combined_error_model : Combined error model
## Not run: model <- remove_error_model(load_example_model("pheno")) model <- set_proportional_error_model(model) model$statements$after_odes model <- remove_error_model(load_example_model("pheno")) model <- set_proportional_error_model( model, data_trans="log(Y)" model$statements$after_odes ## End(Not run)
## Not run: model <- remove_error_model(load_example_model("pheno")) model <- set_proportional_error_model(model) model$statements$after_odes model <- remove_error_model(load_example_model("pheno")) model <- set_proportional_error_model( model, data_trans="log(Y)" model$statements$after_odes ## End(Not run)
Set reference values for selected columns
All values for each selected column will be replaced. For dose columns only the values for dosing events will be replaced.
set_reference_values(model, refs)
set_reference_values(model, refs)
model |
(Model) Pharmpy model object |
refs |
(list(str=numeric)) Pairs of column names and reference values |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_reference_values(model, {'WGT': 0.5, 'AMT': 4.0}) model$dataset ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_reference_values(model, {'WGT': 0.5, 'AMT': 4.0}) model$dataset ## End(Not run)
Set or change to sequential zero order first order absorption rate.
Initial estimate for absorption rate is set the previous rate if available, otherwise it is set to the time of first observation/2.
Currently lagtime together with sequential zero order first order absorption is not supported.
set_seq_zo_fo_absorption(model)
set_seq_zo_fo_absorption(model)
model |
(Model) Model to set or change absorption rate |
(Model) Pharmpy model object
set_instantaneous_absorption
set_zero_order_absorption
set_first_order_absorption
## Not run: model <- load_example_model("pheno") model <- set_seq_zo_fo_absorption(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_seq_zo_fo_absorption(model) model$statements$ode_system ## End(Not run)
Change model into simulation model
set_simulation(model, n = 1, seed = 64206)
set_simulation(model, n = 1, seed = 64206)
model |
(Model) Pharmpy model |
n |
(numeric) Number of replicates |
seed |
(numeric) Random seed for the simulation |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_simulation(model, n=10, seed=1234) steps <- model$execution_steps steps[1] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_simulation(model, n=10, seed=1234) steps <- model$execution_steps steps[1] ## End(Not run)
Set a time varying error model per time cutoff
set_time_varying_error_model(model, cutoff, idv = "TIME", dv = NULL)
set_time_varying_error_model(model, cutoff, idv = "TIME", dv = NULL)
model |
(Model) Pharmpy model |
cutoff |
(numeric) A cutoff value for idv column |
idv |
(str) Time or time after dose, default is Time |
dv |
(str or Expr or numeric (optional)) Name or DVID of dependent variable. NULL for the default (first or only) |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_time_varying_error_model(model, cutoff=1.0) model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_time_varying_error_model(model, cutoff=1.0) model$statements$find_assignment("Y") ## End(Not run)
Sets target mediated drug disposition
Implemented target mediated drug disposition (TMDD) models are:
Full model
Irreversible binding approximation (IB)
Constant total receptor approximation (CR)
Irreversible binding and constant total receptor approximation (CR+IB)
Quasi steady-state approximation (QSS)
Wagner
Michaelis-Menten approximation (MMAPP)
set_tmdd(model, type, dv_types = NULL)
set_tmdd(model, type, dv_types = NULL)
model |
(Model) Pharmpy model |
type |
(str) Type of TMDD model |
dv_types |
(list(str=numeric) (optional)) Dictionary of DV types for TMDD models with multiple DVs (e.g. dv_types = list('drug' = 1, 'target'= 2)). Default is NULL which means that all observations are treated as drug observations. For dv = 1 the only allowed keys are 'drug' and 'drug_tot'. If no DV for drug is specified then (free) drug will have dv = 1. |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_tmdd(model, "full") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_tmdd(model, "full") ## End(Not run)
Set the number of transit compartments of model.
Initial estimate for absorption rate is set the previous rate if available, otherwise it is set to the time of first observation/2.
set_transit_compartments(model, n, keep_depot = TRUE)
set_transit_compartments(model, n, keep_depot = TRUE)
model |
(Model) Pharmpy model |
n |
(numeric) Number of transit compartments |
keep_depot |
(logical) FALSE to convert depot compartment into a transit compartment |
(Model) Pharmpy model object
add_lag_time
## Not run: model <- load_example_model("pheno") model <- set_transit_compartments(model, 3) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_transit_compartments(model, 3) model$statements$ode_system ## End(Not run)
Set parameter upper bounds
set_upper_bounds(model, bounds, strict = TRUE)
set_upper_bounds(model, bounds, strict = TRUE)
model |
(Model) Pharmpy model |
bounds |
(list(str=numeric)) A list of parameter bounds for parameters to change |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
set_lower_bounds : Set parameter lower bounds
unconstrain_parameters : Remove all constraints of parameters
## Not run: model <- load_example_model("pheno") model <- set_upper_bounds(model, list('POP_CL'=10)) model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_upper_bounds(model, list('POP_CL'=10)) model$parameters['POP_CL'] ## End(Not run)
Encode error model with one epsilon and W as weight
set_weighted_error_model(model)
set_weighted_error_model(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
use_thetas_for_error_stdev : Use thetas to estimate error
## Not run: model <- load_example_model("pheno") model <- set_weighted_error_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_weighted_error_model(model) ## End(Not run)
Set or change to zero order absorption rate.
Initial estimate for absorption rate is set the previous rate if available, otherwise it is set to the time of first observation/2.
set_zero_order_absorption(model)
set_zero_order_absorption(model)
model |
(Model) Model to set or change to first order absorption rate |
(Model) Pharmpy model object
set_instantaneous_absorption
set_first_order_absorption
## Not run: model <- load_example_model("pheno") model <- set_zero_order_absorption(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_zero_order_absorption(model) model$statements$ode_system ## End(Not run)
Sets elimination to zero order.
Initial estimate for KM is set to 1% of smallest observation.
set_zero_order_elimination(model)
set_zero_order_elimination(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_first_order_elimination
set_michaelis_menten_elimination
## Not run: model <- load_example_model("pheno") model <- set_zero_order_elimination(model) model$statements$ode_system ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_zero_order_elimination(model) model$statements$ode_system ## End(Not run)
Set a zero order input for the ode system
If the zero order input is already set it will be updated.
set_zero_order_input(model, compartment, expression)
set_zero_order_input(model, compartment, expression)
model |
(Model) Pharmpy model |
compartment |
(str) Name of the compartment |
expression |
(numeric or str or Expr) The expression of the zero order input |
(model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model <- set_zero_order_input(model, "CENTRAL", 10) get_zero_order_inputs(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- set_zero_order_input(model, "CENTRAL", 10) get_zero_order_inputs(model) ## End(Not run)
Simplify expression given constraints in model
simplify_expression(model, expr)
simplify_expression(model, expr)
model |
(Model) Pharmpy model object |
expr |
(str or numeric or Expr) Expression to simplify |
(Expression) Simplified expression
## Not run: model <- load_example_model("pheno") simplify_expression(model, "Abs(POP_CL)") ## End(Not run)
## Not run: model <- load_example_model("pheno") simplify_expression(model, "Abs(POP_CL)") ## End(Not run)
Replace ODE system with analytical solution if possible
Warnings This function can currently only handle the most simple of ODE systems.
solve_ode_system(model)
solve_ode_system(model)
model |
(Model) Pharmpy model object |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") model$statements$ode_system model <- solve_ode_system(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") model$statements$ode_system model <- solve_ode_system(model) ## End(Not run)
Splits etas following a joint distribution into separate distributions.
split_joint_distribution(model, rvs = NULL)
split_joint_distribution(model, rvs = NULL)
model |
(Model) Pharmpy model |
rvs |
(array(str) or str (optional)) Name/names of etas to separate. If NULL, all etas that are IIVs and non-fixed will become single. NULL is default. |
(Model) Pharmpy model object
create_joint_distribution : combine etas into a join distribution
## Not run: model <- load_example_model("pheno") model <- create_joint_distribution(model, c('ETA_CL', 'ETA_VC')) model$random_variables$etas model <- split_joint_distribution(model, c('ETA_CL', 'ETA_VC')) model$random_variables$etas ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- create_joint_distribution(model, c('ETA_CL', 'ETA_VC')) model$random_variables$etas model <- split_joint_distribution(model, c('ETA_CL', 'ETA_VC')) model$random_variables$etas ## End(Not run)
Summarize results of model runs
Summarize different results after fitting a model, includes runtime, ofv, and parameter estimates (with errors). If include_all_execution_steps is FALSE, only the last estimation step will be included (note that in that case, the minimization_successful value will be referring to the last estimation step, if last step is evaluation it will go backwards until it finds an estimation step that wasn't an evaluation).
summarize_modelfit_results(context, include_all_execution_steps = FALSE)
summarize_modelfit_results(context, include_all_execution_steps = FALSE)
context |
(Context) Context in which models were run |
include_all_execution_steps |
(logical) Whether to include all estimation steps, default is FALSE |
(data.frame) A DataFrame of modelfit results with model name and estmation step as index.
Transform for BLQ data
Transform a given model, methods available are m1, m3, m4, m5, m6 and m7 (1). The blq information can come from the dataset, the lloq option or a combination. Both LLOQ and BLQ columns are supported. The table below explains which columns are used for the various cases:
+————-+————-+————+——————-+—————+——————-+ | lloq option | LLOQ column | BLQ column | Used as indicator | Used as level | Note | +=============+=============+============+===================+===============+===================+ | Available | NA | NA | DV < lloq | lloq | | +————-+————-+————+——————-+—————+——————-+ | NA | Available | NA | DV < LLOQ | LLOQ | | +————-+————-+————+——————-+—————+——————-+ | NA | NA | Available | BLQ | nothing | Only for M1 and M7| +————-+————-+————+——————-+—————+——————-+ | NA | NA | NA | NA | NA | No BLQ handling | +————-+————-+————+——————-+—————+——————-+ | NA | Available | Available | BLQ | LLOQ | DV column not used| +————-+————-+————+——————-+—————+——————-+ | Available | NA | Available | BLQ | lloq | | +————-+————-+————+——————-+—————+——————-+ | Available | Available | NA | DV < lloq | lloq | Column overridden | +————-+————-+————+——————-+—————+——————-+ | Available | Available | Available | DV < lloq | lloq | Columns overridden| +————-+————-+————+——————-+—————+——————-+
BLQ observations are defined as shown in the table above. If both a BLQ and an LLOQ column exist in the dataset and no lloq is specified then all dv values in rows with BLQ = 1 are counted as BLQ observations. If instead an lloq value is specified then all rows with dv values below the lloq value are counted as BLQ observations. If no lloq is specified and no BLQ column exists in the dataset then all rows with dv values below the value specified in the DV column are counted as BLQ observations.
M1 method:
All BLQ observations are discarded.
This may affect the size of the dataset.
M3 method:
Including the probability that the BLQ observations are below the LLOQ
as part of the maximum likelihood estimation.
For more details see :ref:(1)<ref_article>
.
This method modifies the Y statement of the model (see examples below).
M4 method:
Including the probability that the BLQ observations are below the LLOQ and positive
as part of the maximum likelihood estimation.
For more details see :ref:(1)<ref_article>
.
This method modifies the Y statement of the model (see examples below).
M5 method:
All BLQ observations are replaced by level/2, where level = lloq if lloq is specified.
Else level = value specified in LLOQ column (see table above).
This method may change entries in the dataset.
M6 method:
Every BLQ observation in a consecutive series of BLQ observations is discarded except for the first one.
The remaining BLQ observations are replaced by level/2, where level = lloq if lloq is specified.
Else level = value specified in LLOQ column (see table above).
This method may change entries in the dataset as well as the size of the dataset.
M7 method:
All BLQ observations are replaced by 0.
This method may change entries in the dataset.
Current limitations of the m3 and m4 method:
Does not support covariance between epsilons
Supports additive, proportional, combined, and power error model
_ref_article:
(1) Beal SL. Ways to fit a PK model with some data below the quantification limit. J Pharmacokinet Pharmacodyn. 2001 Oct;28(5):481-504. doi: 10.1023/a:1012299115260. Erratum in: J Pharmacokinet Pharmacodyn 2002 Jun;29(3):309. PMID: 11768292.
transform_blq(model, method = "m4", lloq = NULL)
transform_blq(model, method = "m4", lloq = NULL)
model |
(Model) Pharmpy model |
method |
(str) Which BLQ method to use |
lloq |
(numeric (optional)) LLOQ limit to use, if NULL Pharmpy will use the BLQ/LLOQ column in the dataset |
(Model) Pharmpy model object
remove_loq_data
set_lloq_data
## Not run: model <- load_example_model("pheno") model <- transform_blq(model, method='m4', lloq=0.1) model$statements$find_assignment("Y") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- transform_blq(model, method='m4', lloq=0.1) model$statements$find_assignment("Y") ## End(Not run)
Applies a boxcox transformation to selected etas
Initial estimate for lambda is 0.1 with bounds (-3, 3).
transform_etas_boxcox(model, list_of_etas = NULL)
transform_etas_boxcox(model, list_of_etas = NULL)
model |
(Model) Pharmpy model to apply boxcox transformation to. |
list_of_etas |
(array(str) or str (optional)) Name/names of etas to transform. If NULL, all etas will be transformed (default). |
(Model) Pharmpy model object
transform_etas_tdist
transform_etas_john_draper
## Not run: model <- load_example_model("pheno") model <- transform_etas_boxcox(model, c("ETA_CL")) model$statements$before_odes$full_expression("CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- transform_etas_boxcox(model, c("ETA_CL")) model$statements$before_odes$full_expression("CL") ## End(Not run)
Applies a John Draper transformation (1) to spelected etas
Initial estimate for lambda is 0.1 with bounds (-3, 3).
(1) John, J., Draper, N. (1980). An Alternative Family of Transformations. Journal of the Royal Statistical Society. Series C (Applied Statistics), 29(2), 190-197. doi:10.2307/2986305
transform_etas_john_draper(model, list_of_etas = NULL)
transform_etas_john_draper(model, list_of_etas = NULL)
model |
(Model) Pharmpy model to apply John Draper transformation to. |
list_of_etas |
(array(str) or str (optional)) Name/names of etas to transform. If NULL, all etas will be transformed (default). |
(Model) Pharmpy model object
transform_etas_boxcox
transform_etas_tdist
## Not run: model <- load_example_model("pheno") model <- transform_etas_john_draper(model, c("ETA_CL")) model$statements$before_odes$full_expression("CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- transform_etas_john_draper(model, c("ETA_CL")) model$statements$before_odes$full_expression("CL") ## End(Not run)
Applies a t-distribution transformation to selected etas
Initial estimate for degrees of freedom is 80 with bounds (3, 100).
transform_etas_tdist(model, list_of_etas = NULL)
transform_etas_tdist(model, list_of_etas = NULL)
model |
(Model) Pharmpy model to apply t distribution transformation to. |
list_of_etas |
(array(str) or str (optional)) Name/names of etas to transform. If NULL, all etas will be transformed (default). |
(Model) Pharmpy model object
transform_etas_boxcox
transform_etas_john_draper
## Not run: model <- load_example_model("pheno") model <- transform_etas_tdist(model, c("ETA_CL")) model$statements$before_odes$full_expression("CL") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- transform_etas_tdist(model, c("ETA_CL")) model$statements$before_odes$full_expression("CL") ## End(Not run)
Translate NM-TRAN TIME and DATE column into one TIME column
If dataset of model have special NM-TRAN TIME and DATE columns these will be translated into one single time column with time in hours.
Warnings Use this function with caution. For example reset events are currently not taken into account.
translate_nmtran_time(model)
translate_nmtran_time(model)
model |
(Model) Pharmpy model object |
(Model) Pharmpy model object
Remove all constraints from parameters
unconstrain_parameters(model, parameter_names, strict = TRUE)
unconstrain_parameters(model, parameter_names, strict = TRUE)
model |
(Model) Pharmpy model |
parameter_names |
(array(str)) Remove all constraints for the listed parameters |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
set_lower_bounds : Set parameter lower bounds
set_upper_bounds : Set parameter upper bounds
unfix_parameters : Unfix parameters
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- unconstrain_parameters(model, c('POP_CL')) model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model$parameters['POP_CL'] model <- unconstrain_parameters(model, c('POP_CL')) model$parameters['POP_CL'] ## End(Not run)
Undrop columns of model
undrop_columns(model, column_names)
undrop_columns(model, column_names)
model |
(Model) Pharmpy model object |
column_names |
(array(str) or str) List of column names or one column name to undrop |
(Model) Pharmpy model object
drop_dropped_columns : Drop all columns marked as drop
drop_columns : Drop or mark columns as dropped
## Not run: model <- load_example_model("pheno") model <- drop_columns(model, c('WGT', 'APGR'), mark=TRUE) model <- undrop_columns(model, 'WGT') ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- drop_columns(model, c('WGT', 'APGR'), mark=TRUE) model <- undrop_columns(model, 'WGT') ## End(Not run)
Unfix parameters
Unfix all listed parameters
unfix_parameters(model, parameter_names, strict = TRUE)
unfix_parameters(model, parameter_names, strict = TRUE)
model |
(Model) Pharmpy model |
parameter_names |
(array(str) or str) one parameter name or a vector of parameter names |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
unfix_paramaters_to : Unfixing parameters and setting a new initial estimate in the same
function
fix_parameters : Fix parameters
fix_or_unfix_parameters : Fix or unfix parameters (given boolean)
fix_parameters_to : Fixing and setting parameter initial estimates in the same function
unconstrain_parameters : Remove all constraints of parameters
## Not run: model <- load_example_model("pheno") model <- fix_parameters(model, c('POP_CL', 'POP_VC')) model$parameters$fix model <- unfix_parameters(model, 'POP_CL') model$parameters$fix ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- fix_parameters(model, c('POP_CL', 'POP_VC')) model$parameters$fix model <- unfix_parameters(model, 'POP_CL') model$parameters$fix ## End(Not run)
Unfix parameters to
Unfix all listed parameters to specified value/values
unfix_parameters_to(model, inits, strict = TRUE)
unfix_parameters_to(model, inits, strict = TRUE)
model |
(Model) Pharmpy model |
inits |
(list(str=numeric)) Inits for all parameters to unfix and change init |
strict |
(logical) Whether all parameters in input need to exist in the model. Default is TRUE |
(Model) Pharmpy model object
fix_parameters : Fix parameters
fix_or_unfix_parameters : Fix or unfix parameters (given boolean)
unfix_paramaters : Unfixing parameters
fix_paramaters_to : Fixing parameters and setting a new initial estimate in the same
function
## Not run: model <- load_example_model("pheno") model <- fix_parameters(model, c('POP_CL', 'POP_VC')) model$parameters$fix model <- unfix_parameters_to(model, {'POP_CL': 0.5}) model$parameters$fix model$parameters['POP_CL'] ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- fix_parameters(model, c('POP_CL', 'POP_VC')) model$parameters$fix model <- unfix_parameters_to(model, {'POP_CL': 0.5}) model$parameters$fix model$parameters['POP_CL'] ## End(Not run)
Unload the dataset from a model
unload_dataset(model)
unload_dataset(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model with dataset removed
## Not run: model <- load_example_model("pheno") model <- unload_dataset(model) model$dataset is NULL ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- unload_dataset(model) model$dataset is NULL ## End(Not run)
Update initial individual estimates for a model
Updates initial individual estimates for a model.
update_initial_individual_estimates(model, individual_estimates, force = TRUE)
update_initial_individual_estimates(model, individual_estimates, force = TRUE)
model |
(Model) Pharmpy model to update initial estimates |
individual_estimates |
(array) Individual estimates to use |
force |
(logical) Set to FALSE to only update if the model had initial individual estimates before |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") ie <- results$individual_estimates model <- update_initial_individual_estimates(model, ie) ## End(Not run)
## Not run: model <- load_example_model("pheno") results <- load_example_modelfit_results("pheno") ie <- results$individual_estimates model <- update_initial_individual_estimates(model, ie) ## End(Not run)
Use thetas to estimate standard deviation of error
use_thetas_for_error_stdev(model)
use_thetas_for_error_stdev(model)
model |
(Model) Pharmpy model |
(Model) Pharmpy model object
set_weighted_error_model : Encode error model with one epsilon and weight
Write dataset to a csv file and updates the datainfo path
write_csv(model, path = NULL, force = FALSE)
write_csv(model, path = NULL, force = FALSE)
model |
(Model) Model whose dataset to write to file |
path |
(str (optional)) Destination path. Default is to use original path with .csv suffix. |
force |
(logical) Overwrite file with same path. Default is FALSE. |
(Model) Updated model object
## Not run: model <- load_example_model("pheno") model <- write_csv(model, path="newdataset$csv") ## End(Not run)
## Not run: model <- load_example_model("pheno") model <- write_csv(model, path="newdataset$csv") ## End(Not run)
Write model code to file
write_model(model, path = "", force = TRUE)
write_model(model, path = "", force = TRUE)
model |
(Model) Pharmpy model |
path |
(str) Destination path |
force |
(logical) Force overwrite, default is TRUE |
(Model) Pharmpy model object
## Not run: model <- load_example_model("pheno") write_model(model) ## End(Not run)
## Not run: model <- load_example_model("pheno") write_model(model) ## End(Not run)
Write results object to json (or csv) file
Note that the csv-file cannot be read into a results object again.
write_results(results, path, compression = FALSE, csv = FALSE)
write_results(results, path, compression = FALSE, csv = FALSE)
results |
(Results) Pharmpy results object |
path |
(str) Path to results file |
compression |
(logical) TRUE to compress the file. Not applicable to csv file |
csv |
(logical) Save as csv file |