Learn R Programming

⚠️There's a newer version (1.4.0) of this package.Take me there.

pharmr is an R wrapper to Pharmpy: an open-source software package for pharmacometric modeling. It provides an R interface to all functions found in the modeling and tools modules (documented here). The documentation for each function is also available via the help-function (or ?).

For comprehensive information and documentation, see: https://pharmpy.github.io

Installation and setup

Install from CRAN

The latest stable version of pharmr is available via CRAN, and can be installed via:

install.packages("pharmr")

After installing pharmr, Pharmpy needs to be set up:

pharmr::install_pharmpy()

For a more comprehensive description of the process of setting up, see the following guide.

Install from GitHub

It is also possible to install the development version of pharmr from GitHub, with the following command:

remotes::install_github("pharmpy/pharmr", ref="main")

Pharmpy can then be installed:

pharmr::install_pharmpy()

Using pharmr

>>> library(pharmr)
>>> model <- load_example_model("pheno")
>>> model$parameters
            value  lower upper    fix
POP_CL   0.004693   0.00     ∞  False
POP_VC   1.009160   0.00     ∞  False
COVAPGR  0.100000  -0.99     ∞  False
IIV_CL   0.030963   0.00     ∞  False
IIV_VC   0.031128   0.00     ∞  False
SIGMA    0.013086   0.00     ∞  False
>>> res <- load_example_modelfit_results("pheno")
>>> res$parameter_estimates
    POP_CL     POP_VC    COVAPGR     IIV_CL     IIV_VC      SIGMA 
0.00469555 0.98425800 0.15892000 0.02935080 0.02790600 0.01324100 
>>>

A simple example of reading a model, performing a simple transformation, and running the model in NONMEM. Note that you need NONMEM installed to be able to fit the model, see the following guide on how to set up the config file.

model <- load_example_model('pheno') %>%
  add_peripheral_compartment() %>%
  fit()

Copy Link

Version

Install

install.packages('pharmr')

Monthly Downloads

292

Version

1.0.1

License

LGPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Rikard Nordgren

Last Published

June 17th, 2024

Functions in pharmr (1.0.1)

add_iiv

add_iiv
add_cmt

add_cmt
add_indirect_effect

add_indirect_effect
add_admid

add_admid
add_estimation_step

add_estimation_step
add_effect_compartment

add_effect_compartment
add_parameter_uncertainty_step

add_parameter_uncertainty_step
add_bioavailability

add_bioavailability
add_individual_parameter

add_individual_parameter
add_residuals

add_residuals
add_iov

add_iov
add_time_after_dose

add_time_after_dose
add_peripheral_compartment

add_peripheral_compartment
add_population_parameter

add_population_parameter
add_pk_iiv

add_pk_iiv
add_predictions

add_predictions
calculate_bic

calculate_bic
check_dataset

check_dataset
calculate_ucp_scale

calculate_ucp_scale
drop_dropped_columns

drop_dropped_columns
bump_model_number

bump_model_number
add_pd_iiv

add_pd_iiv
calculate_corr_from_cov

calculate_corr_from_cov
calculate_parameters_from_ucp

calculate_parameters_from_ucp
evaluate_epsilon_gradient

evaluate_epsilon_gradient
calculate_pk_parameters_statistics

calculate_pk_parameters_statistics
add_covariate_effect

add_covariate_effect
convert_model

convert_model
display_odes

display_odes
create_basic_pk_model

create_basic_pk_model
drop_columns

drop_columns
calculate_aic

calculate_aic
add_allometry

add_allometry
get_ids

get_ids
add_derivative

add_derivative
get_individual_parameters

get_individual_parameters
get_number_of_individuals

get_number_of_individuals
calculate_eta_gradient_expression

calculate_eta_gradient_expression
get_number_of_observations

get_number_of_observations
calculate_cov_from_corrse

calculate_cov_from_corrse
calculate_corr_from_prec

calculate_corr_from_prec
calculate_eta_shrinkage

calculate_eta_shrinkage
calculate_prec_from_cov

calculate_prec_from_cov
calculate_prec_from_corrse

calculate_prec_from_corrse
add_lag_time

add_lag_time
get_observations

get_observations
check_pharmpy

Checks version of Pharmpy/pharmr
cleanup_model

cleanup_model
get_omegas

get_omegas
add_metabolite

add_metabolite
calculate_cov_from_prec

calculate_cov_from_prec
get_zero_order_inputs

get_zero_order_inputs
greekify_model

greekify_model
check_high_correlations

check_high_correlations
calculate_epsilon_gradient_expression

