pharmpy.modeling Package#

Functions#

add_admid(model)

Add an admid column to the model dataset and datainfo.

add_cmt(model)

Add a CMT column to the model dataset and datainfo if not existed

add_allometry(model[, allometric_variable, ...])

Add allometric scaling of parameters

add_parameter_uncertainty_step(model, ...)

Adds parameter uncertainty step to the final estimation step

add_covariate_effect(model, parameter, ...)

Adds covariate effect to pharmpy.model.

add_estimation_step(model, method[, idx])

Add estimation step

add_effect_compartment(model, expr)

Add an effect compartment.

add_indirect_effect(model, expr[, prod])

Add indirect (turnover) effect

add_iiv(model, list_of_parameters, expression)

Adds IIVs to pharmpy.model.

add_individual_parameter(model, name)

Add an individual or pk parameter to a model

add_iov(model, occ[, list_of_parameters, ...])

Adds IOVs to pharmpy.model.

add_lag_time(model)

Add lag time to the dose compartment of model.

add_bioavailability(model[, add_parameter, ...])

Add bioavailability statement for the first dose compartment of the model.

add_metabolite(model[, drug_dvid, presystemic])

Adds a metabolite compartment to a model

add_peripheral_compartment(model[, name])

Add a peripheral distribution compartment to model

add_pk_iiv(model[, initial_estimate])

Adds IIVs to all PK parameters in pharmpy.model.

add_pd_iiv(model[, initial_estimate])

Adds IIVs to all PD parameters in pharmpy.model.

add_population_parameter(model, name, init)

Add a new population parameter to the model

add_predictions(model, pred)

Add predictions and/or residuals

add_residuals(model, res)

Add predictions and/or residuals

add_time_after_dose(model)

Calculate and add a TAD column to the dataset"

append_estimation_step_options(model, ...)

Append estimation step options

bin_observations(model, method, nbins)

Bin all observations on the independent variable

bump_model_number(model[, path])

If the model name ends in a number increase it

calculate_aic(model, likelihood)

Calculate AIC

calculate_bic(model, likelihood[, type, ...])

Calculate BIC

calculate_corr_from_cov(cov)

Calculate correlation matrix from a covariance matrix

calculate_corr_from_prec(precision_matrix)

Calculate correlation matrix from a precision matrix

calculate_cov_from_corrse(corr, se)

Calculate covariance matrix from a correlation matrix and standard errors

calculate_cov_from_prec(precision_matrix)

Calculate covariance matrix from a precision matrix

calculate_epsilon_gradient_expression(model)

Calculate the symbolic expression for the epsilon gradient

calculate_eta_gradient_expression(model)

Calculate the symbolic expression for the eta gradient

calculate_eta_shrinkage(model, ...[, sd])

Calculate eta shrinkage for each eta

calculate_individual_parameter_statistics(...)

Calculate statistics for individual parameters

calculate_individual_shrinkage(model, ...)

Calculate the individual eta-shrinkage

calculate_prec_from_corrse(corr, se)

Calculate precision matrix from a correlation matrix and standard errors

calculate_prec_from_cov(cov)

Calculate precision matrix from a covariance matrix

calculate_parameters_from_ucp(model, scale, ucps)

Scale parameter values from ucp to normal scale

calculate_pk_parameters_statistics(model, ...)

Calculate statistics for common pharmacokinetic parameters

calculate_se_from_cov(cov)

Calculate standard errors from a covariance matrix

calculate_se_from_prec(precision_matrix)

Calculate standard errors from a precision matrix

calculate_ucp_scale(model)

Calculate a scale for unconstrained parameters for a model

check_dataset(model[, dataframe, verbose])

Check dataset for consistency across a set of rules

check_high_correlations(model, cor[, limit])

Check for highly correlated parameter estimates

check_parameters_near_bounds(model, values)

Check if any estimated parameter value is close to its bounds

cleanup_model(model)

Perform various cleanups of a model

convert_model(model, to_format)

Convert model to other format

create_basic_pk_model([administration, ...])

Creates a basic pk model of given type.

create_config_template()

Create a basic config file template

create_joint_distribution(model[, rvs, ...])

Combines some or all etas into a joint distribution.

create_rng([seed])

Create a new random number generator

create_symbol(model, stem[, force_numbering])

Create a new unique variable symbol given a model

