GithubHelp home page GithubHelp logo

pharmr's Introduction

CRAN status R-CMD-check

pharmr is an R package and toolkit for pharmacometrics. It consists of

  • A model abstraction as a foundation for higher level operations
  • Functions for
    • manipulation of models
    • extraction of model estimation results
    • manipulation of datasets
    • various calculations and evaluations
    • running models
    • running higher level workflows or tools

pharmr is implemented as an R wrapper to Pharmpy. It provides an R interface to all functions found in the modeling and tools modules (documented here). Each function is also available via the help-function (or ?).

Installation

Install from github

pharmr uses the package reticulate for calling Python from R. When installing pharmr, reticulate will give a prompt to set up the reticulate environment. In order to use pharmr, you need to have Python 3.9, 3.10 or 3.11.

To install pharmr and Pharmpy:

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

Sometimes it is necessary to specify which version of Python to use. To make reticulate use Python 3.9 in its environment, run the following:

Sys.setenv(RETICULATE_MINICONDA_PYTHON_VERSION="3.9")

Install from CRAN

pharmr is available on CRAN and can be installed with

install.packages("pharmr")
pharmr::install_pharmpy()

Note that pharmr and Pharmpy are under rapid development and the version on github will be a much more up to date version than the version on CRAN. Check the badges above to see the version numbers for CRAN and github.

Using pharmr

>>> library(pharmr)
>>> res <- read_modelfit_results("run1.mod")
>>> res$parameter_estimates
  THETA(1)   THETA(2)   THETA(3) OMEGA(1,1) OMEGA(2,2) SIGMA(1,1)
0.00469555 0.98425800 0.15892000 0.02935080 0.02790600 0.01324100
>>> model <- read_model("run1.mod")
>>> model$parameters
       name     value  lower    upper    fix
   THETA(1)  0.004693   0.00  1000000  False
   THETA(2)  1.009160   0.00  1000000  False
   THETA(3)  0.100000  -0.99  1000000  False
 OMEGA(1,1)  0.030963   0.00       oo  False
 OMEGA(2,2)  0.031128   0.00       oo  False
 SIGMA(1,1)  0.013086   0.00       oo  False
>>>

A simple example of reading a model, performing a simple transformation, and running the model in NONMEM:

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

pharmr's People

Contributors

stellabelin avatar github-actions[bot] avatar rikardn avatar pharmpy-dev-123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.