calculate_epsilon_gradient_expression
check_parameters_near_bounds

check_parameters_near_bounds
find_volume_parameters

find_volume_parameters
filter_dataset

filter_dataset
find_clearance_parameters

find_clearance_parameters
create_config_template

create_config_template
has_zero_order_absorption

has_zero_order_absorption
create_symbol

create_symbol
deidentify_data

deidentify_data
get_central_volume_and_clearance

get_central_volume_and_clearance
fit

fit
get_baselines

get_baselines
evaluate_weighted_residuals

evaluate_weighted_residuals
get_cmt

get_cmt
get_bioavailability

get_bioavailability
append_estimation_step_options

append_estimation_step_options
fix_parameters_to

fix_parameters_to
expand_additional_doses

expand_additional_doses
evaluate_individual_prediction

evaluate_individual_prediction
create_joint_distribution

create_joint_distribution
evaluate_population_prediction

evaluate_population_prediction
bin_observations

bin_observations
get_admid

get_admid
get_doseid

get_doseid
get_covariate_baselines

get_covariate_baselines
get_lag_times

get_lag_times
get_observation_expression

get_observation_expression
get_concentration_parameters_from_data

get_concentration_parameters_from_data
get_doses

get_doses
get_number_of_transit_compartments

get_number_of_transit_compartments
get_covariate_effects

get_covariate_effects
has_zero_order_elimination

has_zero_order_elimination
get_mdv

get_mdv
get_number_of_observations_per_individual

get_number_of_observations_per_individual
get_parameter_rv

get_parameter_rv
get_config_path

get_config_path
get_pd_parameters

get_pd_parameters
get_number_of_peripheral_compartments

get_number_of_peripheral_compartments
get_rv_parameters

get_rv_parameters
get_sigmas

get_sigmas
get_dv_symbol

get_dv_symbol
get_evid

get_evid
has_covariate_effect

has_covariate_effect
has_first_order_absorption

has_first_order_absorption
get_model_code

get_model_code
get_model_covariates

get_model_covariates
has_odes

has_odes
has_seq_zo_fo_absorption

has_seq_zo_fo_absorption
has_weighted_error_model

has_weighted_error_model
plot_dv_vs_ipred

plot_dv_vs_ipred
plot_dv_vs_pred

plot_dv_vs_pred
calculate_individual_parameter_statistics

calculate_individual_parameter_statistics
calculate_individual_shrinkage

calculate_individual_shrinkage
get_thetas

get_thetas
remove_covariate_effect

remove_covariate_effect
calculate_se_from_cov

calculate_se_from_cov
get_unit_of

get_unit_of
remove_derivative

remove_derivative
remove_lag_time

remove_lag_time
remove_loq_data

remove_loq_data
has_first_order_elimination

has_first_order_elimination
run_amd

run_amd
has_instantaneous_absorption

has_instantaneous_absorption
has_proportional_error_model

has_proportional_error_model
is_strictness_fulfilled

is_strictness_fulfilled
calculate_se_from_prec

calculate_se_from_prec
has_random_effect

has_random_effect
has_presystemic_metabolite

has_presystemic_metabolite
load_dataset

load_dataset
load_example_model

load_example_model
has_additive_error_model

has_additive_error_model
create_report

create_report
list_time_varying_covariates

list_time_varying_covariates
has_combined_error_model

has_combined_error_model
is_linearized

is_linearized
create_rng

create_rng
predict_influential_individuals

predict_influential_individuals
plot_vpc

plot_vpc
is_real

is_real
evaluate_eta_gradient

evaluate_eta_gradient
plot_abs_cwres_vs_ipred

plot_abs_cwres_vs_ipred
remove_iiv

remove_iiv
remove_iov

remove_iov
install_pharmpy

Install Pharmpy
mu_reference_model

mu_reference_model
evaluate_expression

evaluate_expression
install_pharmpy_devel

Install Pharmpy (with specified version)
remove_parameter_uncertainty_step

remove_parameter_uncertainty_step
fix_or_unfix_parameters

fix_or_unfix_parameters
plot_iofv_vs_iofv

plot_iofv_vs_iofv
omit_data

omit_data
remove_peripheral_compartment

remove_peripheral_compartment
plot_transformed_eta_distributions

plot_transformed_eta_distributions
predict_outliers

predict_outliers
predict_influential_outliers

predict_influential_outliers
fix_parameters

fix_parameters
remove_error_model

remove_error_model
run_structsearch

run_structsearch
remove_estimation_step

remove_estimation_step
run_tool

run_tool
print_model_symbols

print_model_symbols
set_direct_effect