deidentify_data(df[, id_column, date_columns])

Deidentify a dataset

display_odes(model)

Displays the ordinary differential equation system

drop_columns(model, column_names[, mark])

Drop columns from the dataset or mark as dropped

drop_dropped_columns(model)

Drop columns marked as dropped from the dataset

evaluate_epsilon_gradient(model[, etas, ...])

Evaluate the numeric epsilon gradient

evaluate_eta_gradient(model[, etas, ...])

Evaluate the numeric eta gradient

evaluate_expression(model, expression[, ...])

Evaluate expression using model

evaluate_individual_prediction(model[, ...])

Evaluate the numeric individual prediction

evaluate_population_prediction(model[, ...])

Evaluate the numeric population prediction

evaluate_weighted_residuals(model[, ...])

Evaluate the weighted residuals

expand_additional_doses(model[, flag])

Expand additional doses into separate dose records

filter_dataset(model, expr)

Filter dataset according to expr and return a model with the filtered dataset.

find_clearance_parameters(model)

Find clearance parameters in model

find_volume_parameters(model)

Find volume parameters in model

fix_or_unfix_parameters(model, parameters)

Fix or unfix parameters

fix_parameters(model, parameter_names)

Fix parameters

fix_parameters_to(model, inits)

Fix parameters to

get_admid(model)

Get the admid from model dataset

get_baselines(model)

Baselines for each subject.

get_bioavailability(model)

Get bioavailability of doses for all compartments

get_central_volume_and_clearance(model)

Get the volume and clearance parameters

get_cmt(model)

Get the cmt (compartment) column from the model dataset

get_concentration_parameters_from_data(model)

Create a dataframe with concentration parameters

get_config_path()

Returns path to the user config path

get_covariate_effects(model)

Return a dictionary of all used covariates within a model

get_covariate_baselines(model)

Return a dataframe with baselines of all covariates for each id.

get_doses(model)

Get a series of all doses

get_doseid(model)

Get a DOSEID series from the dataset with an id of each dose period starting from 1

get_dv_symbol(model[, dv])

Get the symbol for a certain dvid or dv and check that it is valid

get_evid(model)

Get the evid from model dataset

get_ids(model)

Retrieve a list of all subject ids of the dataset

get_individual_parameters(model[, level, dv])

Retrieves all individual parameters in a pharmpy.model.

get_individual_prediction_expression(model)

Get the full symbolic expression for the modelled individual prediction

get_initial_conditions(model[, dosing])

Get initial conditions for the ode system

get_lag_times(model)

Get lag times for all compartments

get_mdv(model)

Get MDVs from dataset

get_model_code(model)

Get the model code of the underlying model language

get_model_covariates(model[, strings])

List of covariates used in model

get_number_of_individuals(model)

Retrieve the number of individuals in the model dataset

get_number_of_observations(model)

Retrieve the total number of observations in the model dataset

get_number_of_observations_per_individual(model)

Number of observations for each individual

get_omegas(model)

Get all omegas (variability parameters) of a model

get_observations(model[, keep_index])

Get observations from dataset

get_observation_expression(model)

Get the full symbolic expression for the observation according to the model

get_pk_parameters(model[, kind])

Retrieves PK parameters in pharmpy.model.Model.

get_pd_parameters(model)

Retrieves PD parameters in pharmpy.model.Model.

get_population_prediction_expression(model)

Get the full symbolic expression for the modelled population prediction

get_rv_parameters(model, rv)

Retrieves parameters in pharmpy.model.Model given a random variable.

get_parameter_rv(model, parameter[, var_type])

Retrieves name of random variable in pharmpy.model.Model given a parameter.

get_sigmas(model)

Get all sigmas (residual error variability parameters) of a model

get_thetas(model)

Get all thetas (structural parameters) of a model

get_unit_of(model, variable)

Derive the physical unit of a variable in the model

get_zero_order_inputs(model)

Get zero order inputs for all compartments

greekify_model(model[, named_subscripts])

Convert to using greek letters for all population parameters

has_additive_error_model(model[, dv])

Check if a model has an additive error model

has_combined_error_model(model[, dv])

Check if a model has a combined additive and proportional error model

has_covariate_effect(model, parameter, covariate)

Tests if an instance of pharmpy.model has a given covariate effect.

has_first_order_elimination(model)

Check if the model describes first order elimination

has_linear_odes(model)

