R/nlme_fit.R
nlme_lin_cmpt.Rd
'nlme_lin_cmpt' fits a linear one to three compartment model with either first order absorption, or i.v. bolus, or i.v. infusion. A user specifies the number of compartments, route of drug administrations, and the model parameterization. `nlmixr` supports the clearance/volume parameterization and the micro constant parameterization, with the former as the default. Specification of fixed effects, random effects and initial values follows the standard nlme notations.
nlme_lin_cmpt(
dat,
parModel,
ncmt,
oral = TRUE,
infusion = FALSE,
tlag = FALSE,
parameterization = 1,
parTrans = .getParfn(oral, ncmt, parameterization, tlag),
mcCores = 1,
...
)
nlmeLinCmpt(
dat,
parModel,
ncmt,
oral = TRUE,
infusion = FALSE,
tlag = FALSE,
parameterization = 1,
parTrans = .getParfn(oral, ncmt, parameterization, tlag),
mcCores = 1,
...
)
nlmeLinCmt(
dat,
parModel,
ncmt,
oral = TRUE,
infusion = FALSE,
tlag = FALSE,
parameterization = 1,
parTrans = .getParfn(oral, ncmt, parameterization, tlag),
mcCores = 1,
...
)
data to be fitted
list: model for fixed effects, randoms effects and initial values using nlme-type syntax.
numerical: number of compartments: 1-3
logical
logical
logical
numerical: type of parameterization, 1=clearance/volume, 2=micro-constants
function: calculation of PK parameters
number of cores used in fitting (only for Linux)
additional nlme options
A nlmixr nlme fit object
library(nlmixr)
specs <- list(fixed=lKA+lCL+lV~1, random = pdDiag(lKA+lCL~1),
start=c(lKA=0.5, lCL=-3.2, lV=-1))
fit <- nlme_lin_cmpt(theo_md, par_model=specs, ncmt=1, verbose=TRUE)
#>
#> **Iteration 1
#> LME step: Loglik: -420.4062, nlminb iterations: 1
#> reStruct parameters:
#> ID1 ID2
#> 5.434250 5.693011
#> Beginning PNLS step: .. completed fit_nlme() step.
#> PNLS step: RSS = 300.8155
#> fixed effects: 0.2384012 1.057595 3.395177
#> iterations: 7
#> Convergence crit. (must all become <= tolerance = 1e-05):
#> fixed reStruct
#> 4.025732 4.507369
#>
#> **Iteration 2
#> LME step: Loglik: -422.6508, nlminb iterations: 5
#> reStruct parameters:
#> ID1 ID2
#> 0.9829979 1.4302117
#> Beginning PNLS step: .. completed fit_nlme() step.
#> PNLS step: RSS = 300.5795
#> fixed effects: 0.2352729 1.058965 3.393164
#> iterations: 3
#> Convergence crit. (must all become <= tolerance = 1e-05):
#> fixed reStruct
#> 0.013296643 0.004640838
#>
#> **Iteration 3
#> LME step: Loglik: -422.666, nlminb iterations: 1
#> reStruct parameters:
#> ID1 ID2
#> 0.9821654 1.4298669
#> Beginning PNLS step: .. completed fit_nlme() step.
#> PNLS step: RSS = 300.5795
#> fixed effects: 0.2352729 1.058965 3.393164
#> iterations: 1
#> Convergence crit. (must all become <= tolerance = 1e-05):
#> fixed reStruct
#> 0 0
#plot(augPred(fit,level=0:1))
summary(fit)
#> Nonlinear mixed-effects model fit by maximum likelihood
#> Model: DV ~ (nlmixr::nlmeModList("user_fn"))(lCL, lV, lKA, TIME, ID)
#> AIC BIC logLik
#> 857.3319 878.7876 -422.666
#>
#> Random effects:
#> Formula: list(lKA ~ 1, lCL ~ 1)
#> Level: ID
#> Structure: Diagonal
#> lKA lCL Residual
#> StdDev: 0.399603 0.2553844 1.067033
#>
#> Fixed effects: lKA + lCL + lV ~ 1
#> Value Std.Error DF t-value p-value
#> lKA 0.235273 0.12654742 250 1.85917 0.0642
#> lCL 1.058965 0.07713563 250 13.72861 0.0000
#> lV 3.393164 0.02575930 250 131.72576 0.0000
#> Correlation:
#> lKA lCL
#> lCL -0.013
#> lV 0.263 -0.103
#>
#> Standardized Within-Group Residuals:
#> Min Q1 Med Q3 Max
#> -4.85501592 -0.40260323 0.06705234 0.43848330 3.43996200
#>
#> Number of Observations: 264
#> Number of Groups: 12