-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
053b10e
commit a07b72c
Showing
8 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
^bad-library.md$ | ||
^pkgdown$ | ||
^.github$ | ||
^vignettes/articles$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,4 @@ Suggests: | |
xgxr, | ||
vdiffr | ||
Config/testthat/edition: 3 | ||
Config/Needs/website: rmarkdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
mlxtranGetMutate <- function(mlxtran) { | ||
.cov <- mlxtran$MODEL$COVARIATE$COVARIATE | ||
.mutate <- character(0) | ||
# Convert all covariates to factors | ||
if (!is.null(.cov)) { | ||
.cat <- .cov$cat | ||
.mutate <- paste0("dplyr::mutate(", paste(vapply(names(.cat), function(x) { | ||
paste0(x, "=factor(", x, ", labels=", deparse1(.cat[[x]]$cat), ")") | ||
}, character(1), USE.NAMES=TRUE), collapse=", "), ")") | ||
} | ||
# Add equations | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.html | ||
*.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: "Converting Monolix fit to nlmixr2 fit" | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(monolix2rx) | ||
``` | ||
### Creating a nlmixr2 compatible model | ||
|
||
Unlike `nonmem2rx`, the residuals specification can be converted more | ||
efficiently to the nlmixr2 residual syntax. | ||
|
||
## Example | ||
|
||
```{r asNonmem2Rx} | ||
library(monolix2rx) | ||
library(babelmixr2) | ||
# You use the path to the monolix mlxtran file | ||
# In this case we will us the theophylline project included in monolix2rx | ||
pkgTheo <- system.file("theo/theophylline_project.mlxtran", package="monolix2rx") | ||
# Note you have to setup monolix2rx to use the model library or save the model as a separate file | ||
mod <- monolix2rx(pkgTheo) | ||
print(mod) | ||
``` | ||
|
||
### Converting the model to a nlmixr2 fit | ||
|
||
Once you have a `rxode2()` model that: | ||
|
||
- Qualifies against the NONMEM model, | ||
|
||
- Has `nlmixr2` compatible residuals | ||
|
||
You can then convert it to a `nlmixr2` fit object with `babelmixr2`: | ||
|
||
```{r convertNlmixr2object} | ||
library(babelmixr2) | ||
fit <- as.nlmixr2(mod) | ||
# If you want you can use nlmixr2, to add cwres to this fit: | ||
fit <- addCwres(fit) | ||
library(ggplot2) | ||
ggplot(fit, aes(PRED, CWRES)) + | ||
geom_point() + rxode2::rxTheme() | ||
``` |