Check if model has a linear ODE system

has_linear_odes_with_real_eigenvalues(model)

Check if model has a linear ode system with real eigenvalues

has_michaelis_menten_elimination(model)

Check if the model describes Michaelis-Menten elimination

has_mixed_mm_fo_elimination(model)

Check if the model describes mixed Michaelis-Menten and first order elimination

has_odes(model)

Check if model has an ODE system

has_presystemic_metabolite(model)

Checks whether a model has a presystemic metabolite

has_proportional_error_model(model[, dv])

Check if a model has a proportional error model

has_random_effect(model, parameter[, level])

Decides whether the given parameter of a pharmpy.model has a random effect.

has_zero_order_absorption(model)

Check if ode system describes a zero order absorption

has_first_order_absorption(model)

Check if ode system describes a first order absorption

has_instantaneous_absorption(model)

Check if ode system describes a instantaneous absorption

has_seq_zo_fo_absorption(model)

Check if ode system describes a sequential zero-order, first-order absorption

get_number_of_peripheral_compartments(model)

Return the number of peripherals compartments connected to the central compartment

get_number_of_transit_compartments(model)

Return the number of transit compartments in the model

has_zero_order_elimination(model)

Check if the model describes zero-order elimination

has_weighted_error_model(model)

Check if a model has a weighted error model

is_linearized(model)

Determine if a model is linearized

is_real(model, expr)

Determine if an expression is real valued given constraints of a model

list_time_varying_covariates(model)

Return a list of names of all time varying covariates

load_dataset(model)

Load the dataset given datainfo

load_example_model(name)

Load an example model

make_declarative(model)

Make the model statments declarative

mu_reference_model(model)

Convert model to use mu-referencing

omit_data(dataset_or_model, group[, ...])

Iterate over omissions of a certain group in a dataset.

plot_abs_cwres_vs_ipred(model, predictions, ...)

Plot |CWRES| vs IPRED

plot_cwres_vs_idv(model, residuals[, ...])

Plot CWRES vs idv

plot_dv_vs_ipred(model, predictions[, ...])

Plot DV vs IPRED

plot_dv_vs_pred(model, predictions[, ...])

Plot DV vs PRED

plot_individual_predictions(model, predictions)

Plot DV and predictions grouped on individuals

plot_iofv_vs_iofv(iofv1, iofv2, name1, name2)

Plot individual OFV of two models against each other

plot_transformed_eta_distributions(model, ...)

Plot transformed eta distributions for all transformed etas

plot_eta_distributions(model, ...)

Plot eta distributions for all etas

print_model_code(model)

Print the model code of the underlying model language

print_model_symbols(model)

Print all symbols defined in a model

read_dataset_from_datainfo(datainfo[, datatype])

Read a dataset given a datainfo object or path to a datainfo file

read_model(path)

Read model from file

read_model_from_string(code)

Read model from the model code in a string

rename_symbols(model, new_names)

Rename symbols in the model

remove_parameter_uncertainty_step(model)

Removes parameter uncertainty step from the final estimation step

remove_predictions(model[, to_remove])

Remove predictions and/or residuals

remove_residuals(model[, to_remove])

Remove predictions and/or residuals

remove_covariate_effect(model, parameter, ...)

Remove a covariate effect from an instance of pharmpy.model.

remove_error_model(model)

Remove error model.

remove_estimation_step(model, idx)

Remove estimation step

remove_iiv(model[, to_remove])

Removes all IIV etas given a list with eta names and/or parameter names.

remove_iov(model[, to_remove])

Removes all IOV etas given a list with eta names.

remove_bioavailability(model)

Remove bioavailability from the first dose compartment of model.

remove_lag_time(model)

Remove lag time from the dose compartment of model.

remove_loq_data(model[, lloq, uloq, blq, ...])

Remove loq data records from the dataset

remove_peripheral_compartment(model[, name])

Remove a peripheral distribution compartment from model

remove_unused_parameters_and_rvs(model)

Remove any parameters and rvs that are not used in the model statements

replace_non_random_rvs(model)

Replace all random variables that are not actually random

resample_data(dataset_or_model, group[, ...])

Iterate over resamples of a dataset.

sample_parameters_from_covariance_matrix(...)

Sample parameter vectors using the covariance matrix

sample_individual_estimates(model, ...[, ...])

Sample individual estimates given their covariance.

