Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gnlmm

Fit a generalized nonlinear mixed-effect model


Description

Fit a generalized nonlinear mixed-effect model by adaptive Gaussian quadrature (AQD)

Usage

gnlmm(
  llik,
  data,
  inits,
  syspar = NULL,
  system = NULL,
  diag.xform = c("sqrt", "log", "identity"),
  ...,
  control = list()
)

gnlmm2(
  llik,
  data,
  inits,
  syspar = NULL,
  system = NULL,
  diag.xform = c("sqrt", "log", "identity"),
  ...,
  control = list()
)

Arguments

llik

log-likelihood function

data

data to be fitted

inits

initial values

syspar

function: calculation of PK parameters

system

an optional (compiled) RxODE object

diag.xform

transformation to diagonal elements of OMEGA during fitting

...

additional options

control

additional optimization options

Details

Fit a generalized nonlinear mixed-effect model by adaptive Gaussian quadrature (AGQ)

Value

gnlmm fit object

Author(s)

Wenping Wang

Examples

if (FALSE) {
llik <- function() {
  lp <- THETA[1] * x1 + THETA[2] * x2 + (x1 + x2 * THETA[3]) * ETA[1]
  p <- pnorm(lp)
  dbinom(x, m, p, log = TRUE)
}
inits <- list(THTA = c(1, 1, 1), OMGA = list(ETA[1] ~ 1))

try(gnlmm(llik, rats, inits, control = list(nAQD = 1)))

llik <- function() {
  if (group == 1) {
    lp <- THETA[1] + THETA[2] * logtstd + ETA[1]
  } else {
    lp <- THETA[3] + THETA[4] * logtstd + ETA[1]
  }
  lam <- exp(lp)
  dpois(y, lam, log = TRUE)
}
inits <- list(THTA = c(1, 1, 1, 1), OMGA = list(ETA[1] ~ 1))

fit <- try(gnlmm(llik, pump, inits,
  control = list(
    reltol.outer = 1e-4,
    optim.outer = "nmsimplex",
    nAQD = 5
  )
))



ode <- "
d/dt(depot) =-KA*depot;
d/dt(centr) = KA*depot - KE*centr;
"
sys1 <- RxODE(ode)

pars <- function() {
  CL <- exp(THETA[1] + ETA[1]) # ; if (CL>100) CL=100
  KA <- exp(THETA[2] + ETA[2]) # ; if (KA>20) KA=20
  KE <- exp(THETA[3])
  V <- CL / KE
  sig2 <- exp(THETA[4])
}
llik <- function() {
  pred <- centr / V
  dnorm(DV, pred, sd = sqrt(sig2), log = TRUE)
}
inits <- list(THTA = c(-3.22, 0.47, -2.45, 0))
inits$OMGA <- list(ETA[1]+ETA[2]~c(.027, .01, .37))

theo <- theo_md

fit <- try(gnlmm(llik, theo, inits, pars, sys1,
  control = list(trace = TRUE, nAQD = 1)
))

fit2 <- try(gnlmm2(llik, theo, inits, pars, sys1,
  control = list(trace = TRUE, nAQD = 1)
))

if (inherits(fit, "gnlmm.fit")) {
 cv <- calcCov(fit)
 cbind(fit$par[fit$nsplt == 1], sqrt(diag(cv)))
}
}

nlmixr

Nonlinear Mixed Effects Models in Population PK/PD

v2.0.4
GPL (>= 2)
Authors
Matthew Fidler [aut] (<https://orcid.org/0000-0001-8538-6691>), Yuan Xiong [aut], Rik Schoemaker [aut] (<https://orcid.org/0000-0002-7538-3005>), Justin Wilkins [aut] (<https://orcid.org/0000-0002-7099-9396>), Wenping Wang [aut, cre], Robert Leary [ctb], Mason McComb [aut] (<https://orcid.org/0000-0001-9871-8616>), Mirjam Trame [ctb], Teun Post [ctb], Richard Hooijmaijers [aut], Hadley Wickham [ctb], Dirk Eddelbuettel [cph], Johannes Pfeifer [ctb], Robert B. Schnabel [ctb], Elizabeth Eskow [ctb], Emmanuelle Comets [ctb], Audrey Lavenu [ctb], Marc Lavielle [ctb], David Ardia [cph], Daniel C. Dillon [ctb], Katharine Mullen [cph], Ben Goodrich [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.