Skip to content

is there an equivalent to the PHI function of nonmem ? #1153

Answered by kylebaron
CombetR asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @CombetR -

Yes, there is.

If you use the Rcpp plugin, you get access to all the d/p/q/r functions that you would call in R. Usually we want this to call things like rnorm(), but you can call pnorm() too:

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); 
'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CombetR
Comment options

Answer selected by CombetR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants