https://github.com/stitchfix/diamond
Python solver for mixed-effects models
https://github.com/stitchfix/diamond
Last synced: about 1 year ago
JSON representation
Python solver for mixed-effects models
- Host: GitHub
- URL: https://github.com/stitchfix/diamond
- Owner: stitchfix
- License: other
- Created: 2017-08-07T19:06:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-06-03T22:29:34.000Z (about 1 year ago)
- Last Synced: 2025-06-04T06:42:32.510Z (about 1 year ago)
- Language: Python
- Size: 23.3 MB
- Stars: 97
- Watchers: 88
- Forks: 14
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.txt
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Diamond
[](https://circleci.com/gh/stitchfix/diamond)
### O Diamond, Diamond, thou little knowest the mischief thou hast done.

[(Diamond was Newton's mischievous dog)](https://en.wikipedia.org/wiki/Diamond_(dog))
## What is Diamond?
Diamond utilizes iterative, quasi-Newton 2nd-order solvers for certain kinds of generalized linear models (GLMs) with arbitrary but known L2-regularization. A common use is fitting mixed-effects models, with their covariance already being known by another means (e.g. lme4). These 2nd-order iterative solvers are considerably faster than a full-blown solution.
## Limitations
* The random-effects covariances must be input a-priori. Unlike [R's lme4](https://cran.r-project.org/web/packages/lme4/lme4.pdf) or [Julia's MixedModels](https://github.com/dmbates/MixedModels.jl), Diamond does not estimate the covariance of random effects terms.
* Diamond only supports the following models
* logistic regression
* ordinal logistic regression using proportional odds, as defined in Section 7.2.1 of Categorical Data Analysis, 2nd Ed., by Alan Agresti
* Currently, only formulae with crossed, independent random effects are supported. Using the mtcars dataset as an example, these look like `mpg ~ 1 + hp + (1 + hp | cyl) + (1 | gear)`. I.e. no hierarchical terms
## Installation
You must have [docker](https://docs.docker.com/engine/installation/) installed. Then, run
`docker run -ti --rm -p 8888:8888 tsweetser/diamond`
Copy-paste the URL, including the token, into your browser. Then, check out the Jupyter notebook examples!
You can also install from PyPI via `pip install sf-diamond`
## Troubleshooting installation
* You may need to restart docker if you've been running jupyter notebooks locally on port 8888.
## Documentation
See [documentation](http://stitchfix.github.io/diamond/) for more details on the details of Diamond and how to use it
## Contributing to Diamond
We always welcome contributions. See [CONTRIBUTING.md](CONTRIBUTING.md)
## Running Tests
You will need R to run the integration tests. From the root directory, run `pip install nose` then `nosetests`.
## Development Status
Diamond is an evolving project. Please file issues if you would like to use Diamond in new ways.
## License
See [LICENSE.txt](LICENSE.txt)