sample_parameters_uniformly(model, ...[, ...])

Sample parameter vectors using uniform sampling

set_additive_error_model(model[, dv, ...])

Set an additive error model.

set_baseline_effect(model[, expr])

Create baseline effect model.

set_instantaneous_absorption(model)

Set or change to instantaneous absorption rate.

set_combined_error_model(model[, dv, data_trans])

Set a combined error model.

set_covariates(model, covariates)

Set columns in the dataset to be covariates in the datainfo

set_dataset(model, path_or_df[, datatype])

Load the dataset given datainfo

set_direct_effect(model, expr)

Add an effect to a model.

set_dtbs_error_model(model[, fix_to_log])

Dynamic transform both sides

set_dvid(model, name)

Set a column to act as DVID.

set_estimation_step(model, method[, idx])

Set estimation step

set_evaluation_step(model[, idx])

Set estimation step

set_simulation(model[, n, seed])

Change model into simulation model

set_first_order_absorption(model)

Set or change to first order absorption rate.

set_first_order_elimination(model)

Sets elimination to first order

set_iiv_on_ruv(model[, dv, list_of_eps, ...])

Multiplies epsilons with exponential (new) etas.

set_initial_condition(model, compartment, ...)

Set an initial condition for the ode system

set_initial_estimates(model, inits)

Set initial estimates

set_lloq_data(model, value[, lloq, blq])

Set a dv value for lloq data records

set_lower_bounds(model, bounds)

Set parameter lower bounds

set_upper_bounds(model, bounds)

Set parameter upper bounds

set_michaelis_menten_elimination(model)

Sets elimination to Michaelis-Menten.

set_mixed_mm_fo_elimination(model)

Sets elimination to mixed Michaelis-Menten and first order.

set_name(model, new_name)

Set name of model object

set_ode_solver(model, solver)

Sets ODE solver to use for model

set_peripheral_compartments(model, n[, name])

Sets the number of peripheral compartments for central compartment to a specified number.

set_power_on_ruv(model[, list_of_eps, dv, ...])

Applies a power effect to provided epsilons.

set_proportional_error_model(model[, dv, ...])

Set a proportional error model.

set_reference_values(model, refs)

Set reference values for selected columns

set_seq_zo_fo_absorption(model)

Set or change to sequential zero order first order absorption rate.

set_time_varying_error_model(model, cutoff)

Set a time varying error model per time cutoff

set_tmdd(model, type[, dv_types])

Sets target mediated drug disposition

set_transit_compartments(model, n[, keep_depot])

Set the number of transit compartments of model.

set_weighted_error_model(model)

Encode error model with one epsilon and W as weight

set_zero_order_absorption(model)

Set or change to zero order absorption rate.

set_zero_order_elimination(model)

Sets elimination to zero order.

set_zero_order_input(model, compartment, ...)

Set a zero order input for the ode system

simplify_expression(model, expr)

Simplify expression given constraints in model

solve_ode_system(model)

Replace ODE system with analytical solution if possible

split_joint_distribution(model[, rvs])

Splits etas following a joint distribution into separate distributions.

transform_blq(model[, method, lloq])

Transform for BLQ data

transform_etas_boxcox(model[, list_of_etas])

Applies a boxcox transformation to selected etas

transform_etas_john_draper(model[, list_of_etas])

Applies a John Draper transformation [1]_ to spelected etas

transform_etas_tdist(model[, list_of_etas])

Applies a t-distribution transformation to selected etas

translate_nmtran_time(model)

Translate NM-TRAN TIME and DATE column into one TIME column

unfix_parameters(model, parameter_names)

Unfix parameters

unfix_parameters_to(model, inits)

Unfix parameters to

update_initial_individual_estimates(model, ...)

Update initial individual estimates for a model

update_inits(model, parameter_estimates[, ...])

Update initial parameter estimate for a model

use_thetas_for_error_stdev(model)

Use thetas to estimate standard deviation of error

write_csv(model[, path, force])

Write dataset to a csv file and updates the datainfo path

write_model(model[, path, force])

Write model code to file

unconstrain_parameters(model, parameter_names)

Remove all constraints from parameters

undrop_columns(model, column_names)

Undrop columns of model

unload_dataset(model)

Unload the dataset from a model

vpc_plot(model, simulations[, binning, ...])

Creates a VPC plot for a model