Title: | Nonlinear Mixed Effects Models in Population PK/PD, Extra Support Functions |
---|---|
Description: | Fit and compare nonlinear mixed-effects models in differential equations with flexible dosing information commonly seen in pharmacokinetics and pharmacodynamics (Almquist, Leander, and Jirstrand 2015 <doi:10.1007/s10928-015-9409-1>). Differential equation solving is by compiled C code provided in the 'rxode2' package (Wang, Hallow, and James 2015 <doi:10.1002/psp4.12052>). This package is for support functions like preconditioned fits <doi:10.1208/s12248-016-9866-5>, boostrap and stepwise covariate selection. |
Authors: | Matthew Fidler [aut, cre] , Vipul Mann [aut], Vishal Sarsani [aut] , Christian Bartels [ctb], Bill Denney [aut] |
Maintainer: | Matthew Fidler <[email protected]> |
License: | GPL (>= 3) |
Version: | 3.0.1.9000 |
Built: | 2024-11-21 03:01:53 UTC |
Source: | https://github.com/nlmixr2/nlmixr2extra |
Return Adaptive lasso coefficients after finding optimal t
adaptivelassoCoefficients( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, stratVar = NULL, ... )
adaptivelassoCoefficients( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, stratVar = NULL, ... )
fit |
nlmixr2 fit. |
varsVec |
character vector of variables that need to be added |
covarsVec |
character vector of covariates that need to be added |
catvarsVec |
character vector of categorical covariates that need to be added |
constraint |
theta cutoff. below cutoff then the theta will be fixed to zero. |
stratVar |
A variable to stratify on for cross-validation. |
... |
Other parameters to be passed to optimalTvaluelasso |
return data frame of final lasso coefficients
Vishal Sarsani
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2( one.cmt, d, est = "saem", control = list(print = 0) ) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Adaptive Lasso coefficients: lassoDf <- adaptivelassoCoefficients(fit, varsVec, covarsVec, catvarsVec) ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2( one.cmt, d, est = "saem", control = list(print = 0) ) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Adaptive Lasso coefficients: lassoDf <- adaptivelassoCoefficients(fit, varsVec, covarsVec, catvarsVec) ## End(Not run)
Make dummy variable cols and updated covarsVec
addCatCovariates(data, covarsVec, catcovarsVec)
addCatCovariates(data, covarsVec, catcovarsVec)
data |
data frame used in the analysis |
covarsVec |
character vector of covariates that need to be added |
catcovarsVec |
character vector of categorical covariates that need to be added |
return updated Data along with the updated covarsVec
Vishal Sarsani
Add covariate
addorremoveCovariate(ui, varName, covariate, add = TRUE)
addorremoveCovariate(ui, varName, covariate, add = TRUE)
ui |
compiled rxode2 nlmir2 model or fit |
varName |
the variable name to which the given covariate is to be added |
covariate |
the covariate that needs string to be constructed |
add |
boolean indicating if the covariate needs to be added or removed. |
Matthew Fidler, Vishal Sarsani
Return Adjusted adaptive lasso coefficients after finding optimal t
adjustedlassoCoefficients( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, stratVar = NULL, ... )
adjustedlassoCoefficients( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, stratVar = NULL, ... )
fit |
nlmixr2 fit. |
varsVec |
character vector of variables that need to be added |
covarsVec |
character vector of covariates that need to be added |
catvarsVec |
character vector of categorical covariates that need to be added |
constraint |
theta cutoff. below cutoff then the theta will be fixed to zero. |
stratVar |
A variable to stratify on for cross-validation. |
... |
Other parameters to be passed to optimalTvaluelasso |
return data frame of final lasso coefficients
Vishal Sarsani
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Adaptive Lasso coefficients: lassoDf <- adjustedlassoCoefficients(fit,varsVec,covarsVec,catvarsVec) ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Adaptive Lasso coefficients: lassoDf <- adjustedlassoCoefficients(fit,varsVec,covarsVec,catvarsVec) ## End(Not run)
Produce delta objective function for boostrap
bootplot(x, ...) ## S3 method for class 'nlmixr2FitCore' bootplot(x, ...)
bootplot(x, ...) ## S3 method for class 'nlmixr2FitCore' bootplot(x, ...)
x |
fit object |
... |
other parameters |
Fit traceplot or nothing.
Vipul Mann, Matthew L. Fidler
R Niebecker, MO Karlsson. (2013) Are datasets for NLME models large enough for a bootstrap to provide reliable parameter uncertainty distributions? PAGE 2013. https://www.page-meeting.org/?abstract=2899
Bootstrap input dataset and rerun the model to get confidence bounds and aggregated parameters
bootstrapFit( fit, nboot = 200, nSampIndiv, stratVar, stdErrType = c("perc", "sd", "se"), ci = 0.95, pvalues = NULL, restart = FALSE, plotHist = FALSE, fitName = as.character(substitute(fit)) )
bootstrapFit( fit, nboot = 200, nSampIndiv, stratVar, stdErrType = c("perc", "sd", "se"), ci = 0.95, pvalues = NULL, restart = FALSE, plotHist = FALSE, fitName = as.character(substitute(fit)) )
fit |
the nlmixr2 fit object |
nboot |
an integer giving the number of bootstrapped models to be fit; default value is 200 |
nSampIndiv |
an integer specifying the number of samples in each bootstrapped sample; default is the number of unique subjects in the original dataset |
stratVar |
Variable in the original dataset to stratify on; This is useful to distinguish between sparse and full sampling and other features you may wish to keep distinct in your bootstrap |
stdErrType |
This gives the standard error type for the
updated standard errors; The current possibilities are: |
ci |
Confidence interval level to calculate. Default is 0.95 for a 95 percent confidence interval |
pvalues |
a vector of pvalues indicating the probability of
each subject to get selected; default value is |
restart |
A boolean to try to restart an interrupted or
incomplete boostrap. By default this is |
plotHist |
A boolean indicating if a histogram plot to assess
how well the bootstrap is doing. By default this is turned off
( |
fitName |
is the fit name that is used for the name of the boostrap files. By default it is the fit provided though it could be something else. |
Nothing, called for the side effects; The original fit is updated with the bootstrap confidence bands
Vipul Mann, Matthew Fidler
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- 1; label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } fit <- nlmixr2(one.cmt, nlmixr2data::theo_sd, est = "saem", control = list(print = 0)) withr::with_tempdir({ # Run example in temp dir bootstrapFit(fit, nboot = 5, restart = TRUE) # overwrites any of the existing data or model files bootstrapFit(fit, nboot = 7) # resumes fitting using the stored data and model files # Note this resumes because the total number of bootstrap samples is not 10 bootstrapFit(fit, nboot=10) # Note the boostrap standard error and variance/covariance matrix is retained. # If you wish to switch back you can change the covariance matrix by nlmixr2est::setCov(fit, "linFim") # And change it back again nlmixr2est::setCov(fit, "boot10") # This change will affect any simulations with uncertainty in their parameters # You may also do a chi-square diagnostic plot check for the bootstrap with bootplot(fit) }) ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- 1; label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } fit <- nlmixr2(one.cmt, nlmixr2data::theo_sd, est = "saem", control = list(print = 0)) withr::with_tempdir({ # Run example in temp dir bootstrapFit(fit, nboot = 5, restart = TRUE) # overwrites any of the existing data or model files bootstrapFit(fit, nboot = 7) # resumes fitting using the stored data and model files # Note this resumes because the total number of bootstrap samples is not 10 bootstrapFit(fit, nboot=10) # Note the boostrap standard error and variance/covariance matrix is retained. # If you wish to switch back you can change the covariance matrix by nlmixr2est::setCov(fit, "linFim") # And change it back again nlmixr2est::setCov(fit, "boot10") # This change will affect any simulations with uncertainty in their parameters # You may also do a chi-square diagnostic plot check for the bootstrap with bootplot(fit) }) ## End(Not run)
Build covInfo list from varsVec and covarsVec
buildcovInfo(varsVec, covarsVec)
buildcovInfo(varsVec, covarsVec)
varsVec |
character vector of variables that need to be added |
covarsVec |
character vector of covariates that need to be added |
covInfo list of covariate info
Vishal Sarsani
Build updated from the covariate and variable vector list
buildupatedUI(ui, varsVec, covarsVec, add = TRUE, indep = FALSE)
buildupatedUI(ui, varsVec, covarsVec, add = TRUE, indep = FALSE)
ui |
compiled rxode2 nlmir2 model or fit |
varsVec |
character vector of variables that need to be added |
covarsVec |
character vector of covariates that need to be added |
add |
boolean indicating if the covariate needs to be added or removed |
indep |
a boolean indicating if the covariates should be added independently, or sequentially (append to the previous model). only applicable to adding covariate |
updated ui with added covariates
Vishal Sarsani
Control options for fixed-value likelihood profiling
fixedControl()
fixedControl()
A validated list of control options for fixed-value likelihood profiling
Other Profiling:
llpControl()
,
profile.nlmixr2FitCore()
,
profileFixed()
,
profileLlp()
,
profileNlmixr2FitCoreRet()
Stratified cross-validation fold generator function, inspired from the caret
foldgen(data, nfold = 5, stratVar = NULL)
foldgen(data, nfold = 5, stratVar = NULL)
data |
data frame used in the analysis |
nfold |
number of k-fold cross validations. Default is 5 |
stratVar |
Stratification Variable. Default is NULL and ID is used for CV |
return data.frame with the fold column attached
Vishal Sarsani, caret
d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 covarsVec <- c("WT") # Stratified cross-validation data with CMT df1 <- foldgen(d, nfold=5, stratVar="CMT") # Stratified cross-validation data with ID (individual) df2 <- foldgen(d, nfold=5, stratVar=NULL)
d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 covarsVec <- c("WT") # Stratified cross-validation data with CMT df1 <- foldgen(d, nfold=5, stratVar="CMT") # Stratified cross-validation data with ID (individual) df2 <- foldgen(d, nfold=5, stratVar=NULL)
Create Horseshoe summary posterior estimates
horseshoeSummardf(fit, covarsVec, ...)
horseshoeSummardf(fit, covarsVec, ...)
fit |
compiled rxode2 nlmir2 model fit |
covarsVec |
character vector of covariates that need to be added |
... |
other parameters passed to brm(): warmup = 1000, iter = 2000, chains = 4, cores = 4, control = list(adapt_delta = 0.99, max_treedepth = 15) |
Horse shoe Summary data frame of all covariates
Vishal Sarsani, Christian Bartels
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) covarsVec <- c("WT") # Horseshoe summary posterior estimates: #hsDf <- horseshoeSummardf(fit,covarsVec,cores=2) #brms sometimes may throw a Error in sink(type = “output”) #Issue Should be fixed by uninstalling and re-installing rstan ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) covarsVec <- c("WT") # Horseshoe summary posterior estimates: #hsDf <- horseshoeSummardf(fit,covarsVec,cores=2) #brms sometimes may throw a Error in sink(type = “output”) #Issue Should be fixed by uninstalling and re-installing rstan ## End(Not run)
Extract the equations from an nlmixr2/rxode2 model to produce a 'LaTeX' equation.
## S3 method for class 'nlmixr2FitCore' knit_print(x, ..., output = "equations") ## S3 method for class 'rxUi' knit_print(x, ...)
## S3 method for class 'nlmixr2FitCore' knit_print(x, ..., output = "equations") ## S3 method for class 'rxUi' knit_print(x, ...)
x |
The model to extract equations from |
... |
Ignored |
output |
The type of output to request (currently, just "equations") |
Return Final lasso coefficients after finding optimal t
lassoCoefficients( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, stratVar = NULL, ... )
lassoCoefficients( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, stratVar = NULL, ... )
fit |
nlmixr2 fit. |
varsVec |
character vector of variables that need to be added |
covarsVec |
character vector of covariates that need to be added |
catvarsVec |
character vector of categorical covariates that need to be added |
constraint |
theta cutoff. below cutoff then the theta will be fixed to zero |
stratVar |
A variable to stratify on for cross-validation |
... |
Other parameters to be passed to optimalTvaluelasso |
return data frame of final lasso coefficients
Vishal Sarsani
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Lasso coefficients: lassoDf <- lassoCoefficients(fit, varsVec, covarsVec, catvarsVec, constraint=1e-08, stratVar = NULL) ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Lasso coefficients: lassoDf <- lassoCoefficients(fit, varsVec, covarsVec, catvarsVec, constraint=1e-08, stratVar = NULL) ## End(Not run)
Create Lasso summary posterior estimates
lassoSummardf(fit, covarsVec, ...)
lassoSummardf(fit, covarsVec, ...)
fit |
compiled rxode2 nlmir2 model fit |
covarsVec |
character vector of covariates that need to be added |
... |
other parameters passed to brm(): warmup = 1000, iter = 2000, chains = 4, cores = 4, control = list(adapt_delta = 0.99, max_treedepth = 15) |
Horse shoe Summary data frame of all covariates
Vishal Sarsani, Christian Bartels
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) covarsVec <- c("WT") # Horseshoe summary posterior estimates: #lassoDf <- lassoSummardf(fit,covarsVec,cores=2) #brms sometimes may throw a Error in sink(type = “output”) #Issue Should be fixed by uninstalling and re-installing rstan ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) covarsVec <- c("WT") # Horseshoe summary posterior estimates: #lassoDf <- lassoSummardf(fit,covarsVec,cores=2) #brms sometimes may throw a Error in sink(type = “output”) #Issue Should be fixed by uninstalling and re-installing rstan ## End(Not run)
Control options for log-likelihood profiling
llpControl( ofvIncrease = qchisq(0.95, df = 1), rseTheta = 30, itermax = 10, ofvtol = 0.005, paramDigits = 3, extrapolateExpand = 1.5 )
llpControl( ofvIncrease = qchisq(0.95, df = 1), rseTheta = 30, itermax = 10, ofvtol = 0.005, paramDigits = 3, extrapolateExpand = 1.5 )
ofvIncrease |
The targetted change in objective function value (3.84 corresponds to a Chi-squared test with a 95% confidence interval) |
rseTheta |
The relative standard error (percent) for the model parameters. It can be missing (the default) in which case a default value of 30% will be applied. If given as a single number, it will be applied to all parameters. If given as a named vector of numbers, it will be applied to each named parameter. |
itermax |
Maximum number of likelihood profiling iterations for each bound estimated |
ofvtol |
The relative tolerance for the objective function being close
enough to the |
paramDigits |
The number of significant digits required for the parameter. When interpolation attempts to get smaller than that number of significant digits, it will stop. |
extrapolateExpand |
When extrapolating outside the range previously tested, how far should the step occur as a ratio |
A validated list of control options for log-likelihood profiling
Other Profiling:
fixedControl()
,
profile.nlmixr2FitCore()
,
profileFixed()
,
profileLlp()
,
profileNlmixr2FitCoreRet()
Function to return data of normalized covariates
normalizedData(data, covarsVec, replace = TRUE)
normalizedData(data, covarsVec, replace = TRUE)
data |
a dataframe with covariates to normalize |
covarsVec |
a list of covariate names (parameters) that need to be estimates |
replace |
replace the original covariate data with normalized data for easier updated model. |
data frame with all normalized covariates
Vishal Sarsani
d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 covarsVec <- c("WT") # Normalized covariate (replaced) df1 <- normalizedData(d,covarsVec,replace=TRUE) # Normalized covariate (without replacement) df2 <- normalizedData(d,covarsVec,replace=FALSE)
d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 covarsVec <- c("WT") # Normalized covariate (replaced) df1 <- normalizedData(d,covarsVec,replace=TRUE) # Normalized covariate (without replacement) df2 <- normalizedData(d,covarsVec,replace=FALSE)
Sample from uniform distribution by optim
optimUnisampling(xvec, N = 1000, medValue, floorT = TRUE)
optimUnisampling(xvec, N = 1000, medValue, floorT = TRUE)
xvec |
A vector of min,max values . Ex:c(10,20) |
N |
Desired number of values |
medValue |
Desired Median |
floorT |
boolean indicating whether to round up |
Samples with approx desired median.
Vishal Sarsani
# Simulate 1000 creatine clearance values with median of 71.7 within range of c(6.7,140) creatCl <- optimUnisampling(xvec=c(6.7,140), N=1000, medValue = 71.7, floorT=FALSE)
# Simulate 1000 creatine clearance values with median of 71.7 within range of c(6.7,140) creatCl <- optimUnisampling(xvec=c(6.7,140), N=1000, medValue = 71.7, floorT=FALSE)
Linearly re-parameterize the model to be less sensitive to rounding errors
preconditionFit(fit, estType = c("full", "posthoc", "none"), ntry = 10L)
preconditionFit(fit, estType = c("full", "posthoc", "none"), ntry = 10L)
fit |
A nlmixr2 fit to be preconditioned |
estType |
Once the fit has been linearly reparameterized, should a "full" estimation, "posthoc" estimation or simply a estimation of the covariance matrix "none" before the fit is updated |
ntry |
number of tries before giving up on a pre-conditioned covariance estimate |
A nlmixr2 fit object that was preconditioned to stabilize the variance/covariance calculation
Aoki Y, Nordgren R, Hooker AC. Preconditioning of Nonlinear Mixed Effects Models for Stabilisation of Variance-Covariance Matrix Computations. AAPS J. 2016;18(2):505-518. doi:10.1208/s12248-016-9866-5
Perform likelihood profiling on nlmixr2 focei fits
## S3 method for class 'nlmixr2FitCore' profile( fitted, ..., which = NULL, method = c("llp", "fixed"), control = list() )
## S3 method for class 'nlmixr2FitCore' profile( fitted, ..., which = NULL, method = c("llp", "fixed"), control = list() )
fitted |
The fit model |
... |
ignored |
which |
The parameter names to perform likelihood profiling on
( |
method |
Method to use for profiling (see the details) |
control |
Control arguments for the |
A data.frame with one column named Parameter
indicating the
parameter being fixed on that row, one column for the OFV
indicating the
OFV estimated for the model at that step, one column named profileBound
indicating the estimated value for the profile likelihood and its step
above the minimum profile likelihood value, and columns for each parameter
estimate (or fixed) in the model.
method = "llp"
The search will stop when either the OFV is within ofvtol
of the desired
OFV change or when the parameter is interpolating to more significant digits
than specified in paramDigits
. The "llp" method uses the profileLlp()
function. See its help for more details.
method = "fixed"
Estimate the OFV for specific fixed values. The "fixed" method uses the
profileFixed()
function. See its help for more details.
Other Profiling:
fixedControl()
,
llpControl()
,
profileFixed()
,
profileLlp()
,
profileNlmixr2FitCoreRet()
## Not run: # Likelihood profiling takes a long time to run each model multiple times, so # be aware that running this example may take a few minutes. oneCmt <- function() { ini({ tka <- log(1.57) tcl <- log(2.72) tv <- fixed(log(31.5)) eta.ka ~ 0.6 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv) cp <- linCmt() cp ~ add(add.sd) }) } fit <- nlmixr2( oneCmt, data = nlmixr2data::theo_sd, est="focei", control = list(print=0) ) # profile all parameters profall <- profile(fit) # profile a single parameter proftka <- profile(fit, which = "tka") ## End(Not run)
## Not run: # Likelihood profiling takes a long time to run each model multiple times, so # be aware that running this example may take a few minutes. oneCmt <- function() { ini({ tka <- log(1.57) tcl <- log(2.72) tv <- fixed(log(31.5)) eta.ka ~ 0.6 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl) v <- exp(tv) cp <- linCmt() cp ~ add(add.sd) }) } fit <- nlmixr2( oneCmt, data = nlmixr2data::theo_sd, est="focei", control = list(print=0) ) # profile all parameters profall <- profile(fit) # profile a single parameter proftka <- profile(fit, which = "tka") ## End(Not run)
Estimate the objective function values for a model while fixing defined parameter values
profileFixed(fitted, which, control = list()) profileFixedSingle(fitted, which)
profileFixed(fitted, which, control = list()) profileFixedSingle(fitted, which)
fitted |
The fit model |
which |
A data.frame with column names of parameters to fix and values of the fitted value to fix (one row only). |
control |
A list passed to |
which
with a column named OFV
added with the objective function
value of the fitted estimate fixing the parameters in the other columns
profileFixedSingle()
: Estimate the objective function value for a model
while fixing a single set of defined parameter values (for use in parameter
profiling)
Other Profiling:
fixedControl()
,
llpControl()
,
profile.nlmixr2FitCore()
,
profileLlp()
,
profileNlmixr2FitCoreRet()
Other Profiling:
fixedControl()
,
llpControl()
,
profile.nlmixr2FitCore()
,
profileLlp()
,
profileNlmixr2FitCoreRet()
Profile confidence intervals with log-likelihood profiling
profileLlp(fitted, which, control)
profileLlp(fitted, which, control)
fitted |
The fit model |
which |
Either |
control |
A list passed to |
A data.frame with columns named "Parameter" (the parameter name(s) that were fixed), OFV (the objective function value), and the current estimate for each of the parameters. In addition, if any boundary is found, the OFV increase will be indicated by the absolute value of the "profileBound" column and if that boundary is the upper or lower boundary will be indicated by the "profileBound" column being positive or negative, respectively.
Other Profiling:
fixedControl()
,
llpControl()
,
profile.nlmixr2FitCore()
,
profileFixed()
,
profileNlmixr2FitCoreRet()
Give the output data.frame for a single model for profile.nlmixr2FitCore
profileNlmixr2FitCoreRet(fitted, which, fixedVal)
profileNlmixr2FitCoreRet(fitted, which, fixedVal)
fitted |
The fit model |
which |
The parameter names to perform likelihood profiling on
( |
fixedVal |
The value that |
A data.frame with columns named "Parameter" (the parameter name(s) that were fixed), OFV (the objective function value), and the current estimate for each of the parameters. Omega values are given as their variances and covariances.
Other Profiling:
fixedControl()
,
llpControl()
,
profile.nlmixr2FitCore()
,
profileFixed()
,
profileLlp()
Regular lasso model
regularmodel( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, lassotype = c("regular", "adaptive", "adjusted"), stratVar = NULL, ... )
regularmodel( fit, varsVec, covarsVec, catvarsVec, constraint = 1e-08, lassotype = c("regular", "adaptive", "adjusted"), stratVar = NULL, ... )
fit |
nlmixr2 fit. |
varsVec |
character vector of variables that need to be added |
covarsVec |
character vector of covariates that need to be added |
catvarsVec |
character vector of categorical covariates that need to be added |
constraint |
theta cutoff. below cutoff then the theta will be fixed to zero. |
lassotype |
must be 'regular' , 'adaptive', 'adjusted' |
stratVar |
A variable to stratify on for cross-validation. |
... |
Other parameters to be passed to optimalTvaluelasso |
return fit of the selected lasso coefficients
Vishal Sarsani
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Model fit with regular lasso coefficients: lassoDf <- regularmodel(fit,varsVec,covarsVec,catvarsVec) # Model fit with adaptive lasso coefficients: lassoDf <- regularmodel(fit,varsVec,covarsVec,catvarsVec,lassotype='adaptive') # Model fit with adaptive-adjusted lasso coefficients: lassoDf <- regularmodel(fit,varsVec,covarsVec,catvarsVec, lassotype='adjusted') ## End(Not run)
## Not run: one.cmt <- function() { ini({ tka <- 0.45; label("Ka") tcl <- log(c(0, 2.7, 100)); label("Cl") tv <- 3.45; label("V") eta.ka ~ 0.6 eta.cl ~ 0.3 eta.v ~ 0.1 add.sd <- 0.7 }) model({ ka <- exp(tka + eta.ka) cl <- exp(tcl + eta.cl) v <- exp(tv + eta.v) linCmt() ~ add(add.sd) }) } d <- nlmixr2data::theo_sd d$SEX <-0 d$SEX[d$ID<=6] <-1 fit <- nlmixr2(one.cmt, d, est = "saem", control = list(print = 0)) varsVec <- c("ka","cl","v") covarsVec <- c("WT") catvarsVec <- c("SEX") # Model fit with regular lasso coefficients: lassoDf <- regularmodel(fit,varsVec,covarsVec,catvarsVec) # Model fit with adaptive lasso coefficients: lassoDf <- regularmodel(fit,varsVec,covarsVec,catvarsVec,lassotype='adaptive') # Model fit with adaptive-adjusted lasso coefficients: lassoDf <- regularmodel(fit,varsVec,covarsVec,catvarsVec, lassotype='adjusted') ## End(Not run)
This is a nlmixr2 model that is pre-run so that it can be used in
package testing and development. It is regenerated whenever
binaries of nlmixr2extra
are created. If there is a binary
incompatability between the fit objects, a simple rerun of the
installation will fix this nlmixr2 fit object.
A (modified) data frame with 132 rows and 22 columns.
Patient identifier
Time (hr)
Dependent variable (concentration)
Predictions without any between subject variability
Population Residual
Weighted Residuals under the FO assumption
Individual Predictions
Individual Residuals
Individual Weighted Residuals
Conditional Prediction under the FOCE assumption
Conditional Residuals under the FOCE assumption
Conditional Weighted Residuals under the FOCE assumption
Between subject changes for ka
Between subject changes for v
amount in the depot compartment
amount in the central compartment
Individual ka values
Individual cl values
Individual volume of distribution
Time after dose
Dose number