0.01
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Fit statistical (linear) models with fixed and mixed (random) effects in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
~> 10.0
~> 3.2

Runtime

= 0.1.0
~> 0.7.3
~> 0.2.0
~> 1.6.1
 Project Readme

mixed_models

Build Status

Fit statistical (linear) models with fixed and mixed (random) effects in Ruby.

Features

Linear mixed models

  • Support for the formula language of the R package lme4 makes model specification convenient and user friendly. An expanation of the lme4 formula interface can be found in the lme4 vignette, or on stackexchange (example). Types of linear mixed models that can be fit by mixed_models with the formula interface include:

    • Models with interaction fixed or random effects (e.g. y ~ x + z + x:z + (x + z + x:z | g)),
    • Models with multiple crossed random effects (e.g. y ~ x + (x|g) + (x|h)),
    • Models with nested random effects (e.g. y ~ x + (x|g) + (x|g:h)).
  • Flexible model specification capabilities with the possibility to pass the random effects covariance structure as a Proc, when fitting a model from raw madel matrices.

  • Possibility of singular fits (i.e models with random effects variance equal to zero).

  • Likelihood ratio test for nested models (Chi squared or bootstrap based).

  • Many types of hypotheses tests for the fixed and random effects (based on LRT, bootstrap or the Wald Z statistic).

  • Four types of bootstrap confidence intervals for the fixed effects coefficient estimates, as well as Wald Z confidence intervals. All bootstrap based methods are performed in parallel by default.

  • Prediction on new data and prediction intervals.

Installation

To install the latest stable version:

$ gem install mixed_models

Alternatively, you can add the line gem 'mixed_models' to your application's Gemfile, and then execute:

$ bundle

Ruby is required in version >=2.0 because keyword arguments are excessively used in mixed_models.

Usage

Linear mixed models (LMM) tutorials

Analysis of real data

  • This IRuby notebook shows an application of mixed_models to real data, which originate from blog posts from various sources in 2010-2012. The analyzed data set is of nontrivial size (~50000x300) and nontrivial structure (redundant variables, missing values, data transformations, etc.).

More usage examples

Some other examples in form of Ruby code can be found in the examples folder.

Further examples can be found in several BLOG posts (see below).

Some relevant BLOG posts

Development

The development version of mixed_models can be installed using the command line:

git clone https://github.com/agisga/mixed_models.git
cd mixed_models/
bundle install
bundle exec rake install

The automatic tests can be run with bundle exec rspec spec.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/mixed_models/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request