Skip to content
Easily Specify block-diagonal matrices with lower triangular info
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Fix last minute error; Version bump May 13, 2019
man Add coverage reports and others May 10, 2019
tests Fix last minute error; Version bump May 13, 2019
vignettes Fix Vignette spelling made cran :(. Add cran badge May 14, 2019
.Rbuildignore Add coverage reports and others May 10, 2019
.gitignore
.travis.yml Add R 3.6 to the build matrix May 14, 2019
DESCRIPTION Fix last minute error; Version bump May 13, 2019
NAMESPACE Add breif vignette and expand readme May 10, 2019
README.md Fix Vignette spelling made cran :(. Add cran badge May 14, 2019
appveyor.yml Add coverage reports and others May 10, 2019
codecov.yml Add coverage reports and others May 10, 2019

README.md

lotri

Travis build status AppVeyor build status Coverage status CRAN status

Easily Specify block-diagonal matrices with (lo)wer (tri)angular matrices. Its as if you have won the (badly spelled) lotri (or lottery).

This was made to allow people (like me) to specify lower triangular matrices similar to the domain specific language implemented in nlmixr. Originally I had it included in RxODE, but thought it may have more general applicability, so I separated it into a new package.

For me, specifying the matricies in this way is easier than specifying them using R's default matrix. For instance to fully specify a simple 2x2 matrix, in R you specify:

mat <- matrix(c(1, 0.5, 0.5, 1),nrow=2,ncol=2,dimnames=list(c("a", "b"), c("a", "b")))

With lotri, you simply specify:

library(lotri)

mat <- lotri(a+b ~ c(1,
                     0.5, 1))

I find it more legible and easier to specify, especially if you have a more complex matrix. For instance with the more complex matrix:

mat <- lotri({
    a+b ~ c(1,
            0.5, 1)
    c ~ 1
    d +e ~ c(1,
             0.5, 1)
})

To fully specify this in base R you would need to use:

mat <- matrix(c(1, 0.5, 0, 0, 0,
                0.5, 1, 0, 0, 0,
                0, 0, 1, 0, 0,
                0, 0, 0, 1, 0.5,
                0, 0, 0, 0.5, 1),
              nrow=5, ncol=5,
              dimnames= list(c("a", "b", "c", "d", "e"), c("a", "b", "c", "d", "e")))

Of course with the excellent Matrix package this is a bit easier:

library(Matrix)
mat <- matrix(c(1, 0.5, 0.5, 1),nrow=2,ncol=2,dimnames=list(c("a", "b"), c("a", "b")))
mat <- bdiag(list(mat, matrix(1), mat))
## Convert back to standard matrix
mat <- as.matrix(mat)
##
dimnames(mat) <- list(c("a", "b", "c", "d", "e"), c("a", "b", "c", "d", "e"))

Regardless, I think lotri is a bit easier to use.

You can’t perform that action at this time.