Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boundary issue triggered when lower and upper bounds are on both sides of zero #318

Closed
billdenney opened this issue Mar 5, 2023 · 1 comment · Fixed by #321
Closed

Comments

@billdenney
Copy link
Contributor

The below estimation inaccurately indicates that tka is at the boundary. The issue is because the bounds are on both sides of zero.

library(nlmixr2)
#> Loading required package: nlmixr2data

one.compartment <- function() {
  ini({
    tka <- c(-6, -4, 2)
    tcl <- 1
    tv <- 3.45
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.sd <- 0.7
  })
  model({
    ka <- exp(tka + eta.ka)*100
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center
    cp = center / v
    cp ~ add(add.sd)
  })
}

## The fit is performed by the function nlmixr/nlmix2 specifying the model, data and estimate
fit <- nlmixr2(one.compartment, theo_sd,  est="focei", control = list(print=0))
#> rxode2 2.0.11.9000 using 8 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
#> done
#> → Calculating residuals/tables
#> ✔ done
#> → compress origData in nlmixr2 object, save 5952
#> → compress parHist in nlmixr2 object, save 2720
print(fit)
#> ── nlmixr² FOCEi (outer: nlminb) ──
#> 
#>           OBJF      AIC      BIC Log-likelihood
#> FOCEi 116.8089 373.4087 393.5883      -179.7043
#> 
#> ── Time (sec $time): ──
#> 
#>         setup table compress other
#> elapsed 0.017  0.03     0.01 3.113
#> 
#> ── Population Parameters ($parFixed or $parFixedDf): ──
#> 
#>         Est. Back-transformed BSV(CV%) Shrink(SD)%
#> tka    -4.14            0.016     69.7      1.26% 
#> tcl     1.01             2.75     26.7      3.61% 
#> tv      3.46             31.8     13.8      9.95% 
#> add.sd 0.697            0.697                     
#>  
#>   Covariance Type ($covMethod): Boundary issue; Get SEs with `getVarCov()`: "tka" "tka" 
#>   No correlations in between subject variability (BSV) matrix
#>   Full BSV covariance ($omega) or correlation ($omegaR; diagonals=SDs) 
#>   Distribution stats (mean/skewness/kurtosis/p-value) available in $shrink 
#>   Information about run found ($runInfo):
#>    • gradient problems with initial estimate; see $scaleInfo 
#>    • parameter estimate near boundary; covariance not calculated: "tka" "tka" use 'getVarCov' to calculate anyway 
#>    • last objective function was not at minimum, possible problems in optimization 
#>    • ETAs were reset to zero during optimization; (Can control by foceiControl(resetEtaP=.)) 
#>    • initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=)) 
#>   Censoring ($censInformation): No censoring
#>   Minimization message ($message):  
#>     false convergence (8) 
#>   In an ODE system, false convergence may mean "useless" evaluations were performed.
#>   See https://tinyurl.com/yyrrwkce
#>   It could also mean the convergence is poor, check results before accepting fit
#>   You may also try a good derivative free optimization:
#>     nlmixr2(...,control=list(outerOpt="bobyqa"))
#> 
#> ── Fit Data (object is a modified tibble): ──
#> # A tibble: 132 × 22
#>   ID     TIME    DV  PRED    RES   WRES IPRED   IRES  IWRES CPRED   CRES  CWRES
#>   <fct> <dbl> <dbl> <dbl>  <dbl>  <dbl> <dbl>  <dbl>  <dbl> <dbl>  <dbl>  <dbl>
#> 1 1      0     0.74  0     0.74   1.06   0     0.74   1.06   0     0.74   1.06 
#> 2 1      0.25  2.84  3.27 -0.434 -0.233  3.85 -1.01  -1.44   3.23 -0.392 -0.185
#> 3 1      0.57  6.57  5.85  0.725  0.293  6.79 -0.215 -0.309  5.79  0.778  0.284
#> # … with 129 more rows, and 10 more variables: eta.ka <dbl>, eta.cl <dbl>,
#> #   eta.v <dbl>, depot <dbl>, center <dbl>, ka <dbl>, cl <dbl>, v <dbl>,
#> #   tad <dbl>, dosenum <dbl>

Created on 2023-03-04 with reprex v2.0.2

@mattfidler mattfidler linked a pull request Mar 5, 2023 that will close this issue
@billdenney
Copy link
Contributor Author

I'm almost done with a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants