Closed mattfidler closed 2 months ago
Is that to remove correlation between a and b without changing the estimates?
Is that to remove correlation between a and b without changing the estimates?
diag(a, b)
will remove all correlations that include a
or b
. If needed it will re-order the matrix.
For example:
library(rxode2)
#> rxode2 3.0.0 using 8 threads (see ?getRxThreads)
#> no cache: create with `rxCreateCache()`
mod2 <- function() {
ini({
lka ~ 0.45
lcl ~ c(0.01, 1)
lvc ~ c(-0.01, 0.01, 3.45)
lfun ~ c(-0.1, 0.1, 0.01, 4)
})
model({
ka <- exp(lka)
cl <- exp(lcl)
vc <- exp(lvc)
kel <- cl / vc
d/dt(depot) <- -ka*depot
d/dt(central) <- ka*depot-kel*central
cp <- central / vc + lfun
})
}
# Will reorder
mod2 %>% ini(diag(lcl, lvc))
#> ℹ remove covariance `(lka,lcl)`
#> ℹ remove covariance `(lcl,lvc)`
#> ℹ remove covariance `(lcl,lfun)`
#> ℹ remove covariance `(lka,lvc)`
#> ℹ remove covariance `(lvc,lfun)`
#> ── rxode2-based free-form 2-cmt ODE model ──────────────────────────────────────
#> ── Initalization: ──
#>
#> Omega ($omega):
#> lfun lka lvc lcl
#> lfun 4.0 -0.10 0.00 0
#> lka -0.1 0.45 0.00 0
#> lvc 0.0 0.00 3.45 0
#> lcl 0.0 0.00 0.00 1
#>
#> States ($state or $stateDf):
#> Compartment Number Compartment Name
#> 1 1 depot
#> 2 2 central
#> ── Model (Normalized Syntax): ──
#> function() {
#> ini({
#> lfun ~ 4
#> lka ~ c(-0.1, 0.45)
#> lvc ~ 3.45
#> lcl ~ 1
#> })
#> model({
#> ka <- exp(lka)
#> cl <- exp(lcl)
#> vc <- exp(lvc)
#> kel <- cl/vc
#> d/dt(depot) <- -ka * depot
#> d/dt(central) <- ka * depot - kel * central
#> cp <- central/vc + lfun
#> })
#> }
Created on 2024-09-07 with reprex v2.1.1
You can also see the new lower triangular form here....
something like:
%>% ini(diag(a,b))
or%>% ini(diag(a+b))