-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
74 lines (62 loc) · 2.67 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# nlmixr2targets
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/nlmixr2targets)](https://CRAN.R-project.org/package=nlmixr2targets)
[![R Targetopia](https://img.shields.io/badge/R_Targetopia-member-blue?style=flat&labelColor=gray)](https://wlandau.github.io/targetopia/)
[![R-CMD-check](https://github.com/nlmixr2/nlmixr2targets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nlmixr2/nlmixr2targets/actions/workflows/R-CMD-check.yaml)
[![Code_Coverage_Badge](http://codecov.io/github/nlmixr2/nlmixr2targets/coverage.svg?branch=main)](http://codecov.io/github/nlmixr2/nlmixr2targets?branch=main)
<!-- badges: end -->
The goal of nlmixr2targets is to simplify the use of the [nlmixr2](https://github.com/nlmixr2/nlmixr2) package with the [targets](https://docs.ropensci.org/targets/) package. nlmixr2targets is part of the [targetopeia](https://wlandau.github.io/targetopia/packages.html).
## Installation
When available on CRAN, you can install the released version of nlmixr2targets from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("nlmixr2targets")
```
And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("nlmixr2/nlmixr2targets")
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r example, eval=FALSE}
library(targets)
targets::tar_script({
library(nlmixr2targets)
pheno <- function() {
ini({
tcl <- log(0.008) # typical value of clearance
tv <- log(0.6) # typical value of volume
## var(eta.cl)
eta.cl + eta.v ~ c(1,
0.01, 1) ## cov(eta.cl, eta.v), var(eta.v)
# interindividual variability on clearance and volume
add.err <- 0.1 # residual variability
})
model({
cl <- exp(tcl + eta.cl) # individual value of clearance
v <- exp(tv + eta.v) # individual value of volume
ke <- cl / v # elimination rate constant
d/dt(A1) = - ke * A1 # model differential equation
cp = A1 / v # concentration in plasma
cp ~ add(add.err) # define error model
})
}
list(
tar_nlmixr(name=pheno_model, object=pheno, data=nlmixr2data::pheno_sd, est="saem")
)
})
targets::tar_make()
```