
An ELOS (expected length of stay) model, ported out of SAS into dependency-free C or Java, that reports when the fit is misleading
A few times in my career, I ported into plain C or Java the tools that scientists had written and tested in R, SAS, Python or MATLAB, so they could run on any computer, down to embedded ones, in the smallest memory footprint I could get, without depending on anything else, and in a streaming fashion, so that a million records go through the same 2.7 MB as hundreds of millions do. One of them was a hospital length-of-stay model, and that is the one I've just released as open source, in case it's useful to someone here.
It's ordinary least squares - linear regression, fitted by minimising the squared residuals. The terms aren't compiled in. Your CSV header names them, so adding a term to the model means adding a column to the file, like in R, and the same binary fits two terms or 35 (which is what one of my production models needed). With one term the whole method is five lines of arithmetic. The README shows them.
There are checks built in against bad design. The program tests each term for curvature, the fitted value for a missing interaction, and the residuals for spread that grows with the prediction.
It's not a stats package: no inference, no imputation, and an NA stops the run rather than being filled in. Do the modelling in R, Python, whatever. It reproduces NIST's Longley to eleven digits, which is the set that kills naive implementations, and agrees with lm() on every example file. Both run as regression tests in the suite.
Disclosure: written with AI assistance. The design, the prototype, the requirements and the tests are mine. make check diffs every example file against lm() and against the Java implementation, which came from the original that has been running at a large number of facilities since 2011.
The author is not a statistician, so if someone here sees where the diagnostics go wrong, that is the most useful thing to hear. Contributions welcome.