set_direct_effect
run_bootstrap

run_bootstrap
run_retries

run_retries
set_covariates

set_covariates
run_modelsearch

run_modelsearch
set_dtbs_error_model

set_dtbs_error_model
set_dataset

set_dataset
set_initial_condition

set_initial_condition
print_pharmpy_version

Print pharmpy version
print_fit_summary

print_fit_summary
plot_cwres_vs_idv

plot_cwres_vs_idv
set_michaelis_menten_elimination

set_michaelis_menten_elimination
set_lower_bounds

set_lower_bounds
remove_predictions

remove_predictions
set_reference_values

set_reference_values
print_model_code

print_model_code
set_seq_zo_fo_absorption

set_seq_zo_fo_absorption
set_initial_estimates

set_initial_estimates
run_iivsearch

run_iivsearch
remove_residuals

remove_residuals
read_model_from_string

read_model_from_string
read_modelfit_results

read_modelfit_results
replace_non_random_rvs

replace_non_random_rvs
set_zero_order_absorption

set_zero_order_absorption
solve_ode_system

solve_ode_system
set_zero_order_elimination

set_zero_order_elimination
transform_etas_john_draper

transform_etas_john_draper
transform_etas_boxcox

transform_etas_boxcox
run_covsearch

run_covsearch
resample_data

resample_data
run_estmethod

run_estmethod
transform_blq

transform_blq
summarize_modelfit_results

summarize_modelfit_results
use_thetas_for_error_stdev

use_thetas_for_error_stdev
split_joint_distribution

split_joint_distribution
write_csv

write_csv
retrieve_models

retrieve_models
run_linearize

run_linearize
run_modelfit

run_modelfit
run_iovsearch

run_iovsearch
sample_parameters_uniformly

sample_parameters_uniformly
sample_individual_estimates

sample_individual_estimates
sample_parameters_from_covariance_matrix

sample_parameters_from_covariance_matrix
get_individual_prediction_expression

get_individual_prediction_expression
run_allometry

run_allometry
get_initial_conditions

get_initial_conditions
set_evaluation_step

set_evaluation_step
set_additive_error_model

set_additive_error_model
set_baseline_effect

set_baseline_effect
run_ruvsearch

run_ruvsearch
run_simulation

run_simulation
get_pk_parameters

get_pk_parameters
set_instantaneous_absorption

set_instantaneous_absorption
get_population_prediction_expression

get_population_prediction_expression
set_first_order_absorption

set_first_order_absorption
set_lloq_data

set_lloq_data
set_proportional_error_model

set_proportional_error_model
set_power_on_ruv

set_power_on_ruv
set_combined_error_model

set_combined_error_model
set_simulation

set_simulation
set_tmdd

set_tmdd
set_first_order_elimination

set_first_order_elimination
set_transit_compartments

set_transit_compartments
unfix_parameters

unfix_parameters
set_iiv_on_ruv

set_iiv_on_ruv
set_mixed_mm_fo_elimination

set_mixed_mm_fo_elimination
unfix_parameters_to

unfix_parameters_to
has_linear_odes

has_linear_odes
has_linear_odes_with_real_eigenvalues

has_linear_odes_with_real_eigenvalues
has_michaelis_menten_elimination

has_michaelis_menten_elimination
set_name

set_name
set_time_varying_error_model

set_time_varying_error_model
write_model

write_model
write_results

write_results
has_mixed_mm_fo_elimination

has_mixed_mm_fo_elimination
set_upper_bounds

set_upper_bounds
set_weighted_error_model

set_weighted_error_model
transform_etas_tdist

transform_etas_tdist
load_example_modelfit_results

load_example_modelfit_results
make_declarative

make_declarative
plot_eta_distributions

plot_eta_distributions
translate_nmtran_time

translate_nmtran_time
read_dataset_from_datainfo

read_dataset_from_datainfo
read_model

read_model
plot_individual_predictions

plot_individual_predictions
read_results

read_results
remove_bioavailability

remove_bioavailability
remove_unused_parameters_and_rvs

remove_unused_parameters_and_rvs
rename_symbols

rename_symbols
reset_index

Reset index
reset_indices_results

Reset result indices
set_ode_solver

set_ode_solver
set_estimation_step

set_estimation_step
set_dvid

set_dvid
set_peripheral_compartments

set_peripheral_compartments
set_zero_order_input

set_zero_order_input
unconstrain_parameters

unconstrain_parameters
simplify_expression

simplify_expression
undrop_columns

undrop_columns
update_initial_individual_estimates

update_initial_individual_estimates
unload_dataset

unload_dataset