| Version: | 2.0.17 |
| Title: | Log-Likelihood Functions for 'rxode2' |
| Maintainer: | Matthew L. Fidler <matthew.fidler@gmail.com> |
| Depends: | R (≥ 4.0.0) |
| Suggests: | covr, testthat (≥ 3.0.0) |
| Imports: | Rcpp (≥ 1.0.8), checkmate, RcppParallel |
| Description: | Provides the log-likelihoods with gradients from 'stan' (Carpenter et al (2015), <doi:10.48550/arXiv.1509.07164>) needed for generalized log-likelihood estimation in 'nlmixr2' (Fidler et al (2019) <doi:10.1002/psp4.12445>). This is split of to reduce computational burden of recompiling 'rxode2' (Wang, Hallow and James (2016) <doi:10.1002/psp4.12052>) which runs the 'nlmixr2' models during estimation. |
| BugReports: | https://github.com/nlmixr2/rxode2ll/issues/ |
| NeedsCompilation: | yes |
| License: | GPL (≥ 3) |
| URL: | https://nlmixr2.github.io/rxode2ll/, https://github.com/nlmixr2/rxode2ll/ |
| Biarch: | true |
| LinkingTo: | Rcpp (≥ 1.0.8), RcppEigen (≥ 0.3.3.9.2), StanHeaders (≥ 2.26), BH (≥ 1.78.0.0), RcppParallel |
| Encoding: | UTF-8 |
| Language: | en-US |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| Packaged: | 2026-09-08 14:23:10 UTC; matt-fidler |
| Author: | Matthew L. Fidler |
| Repository: | CRAN |
| Date/Publication: | 2026-09-09 05:20:11 UTC |
External pointers to rxode2ll's log-likelihood functions
Description
Hands a consumer package the addresses of every rxLlik* function and its
exact derivatives, so it can call them from C/C++ without an ABI dependency
on this package.
Usage
.rxode2llPtr()
Details
R_GetCCallable() is not sufficient for that. It drops the link-time
dependency, but the consumer still compiles in a typedef'd signature and
caches a raw address: updating rxode2ll then requires the consumer to be
rebuilt, and reloading rxode2ll leaves the cached pointers dangling. This is
the same external-pointer handshake rxode2, nlmixr2est, RcppTrust and n1qn1
already use, where the consumer re-reads the list in its own .onLoad() and
therefore picks up an updated rxode2ll instead of baking one in.
The returned list is APPEND-ONLY and its order is fixed; see
inst/include/rxode2llPtrs.h, which is the matching consumer header.
Value
list of external pointers, in the order documented in
rxode2llPtrs.h
Examples
length(.rxode2llPtr())
Calculate the log likelihood of the binomial function (and its derivatives)
Description
Calculate the log likelihood of the binomial function (and its derivatives)
Usage
llikBeta(x, shape1, shape2, full = FALSE)
Arguments
x |
Observation |
shape1, shape2 |
non-negative parameters of the Beta distribution. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with
dShape1 and dShape2 that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
x <- seq(1e-4, 1 - 1e-4, length.out = 21)
llikBeta(x, 0.5, 0.5)
llikBeta(x, 1, 3, TRUE)
log likelihood of the BetaProportion distribution and its derivatives (from stan)
Description
log likelihood of the BetaProportion distribution and its derivatives (from stan)
Usage
llikBetaProportion(x, mu, kappa, full = FALSE)
Arguments
x |
Observation |
mu |
distribution parameter |
kappa |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
Calculate the log likelihood of the binomial function (and its derivatives)
Description
Calculate the log likelihood of the binomial function (and its derivatives)
Usage
llikBinom(x, size, prob, full = FALSE)
Arguments
x |
Number of successes |
size |
Size of trial |
prob |
probability of success |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the pdf value of with
dProb that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikBinom(46:54, 100, 0.5)
llikBinom(46:54, 100, 0.5, TRUE)
log likelihood of Cauchy distribution and it's derivatives (from stan)
Description
log likelihood of Cauchy distribution and it's derivatives (from stan)
Usage
llikCauchy(x, location = 0, scale = 1, full = FALSE)
Arguments
x |
Observation |
location, scale |
location and scale parameters. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with
dLocation and dScale that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
x <- seq(-3, 3, length.out = 21)
llikCauchy(x, 0, 1)
llikCauchy(x, 3, 1, full=TRUE)
log likelihood and derivatives for chi-squared distribution
Description
log likelihood and derivatives for chi-squared distribution
Usage
llikChisq(x, df, full = FALSE)
Arguments
x |
variable that is distributed by chi-squared distribution |
df |
degrees of freedom (non-negative, but can be non-integer). |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dDf
that has the derivatives with respect to the df parameter
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikChisq(1, df = 1:3, full=TRUE)
llikChisq(1, df = 6:9)
log likelihood of the DblExp distribution and its derivatives (from stan)
Description
log likelihood of the DblExp distribution and its derivatives (from stan)
Usage
llikDblExp(x, mu, sigma, full = FALSE)
Arguments
x |
Observation |
mu |
distribution parameter |
sigma |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood and derivatives for exponential distribution
Description
log likelihood and derivatives for exponential distribution
Usage
llikExp(x, rate, full = FALSE)
Arguments
x |
variable that is distributed by exponential distribution |
rate |
vector of rates. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dRate
that has the derivatives with respect to the rate parameter
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikExp(1, 1:3)
llikExp(1, 1:3, full=TRUE)
log likelihood and derivatives for F distribution
Description
log likelihood and derivatives for F distribution
Usage
llikF(x, df1, df2, full = FALSE)
Arguments
x |
variable that is distributed by f distribution |
df1, df2 |
degrees of freedom. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dDf1 and dDf2
that has the derivatives with respect to the df1/df2 parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
x <- seq(0.001, 5, length.out = 100)
llikF(x^2, 1, 5)
log likelihood of the Frechet distribution and its derivatives (from stan)
Description
log likelihood of the Frechet distribution and its derivatives (from stan)
Usage
llikFrechet(x, alpha, sigma, full = FALSE)
Arguments
x |
Observation |
alpha |
distribution parameter |
sigma |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood and derivatives for Gamma distribution
Description
log likelihood and derivatives for Gamma distribution
Usage
llikGamma(x, shape, rate, full = FALSE)
Arguments
x |
variable that is distributed by gamma distribution |
shape |
this is the distribution's shape parameter. Must be positive. |
rate |
this is the distribution's rate parameters. Must be positive. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dProb
that has the derivatives with respect to the prob parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikGamma(1, 1, 10)
log likelihood and derivatives for Geom distribution
Description
log likelihood and derivatives for Geom distribution
Usage
llikGeom(x, prob, full = FALSE)
Arguments
x |
variable distributed by a geom distribution |
prob |
probability of success in each trial. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dProb
that has the derivatives with respect to the prob parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikGeom(1:10, 0.2)
log likelihood of the Gumbel distribution and its derivatives (from stan)
Description
log likelihood of the Gumbel distribution and its derivatives (from stan)
Usage
llikGumbel(x, mu, beta, full = FALSE)
Arguments
x |
Observation |
mu |
distribution parameter |
beta |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood of the InvChisq distribution and its derivatives (from stan)
Description
log likelihood of the InvChisq distribution and its derivatives (from stan)
Usage
llikInvChisq(x, nu, full = FALSE)
Arguments
x |
Observation |
nu |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood of the InvGamma distribution and its derivatives (from stan)
Description
log likelihood of the InvGamma distribution and its derivatives (from stan)
Usage
llikInvGamma(x, alpha, beta, full = FALSE)
Arguments
x |
Observation |
alpha |
distribution parameter |
beta |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood of the Lnorm distribution and its derivatives (from stan)
Description
log likelihood of the Lnorm distribution and its derivatives (from stan)
Usage
llikLnorm(x, meanlog, sdlog, full = FALSE)
Arguments
x |
Observation |
meanlog |
distribution parameter |
sdlog |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood of the Logis distribution and its derivatives (from stan)
Description
log likelihood of the Logis distribution and its derivatives (from stan)
Usage
llikLogis(x, location, scale, full = FALSE)
Arguments
x |
Observation |
location |
distribution parameter |
scale |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
Calculate the log likelihood of the negative binomial function (and its derivatives)
Description
Calculate the log likelihood of the negative binomial function (and its derivatives)
Usage
llikNbinom(x, size, prob, full = FALSE)
Arguments
x |
Number of successes |
size |
Dispersion parameter; may be non-integer |
prob |
probability of success |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the pdf value of with
dProb that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikNbinom(46:54, 100, 0.5)
llikNbinom(46:54, 100, 0.5, TRUE)
Calculate the log likelihood of the negative binomial function (and its derivatives)
Description
Calculate the log likelihood of the negative binomial function (and its derivatives)
Usage
llikNbinomMu(x, size, mu, full = FALSE)
Arguments
x |
Number of successes |
size |
Dispersion parameter; may be non-integer |
mu |
mu parameter for negative binomial |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the pdf value of with
dProb that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikNbinomMu(46:54, 100, 40)
llikNbinomMu(46:54, 100, 40, TRUE)
Log likelihood for normal distribution
Description
Log likelihood for normal distribution
Usage
llikNorm(x, mean = 0, sd = 1, full = FALSE)
Arguments
x |
Observation |
mean |
Mean for the likelihood |
sd |
Standard deviation for the likelihood |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the pdf value of with dMean and
dSd that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikNorm(0)
llikNorm(seq(-2,2,length.out=10), full=TRUE)
log likelihood of the Pareto distribution and its derivatives (from stan)
Description
log likelihood of the Pareto distribution and its derivatives (from stan)
Usage
llikPareto(x, yMin, alpha, full = FALSE)
Arguments
x |
Observation |
yMin |
distribution parameter |
alpha |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood of the ParetoType2 distribution and its derivatives (from stan)
Description
log likelihood of the ParetoType2 distribution and its derivatives (from stan)
Usage
llikParetoType2(x, mu, lambda, alpha, full = FALSE)
Arguments
x |
Observation |
mu |
distribution parameter |
lambda |
distribution parameter |
alpha |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log-likelihood for the Poisson distribution
Description
log-likelihood for the Poisson distribution
Usage
llikPois(x, lambda, full = FALSE)
Arguments
x |
non negative integers |
lambda |
non-negative means |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the pdf value of with
dLambda that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
log likelihood of the Rayleigh distribution and its derivatives (from stan)
Description
log likelihood of the Rayleigh distribution and its derivatives (from stan)
Usage
llikRayleigh(x, sigma, full = FALSE)
Arguments
x |
Observation |
sigma |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
log likelihood of the ScaledInvChisq distribution and its derivatives (from stan)
Description
log likelihood of the ScaledInvChisq distribution and its derivatives (from stan)
Usage
llikScaledInvChisq(x, nu, sigma, full = FALSE)
Arguments
x |
Observation |
nu |
distribution parameter |
sigma |
distribution parameter |
full |
return the input parameters alongside the result |
Value
data frame with fx and the derivative of each parameter
Log likelihood of T and it's derivatives (from stan)
Description
Log likelihood of T and it's derivatives (from stan)
Usage
llikT(x, df, mean = 0, sd = 1, full = FALSE)
Arguments
x |
Observation |
df |
degrees of freedom ( |
mean |
Mean for the likelihood |
sd |
Standard deviation for the likelihood |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dDf
dMean and dSd that has the derivatives with respect to the parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
x <- seq(-3, 3, length.out = 21)
llikT(x, 7, 0, 1)
llikT(x, 15, 0, 1, full=TRUE)
log likelihood and derivatives for Unif distribution
Description
log likelihood and derivatives for Unif distribution
Usage
llikUnif(x, alpha, beta, full = FALSE)
Arguments
x |
variable distributed by a uniform distribution |
alpha |
is the lower limit of the uniform distribution |
beta |
is the upper limit of the distribution |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dProb
that has the derivatives with respect to the prob parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikUnif(1, -2, 2)
log likelihood and derivatives for Weibull distribution
Description
log likelihood and derivatives for Weibull distribution
Usage
llikWeibull(x, shape, scale, full = FALSE)
Arguments
x |
variable distributed by a Weibull distribution |
shape, scale |
shape and scale parameters, the latter defaulting to 1. |
full |
Add the data frame showing x, mean, sd as well as the fx and derivatives |
Value
data frame with fx for the log pdf value of with dProb
that has the derivatives with respect to the prob parameters at
the observation time-point
Author(s)
Matthew L. Fidler
Examples
llikWeibull(1, 1, 10)