-
Hello , I'm currently translating a nonmem model to R using mrgsolve. Thanks a lot ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @CombetR - Yes, there is. If you use the pnorm(c(-1.96, 1.96), 0, 1)
#> [1] 0.0249979 0.9750021 Created on 2024-01-10 with reprex v2.0.2 Here's how to use the plugin: https://mrgsolve.org/user-guide/plugins.html#sec-plugin-rcpp Here's how you can call this in your model: library(mrgsolve)
#>
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#>
#> filter
code <- '
$PLUGIN Rcpp
$ERROR
capture lower = R::pnorm(-1.96, 0.0, 1.0, 1, 0);
capture upper = R::pnorm( 1.96, 0.0, 1.0, 1, 0);
'
mod <- mcode("pnorm", code)
#> Building pnorm ...
#> done.
mrgsim(mod, end = 0)
#> Model: pnorm
#> Dim: 1 x 4
#> Time: 0 to 0
#> ID: 1
#> ID time lower upper
#> 1: 1 0 0.025 0.975 Created on 2024-01-10 with reprex v2.0.2 The signature for args(pnorm)
#> function (q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
#> NULL Created on 2024-01-10 with reprex v2.0.2 I think there is a vectorized version of this too; just showing you the version for doing this for a single value. |
Beta Was this translation helpful? Give feedback.
Hi @CombetR -
Yes, there is.
If you use the
Rcpp
plugin, you get access to all thed/p/q/r
functions that you would call in R. Usually we want this to call things likernorm()
, but you can callpnorm()
too:Created on 2024-01-10 with reprex v2.0.2
Here's how to use the plugin: https://mrgsolve.org/user-guide/plugins.html#sec-plugin-rcpp
Here's how you can call this in your model: