Giter VIP home page Giter VIP logo

mixedmodels.jl's Introduction

Mixed-effects models in Julia

Documentation Citation Build Status Code Coverage Style Guide
Stable Docs Dev Docs DOI Julia Current Julia Minimum Supported Version Julia Nightly PkgEval CodeCov Code Style: Blue

This package defines linear mixed models (LinearMixedModel) and generalized linear mixed models (GeneralizedLinearMixedModel). Users can use the abstraction for statistical model API to build, fit (fit/fit!), and query the fitted models.

A mixed-effects model is a statistical model for a response variable as a function of one or more covariates. For a categorical covariate the coefficients associated with the levels of the covariate are sometimes called effects, as in "the effect of using Treatment 1 versus the placebo". If the potential levels of the covariate are fixed and reproducible, e.g. the levels for Sex could be "F" and "M", they are modeled with fixed-effects parameters. If the levels constitute a sample from a population, e.g. the Subject or the Item at a particular observation, they are modeled as random effects.

A mixed-effects model contains both fixed-effects and random-effects terms.

With fixed-effects it is the coefficients themselves or combinations of coefficients that are of interest. For random effects it is the variability of the effects over the population that is of interest.

In this package random effects are modeled as independent samples from a multivariate Gaussian distribution of the form ๐“‘ ~ ๐“(0, ๐šบ). For the response vector, ๐ฒ, only the mean of conditional distribution, ๐“จ|๐“‘ = ๐› depends on ๐› and it does so through a linear predictor expression, ๐›ˆ = ๐—๐›ƒ + ๐™๐›, where ๐›ƒ is the fixed-effects coefficient vector and ๐— and ๐™ are model matrices of the appropriate sizes,

In a LinearMixedModel the conditional mean, ๐› = ๐”ผ[๐“จ|๐“‘ = ๐›], is the linear predictor, ๐›ˆ, and the conditional distribution is multivariate Gaussian, (๐“จ|๐“‘ = ๐›) ~ ๐“(๐›, ฯƒยฒ๐ˆ).

In a GeneralizedLinearMixedModel, the conditional mean, ๐”ผ[๐“จ|๐“‘ = ๐›], is related to the linear predictor via a link function. Typical distribution forms are Bernoulli for binary data or Poisson for count data.

Currently Tested Platforms

OS OS Version Arch Julia
Linux Ubuntu 20.04 x64 v1.8
Linux Ubuntu 20.04 x64 current release
Linux Ubuntu 20.04 x64 nightly
macOS Monterey 12 x64 v1.8
Windows Server 2019 x64 v1.8

Note that previous releases still support older Julia versions.

Version 4.0.0

Version 4.0.0 contains some user-visible changes and many changes in the underlying code.

Please see NEWS for a complete overview, but a few key points are:

  • The internal storage of the model matrices in LinearMixedModel has changed and been optimized. This change should be transparent to users who are not manipulating the fields of the model struct directly.
  • The handling of rank deficiency continues to evolve.
  • Additional predict and simulate methods have been added for generalizing to new data.
  • saveoptsum and restoreoptsum! provide for saving and restoring the optsum and thus offer a way to serialize a model fit.
  • There is improved support for the runtime construction of model formula, especially RandomEffectsTerms and nested terms (methods for Base.|(::AbstractTerm, ::AbstractTerm) and Base./(::AbstractTerm, ::AbstractTerm)).
  • A progress display is shown by default for models taking more than a few hundred milliseconds to fit. This can be disabled with the keyword argument progress=false.

Quick Start

julia> using MixedModels

julia> m1 = fit(MixedModel, @formula(yield ~ 1 + (1|batch)), MixedModels.dataset(:dyestuff))
Linear mixed model fit by maximum likelihood
 yield ~ 1 + (1 | batch)
   logLik   -2 logLik     AIC       AICc        BIC
  -163.6635   327.3271   333.3271   334.2501   337.5307

Variance components:
            Column    Variance Std.Dev.
batch    (Intercept)  1388.3332 37.2603
Residual              2451.2501 49.5101
 Number of obs: 30; levels of grouping factors: 6

  Fixed-effects parameters:
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
              Coef.  Std. Error      z  Pr(>|z|)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
(Intercept)  1527.5     17.6946  86.33    <1e-99
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

julia> using Random

julia> bs = parametricbootstrap(MersenneTwister(42), 1000, m1);
Progress: 100%%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| Time: 0:00:00

julia> propertynames(bs)
13-element Vector{Symbol}:
 :allpars
 :objective
 :ฯƒ
 :ฮฒ
 :se
 :coefpvalues
 :ฮธ
 :ฯƒs
 :ฮป
 :inds
 :lowerbd
 :fits
 :fcnames

julia> bs.coefpvalues # returns a row table
1000-element Vector{NamedTuple{(:iter, :coefname, :ฮฒ, :se, :z, :p), Tuple{Int64, Symbol, Float64, Float64, Float64, Float64}}}:
 (iter = 1, coefname = Symbol("(Intercept)"), ฮฒ = 1517.0670832927115, se = 20.76271142094811, z = 73.0669059804057, p = 0.0)
 (iter = 2, coefname = Symbol("(Intercept)"), ฮฒ = 1503.5781855888436, se = 8.1387737362628, z = 184.7425956676446, p = 0.0)
 (iter = 3, coefname = Symbol("(Intercept)"), ฮฒ = 1529.2236379016574, se = 16.523824785737837, z = 92.54659001356465, p = 0.0)
 โ‹ฎ
 (iter = 998, coefname = Symbol("(Intercept)"), ฮฒ = 1498.3795009457242, se = 25.649682012258104, z = 58.417079019913054, p = 0.0)
 (iter = 999, coefname = Symbol("(Intercept)"), ฮฒ = 1526.1076747922416, se = 16.22412120273579, z = 94.06411945042063, p = 0.0)
 (iter = 1000, coefname = Symbol("(Intercept)"), ฮฒ = 1557.7546433870125, se = 12.557577103806015, z = 124.04898098653763, p = 0.0)

julia> using DataFrames

julia> DataFrame(bs.coefpvalues) # puts it into a DataFrame
1000ร—6 DataFrame
โ”‚ Row  โ”‚ iter  โ”‚ coefname    โ”‚ ฮฒ       โ”‚ se      โ”‚ z       โ”‚ p       โ”‚
โ”‚      โ”‚ Int64 โ”‚ Symbol      โ”‚ Float64 โ”‚ Float64 โ”‚ Float64 โ”‚ Float64 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1    โ”‚ 1     โ”‚ (Intercept) โ”‚ 1517.07 โ”‚ 20.7627 โ”‚ 73.0669 โ”‚ 0.0     โ”‚
โ”‚ 2    โ”‚ 2     โ”‚ (Intercept) โ”‚ 1503.58 โ”‚ 8.13877 โ”‚ 184.743 โ”‚ 0.0     โ”‚
โ”‚ 3    โ”‚ 3     โ”‚ (Intercept) โ”‚ 1529.22 โ”‚ 16.5238 โ”‚ 92.5466 โ”‚ 0.0     โ”‚
โ‹ฎ
โ”‚ 998  โ”‚ 998   โ”‚ (Intercept) โ”‚ 1498.38 โ”‚ 25.6497 โ”‚ 58.4171 โ”‚ 0.0     โ”‚
โ”‚ 999  โ”‚ 999   โ”‚ (Intercept) โ”‚ 1526.11 โ”‚ 16.2241 โ”‚ 94.0641 โ”‚ 0.0     โ”‚
โ”‚ 1000 โ”‚ 1000  โ”‚ (Intercept) โ”‚ 1557.75 โ”‚ 12.5576 โ”‚ 124.049 โ”‚ 0.0     โ”‚

julia> DataFrame(bs.ฮฒ)
1000ร—3 DataFrame
โ”‚ Row  โ”‚ iter  โ”‚ coefname    โ”‚ ฮฒ       โ”‚
โ”‚      โ”‚ Int64 โ”‚ Symbol      โ”‚ Float64 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1    โ”‚ 1     โ”‚ (Intercept) โ”‚ 1517.07 โ”‚
โ”‚ 2    โ”‚ 2     โ”‚ (Intercept) โ”‚ 1503.58 โ”‚
โ”‚ 3    โ”‚ 3     โ”‚ (Intercept) โ”‚ 1529.22 โ”‚
โ‹ฎ
โ”‚ 998  โ”‚ 998   โ”‚ (Intercept) โ”‚ 1498.38 โ”‚
โ”‚ 999  โ”‚ 999   โ”‚ (Intercept) โ”‚ 1526.11 โ”‚
โ”‚ 1000 โ”‚ 1000  โ”‚ (Intercept) โ”‚ 1557.75 โ”‚

Funding Acknowledgement

The development of this package was supported by the Center for Interdisciplinary Research, Bielefeld (ZiF)/Cooperation Group "Statistical models for psychological and linguistic data".

mixedmodels.jl's People

Contributors

andreasnoack avatar ararslan avatar behinger avatar dependabot[bot] avatar dkarrasch avatar dmbates avatar femtocleaner[bot] avatar github-actions[bot] avatar kaskarn avatar kleinschmidt avatar likanzhan avatar michaelhatherly avatar mortenpi avatar nalimilan avatar nosferican avatar palday avatar pkofod avatar quinnj avatar simonab avatar staticfloat avatar timholy avatar tkelman avatar yakir12 avatar yoninazarathy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mixedmodels.jl's Issues

Nested grouping factors

I am in the process of moving my lme4 code from R over to Julia (those speed gains are very impressive), but I cannot find any documentation on the syntax. Specifically, I'm trying to specify nested random effects, but I cannot get it to work using the usual (1 | A/B) syntax. Is nesting supported natively in Julia MixedModels, or is the only solution to split nested effects into multiple terms: (1|A)+(1|A:B)?

FR: significance for variance

The current fit function returns several parameters for the model. For example, following https://github.com/dmbates/MixedModelsinJulia/blob/master/SimpleLMM.ipynb:

Linear mixed model fit by maximum likelihood
 Formula: Y ~ 1 + (1 | G)
   logLik   -2 logLik     AIC        BIC    
 -163.66353  327.32706  333.32706  337.53065

Variance components:
              Column    Variance  Std.Dev. 
 G        (Intercept)  1388.3335 37.260347
 Residual              2451.2500 49.510100
 Number of obs: 30; levels of grouping factors: 6

  Fixed-effects parameters:
             Estimate Std.Error z value P(>|z|)
(Intercept)    1527.5   17.6946  86.326  <1e-99

Would it be possible to also return a p-value for the variance estimator of the random effect parameter (G)?

dof not defined for MixedModels.LinearMixedModel{Float64}

This seemingly innocent code will not work for me:

julia> using DataFrames, MixedModels
julia> df = DataFrame(x1 = randn(100), x2 = randn(100), g = rand(1:15, 100))
julia> gvals = DataFrame(g = collect(1:15), nu = randn(15))
julia> df = join(df, gvals, on = :g, kind = :inner)
julia> df[:y] = df[:x1] + df[:x2] + df[:nu]
julia> fit!(lmm(y ~ x1 + (1|g), df))
Linear mixed model fit by maximum likelihood
 Formula: y ~ x1 + (1 | g)
Error showing value of type MixedModels.LinearMixedModel{Float64}:
ERROR: dof is not defined for MixedModels.LinearMixedModel{Float64}.
 in dof(::MixedModels.LinearMixedModel{Float64}) at /Users/tcovert/.julia/v0.5/StatsBase/src/statmodels.jl:43
 in show(::IOContext{Base.Terminals.TTYTerminal}, ::MixedModels.LinearMixedModel{Float64}) at /Users/tcovert/.julia/v0.5/MixedModels/src/pls.jl:418
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::MixedModels.LinearMixedModel{Float64}) at ./REPL.jl:132
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MixedModels.LinearMixedModel{Float64}) at ./REPL.jl:135
 in display(::MixedModels.LinearMixedModel{Float64}) at ./multimedia.jl:143
 in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:154
 in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:139
 in (::Base.REPL.##22#23{Bool,Base.REPL.##33#42{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:652
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1579
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:903
 in run_repl(::Base.REPL.LineEditREPL, ::Base.##930#931) at ./REPL.jl:188
 in _start() at ./client.jl:360
 in _start() at /usr/local/Cellar/julia/0.5.0/lib/julia/sys.dylib:?

Note that the model does seem estimate, in the sense that the return value of that expression is a MixedModels.LinearMixedModel{Float64} that seems to contain the fixed effects and covariances I was expecting.

I am using MixedModels version 0.5.6, on julia 0.5 on a mac (os x el capitan)

BoundsError on Julia 0.6rc1

On Julia 0.6 RC1, trying to run an example from https://github.com/dmbates/MixedModelsinJulia/blob/master/SimpleLMM.ipynb, I get this error:

 julia> mm1 = fit!(lmm(@formula(Y ~ 1 + (1 | G)), dyestuff))
ERROR: BoundsError: attempt to access ()
  at index [1]
Stacktrace:
 [1] macro expansion at /home/ohad/.julia/v0.6/DataArrays/src/dataarray.jl:254 [inlined]
 [2] macro expansion at /home/ohad/.julia/v0.6/Compat/src/ngenerate.jl:60 [inlined]
 [3] isna(::DataArrays.DataArray{Float64,1}) at /home/ohad/.julia/v0.6/Compat/src/ngenerate.jl:57
 [4] completecases(::DataFrames.DataFrame) at /home/ohad/.julia/v0.6/DataFrames/src/abstractdataframe/abstractdataframe.jl:471
 [5] na_omit at /home/ohad/.julia/v0.6/DataFrames/src/statsmodels/formula.jl:235 [inlined]
 [6] #ModelFrame#122(::Dict{Any,Any}, ::Type{T} where T, ::DataFrames.Terms, ::DataFrames.DataFrame) at /home/ohad/.julia/v0.6/DataFrames/src/statsmodels/formula.jl:320
 [7] #ModelFrame#125(::Array{Any,1}, ::Type{T} where T, ::DataFrames.Formula, ::DataFrames.DataFrame) at /home/ohad/.julia/v0.6/DataFrames/src/statsmodels/formula.jl:333
 [8] #lmm#32(::Array{Any,1}, ::Function, ::DataFrames.Formula, ::DataFrames.DataFrame) at /home/ohad/.julia/v0.6/MixedModels/src/pls.jl:100
 [9] lmm(::DataFrames.Formula, ::DataFrames.DataFrame) at /home/ohad/.julia/v0.6/MixedModels/src/pls.jl:100

GLMMs

I'm wondering what, if any, plans there are for support of GLMMs in this package.

I'd be happy to help, but after doing some reading about the general methods that are used to approximate the likelihood for GLMMs in lme4 I'm thinking that honestly it will take a lot to get myself up to speed. However, much of the data I deal with is binary or count data, so I'm highly motivated (as are some of my colleagues) and have a bit more free time over the summer to work on it.

The most obvious place, to me, to start is to look at the source code for lme4, but as far as I know that's verboten because it's GPL-licensed and so anything derived from it can't be included in this package which is MIT-licensed. Is that correct?

Covariance structure, penalized splines?

Hey,

I am glad to see that mixed models are coming to Julia.

Are there any plans for allowing the specification of a parametric covariance model? This would be very helpful for analyzing longitudinal data. Also, it would be very nice to have a way of directly fitting penalized smooth splines (GAM) with a unified interface. How complicated would that be?

Finding your way around for R users

In private email Martin Maechler asked me several questions about using Julia and the MixedModels package. Because the answers to which may be of more general interest, I created this issue for them so that others may see the answers and comment on them.

I am assuming that a recent version of Julia 0.2 devel is installed. The easiest way to do that for Ubuntu users is using the julianightlies PPA and the julia-deps PPA. As of today, the "nightlies" version produces

$ /usr/bin/julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" to list help topics
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.2.0+nightly20130502.9a72fab
 _/ |\__'_|_|_|\__'_|  |  -Linux-x86_64 (2013-05-03 19:14:05)
|__/                   |

on startup. There have been too many changes since the 0.1.2 release to try using that. Please ensure that your version string starts with 0.2.0

The system for attaching packages has changed in version 0.2.0. To install this package use

Pkg.add("MixedModels")

After that, attaching this and other packages is done with the using directive.

using MixedModels

More than one package can be listed. For testing I often use

using RDatasets, MixedModels

This directive doesn't return instantaneously but the delay is due to the size and complexity of the DataFrames package upon which both of these depend.

As in R, attaching a package also attaches its dependencies but there are distinctions between those packages that are visible from the REPL and those that are visible only inside the package listed in using. The equivalent of R's ls() is whos() and it can take an argument which is the name of a Module. (Most packages are organized as a Module - which is a namespace - but you can have Modules that are not separate packages).

julia> using MixedModels

julia> whos()
Base                          Module
Core                          Module
DataFrames                    Module
Distributions                 Module
GZip                          Module
Main                          Module
MixedModels                   Module
NLopt                         Module
OptionsMod                    Module
Stats                         Module

julia> whos(MixedModels)
LMMsimple                     DataType
LMMsplit                      DataType
MixedModel                    DataType
MixedModels                   Module
SparseMatrixRSC               DataType
VarCorr                       Function
fixef                         Function
ranef                         Function
reml                          Function

It happens that MixedModels attaches the DataFrames and Distributions namespaces in the REPL as well as its own namespace. However is does not the NLopt namespace in the REPL. I am not sure how to discover this other than by reading the source code or experimenting with names. The directive using MixedModels evaluates the source file

joinpath(Pkg.dir(), "MixedModels", "src", "MixedModels.jl")

which, in turn, has several calls to include

include("RSC.jl")           # regular sparse column-oriented matrices
include("utils.jl")         # utilities to deal with the model formula
include("linearmixedmodel.jl")
include("LMM.jl")

The fact that this driver file has the directive

using DataFrames, Distributions

both before and after the directive

module MixedModels

means that these namespaces will be visible in the REPL (because of the first using) and withing the module itself, because of the second using.

You can always try evaluating a name in the namespace to see if it is visible in the REPL.

julia> whos(NLopt)
ForcedStop                    DataType
NLOPT_VERSION                 VersionNumber
NLopt                         Module
Opt                           DataType
algorithm                     Function
algorithm_name                Function
default_initial_step!         Function
equality_constraint!          Function
force_stop                    Function
force_stop!                   Function
ftol_abs                      Function
ftol_abs!                     Function
ftol_rel                      Function
ftol_rel!                     Function
inequality_constraint!        Function
initial_step                  Function
initial_step!                 Function
local_optimizer!              Function
lower_bounds                  Function
lower_bounds!                 Function
max_objective!                Function
maxeval                       Function
maxeval!                      Function
maxtime                       Function
maxtime!                      Function
min_objective!                Function
optimize                      Function
optimize!                     Function
population                    Function
population!                   Function
remove_constraints!           Function
stopval                       Function
stopval!                      Function
upper_bounds                  Function
upper_bounds!                 Function
vector_storage                Function
vector_storage!               Function
xtol_abs                      Function
xtol_abs!                     Function
xtol_rel                      Function
xtol_rel!                     Function

julia> algorithm
ERROR: algorithm not defined

The fully qualified name will be accessible

julia> NLopt.algorithm
# methods for generic function algorithm
algorithm(o::Opt) at /home/bates/.julia/NLopt/src/NLopt.jl:143

Martin asked about the equivalent of R's installed.packages() which is

julia> Pkg.installed()
["GLM"=>"aefc6c1c616f784ddec920ea07ee6e3ab712bb50","Tk"=>v"0.0.1","MathProg"=>v"0.0.0","MAT"=>v"0.2.0","TextWrap"=>v"0.0.0","NLopt"=>v"0.0.0","Color"=>v"0.2.0","Mustache"=>v"0.0.0","Benchmark"=>v"0.0.0","Zlib"=>v"0.0.0","Debug"=>v"0.0.0","PyCall"=>v"0.0.0","Graphs"=>v"0.2.2","Gadfly"=>v"0.0.0","Compose"=>v"0.0.0","Metis"=>v"0.0.0","Cubature"=>v"0.1.0","CoinMP"=>v"0.0.1","GetC"=>v"0.0.0","Winston"=>v"0.0.0","RDatasets"=>"9000825fff7b059afc1973201d48e46521990a69","Profile"=>v"0.2.0","DataFrames"=>v"0.2.1","GZip"=>v"0.2.0","StrPack"=>v"0.0.0","IniFile"=>v"0.0.0","JSON"=>v"0.1.0","BinDeps"=>v"0.0.1","OpenGL"=>v"0.0.0","Rif"=>v"0.0.0","Iterators"=>v"0.0.0","Distributions"=>"1ba699146607c6c0a41e9b2c2266aee4c99e0141","HDF5"=>"8b7344bee440f3467adb2be6afe478677b25f224","Stats"=>v"0.2.0","Codecs"=>v"0.0.0","Clp"=>v"0.0.1","SemidefiniteProgramming"=>v"0.0.0","Clang"=>"6e995712fc89700190d7f79aed09e94e10752188","Options"=>v"0.2.0","ArgParse"=>v"0.2.1","Optim"=>"1dd33924ef113d960d8ffe981519ea78558f8681","DataStructures"=>v"0.2.3","Cairo"=>v"0.0.1","MathProgBase"=>v"0.0.0","Calculus"=>v"0.1.1"]

which is a hash or Dict

julia> typeof(Pkg.installed())
Dict{String,Union(String,VersionNumber)}

A more readable display is returned by

julia> Pkg.status()
ArgParse         0.2.1
Benchmark        0.0.0
BinDeps          0.0.1
Cairo            0.0.1
Clang            master
Clp              0.0.1
Codecs           0.0.0
CoinMP           0.0.1
Color            0.2.0
Compose          0.0.0
Cubature         0.1.0
Debug            0.0.0
Distributions    master
GLM              master
GZip             0.2.0
Gadfly           0.0.0
GetC             0.0.0
Graphs           master
HDF5             master
Iterators        0.0.0
JSON             0.1.0
MAT              0.2.0
MathProg         0.0.0
Metis            0.0.0
Mustache         0.0.0
NLopt            0.0.0
OpenGL           0.0.0
Optim            master
Options          0.2.0
Profile          master
PyCall           0.0.0
RDatasets        master (dirty)
Rif              0.0.0
SemidefiniteProgramming 0.0.0
Stats            0.2.0
StrPack          0.0.0
TextWrap         0.0.0
Tk               0.0.1
Winston          0.0.0
DataFrames       master (dirty)
DataStructures   0.2.3
Zlib             0.0.0
MathProgBase     0.0.0
Calculus         master
IniFile          0.0.0

I will be adding an lmer() function soon. Right now the package has two user-defined types for simple linear mixed models, LMMsimple and LMMsplit because I was experimenting to see if the complexity of handling the fixed-effects part separately from the random-effects part of the model was warranted (and apparently it is). The LMMsimple class throws both into a single sparse matrix and updatemu() for that class is only four lines.

## Update L, solve for ubeta and evaluate mu
function updatemu(m::LMMsimple)
    m.A.nzval[:] = m.anzv[:]            # restore A to ZXt*ZXt', update A and L
    chm_factorize!(m.L, pluseye!(chm_scale!(m.A, m.lambda, 3), 1:m.Zt.q))
    m.ubeta[:] = (m.L \ (m.lambda .* m.Zty))[:]
    m.mu[:] = m.Zt'*(m.lambda .* m.ubeta)
end

For LMMsplit the random-effects part of the system matrix is stored as a sparse symmetric matrix and the fixed-effects part is a dense matrix.

The formula/data interface is slightly more verbose than in R. A formula must be enclosed in :( ) to retain it as an expression. Thus

julia> using RDatasets

julia> ds = data("lme4", "Dyestuff")
Written by version 2.15.3
Minimal R version: 2.3.0
WARNING: has(d,k) is deprecated, use haskey(d,k) instead.
 in make_unique at /home/bates/.julia/DataFrames/src/utils.jl:47
30x2 DataFrame:
         Batch  Yield
[1,]       "A" 1545.0
[2,]       "A" 1440.0
[3,]       "A" 1440.0
[4,]       "A" 1520.0
[5,]       "A" 1580.0
[6,]       "B" 1540.0
[7,]       "B" 1555.0
[8,]       "B" 1490.0
[9,]       "B" 1560.0
[10,]      "B" 1495.0
[11,]      "C" 1595.0
[12,]      "C" 1550.0
[13,]      "C" 1605.0
[14,]      "C" 1510.0
[15,]      "C" 1560.0
[16,]      "D" 1445.0
[17,]      "D" 1440.0
[18,]      "D" 1595.0
[19,]      "D" 1465.0
[20,]      "D" 1545.0
[21,]      "E" 1595.0
[22,]      "E" 1630.0
[23,]      "E" 1515.0
[24,]      "E" 1635.0
[25,]      "E" 1625.0
[26,]      "F" 1520.0
[27,]      "F" 1455.0
[28,]      "F" 1450.0
[29,]      "F" 1480.0
[30,]      "F" 1445.0


julia> fm1 = LMMsplit(:(Yield ~ 1|Batch), ds)
Linear mixed model fit by maximum likelihood
 logLik: -163.66352994061094, deviance: 327.3270598812219

  Variance components: [1388.34, 2451.25]
  Number of obs: 30; levels of grouping factors: [6]
  Fixed-effects parameters: [1527.5]

The first time you do this the response will seem slow, which is because all the methods are being encountered for the first time and need to be compiled. Subsequent calls to will be much faster.

ReMat type that holds "raw" matrix

Is there any possibility of adding an additional ReMat subtype that wraps an AbstractMatrix? I'm interested in fitting mixed effects models that have random effects structure which isn't a strict partitioning of the full design matrix by row (they're events convolved with a temporal kernel, separate instances of which might overlap)

I'm also open to the possibility of extending the ReMat type in my own package but I'm not entirely clear on which methods I'd need to implement to make that work (since there's a lot of specialization for scalar/vector).

Return value of `simulate!`

Return the model so that

refit!(simulate!(m))

works. The simulated response vector can be accessed with model_response if other models are to be fit.

Crash in 0.5 - chksquare not defined

it appears that Base.LinAlg.chksquare => Base.LinAlg.checksquare

julia> fm = fit!(lmm(math_gr_8 ~ 1 + math_gr_5 + math_gr_3 + reading_gr_5 + reading_gr_3 +
(1 + math_gr_5 + math_gr_3 | class_id),df))
ERROR: UndefVarError: chksquare not defined
in getindex at /Users/sjbespa/.julia/v0.5/MixedModels/src/paramlowertriangular.jl:11
in anonymous at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:89
in _mapreduce at reduce.jl:141
in mapreduce at reduce.jl:159
[inlined code] from reduce.jl:162
in call at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:89
in lmm at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:105
in eval at /usr/local/lib/julia/sys-debug.dylib

Printing of variance components for vector-valued random effects needs work

julia> using RDatasets,MixedModels

julia> sleep = data("lme4","sleepstudy");

julia> fm1 = lmm(:(Reaction ~ Days + (Days|Subject)),sleep)
Linear mixed model fit by maximum likelihood
 logLik: -875.969672, deviance: 1751.939344

 Variance components:
                Variance    Std.Dev.
 Subject      565.693095   23.784304
 Residual      32.465657    5.697864
 Number of obs: 180; levels of grouping factors: 18

  Fixed-effects parameters:
        Estimate Std.Error z value
[1,]     251.405   6.63212 37.9072
[2,]     10.4673   1.50223 6.96783

It is not correctly counting the number of variance components. Also the within-subject correlations should be printed.

README needs update

Many of the examples in the README reference lmer, which seems to have been renamed to lmm. Additionally, the README needs updates for the new ~ syntax and the InstEval dataset now appears to have different capitalization for its column names. Eventually the code also needs to be updated for the DataFrames string -> symbol change, but maybe that should wait until we release a new DataFrames.

Tests pass on v0.5 but fail on v0.6

Pkg.test("MixedModels") passes on v0.5 but fails on v0.6 with the following error:

ERROR: LoadError: LoadError: There was an error during testing
 in record(::Base.Test.FallbackTestSet, ::Base.Test.Fail) at ./test.jl:397
 in do_test(::Base.Test.Returned, ::Expr) at ./test.jl:281
 in include_from_node1(::String) at ./loading.jl:426 (repeats 2 times)
 in process_options(::Base.JLOptions) at ./client.jl:262
 in _start() at ./client.jl:318
while loading /Users/ranjan/.julia/v0.6/MixedModels/test/vectorReTerm.jl, in expression starting on line 16
while loading /Users/ranjan/.julia/v0.6/MixedModels/test/runtests.jl, in expression starting on line 7

Incorrect output w.r.t. to correlations between the random effects

Something doesn't seem right in the output with respect to the estimated correlations between multiple random effects. Here is an example:

using MixedModels,RDatasets
dat = dataset("lme4","sleepstudy")
dat[:Days2] = map(Days -> Days^2, dat[:Days]);
fit!(lmm(Reaction ~ Days + Days2 + (Days + Days2 | Subject), dat))

In the output:

Variance components:
            Variance   Std.Dev.    Corr.
 Subject  742.5642654 27.2500324
          196.6435621 14.0229655 -0.40
            1.9583393  1.3994068  0.45  0.45
 Residual 518.1687688 22.7633207

Note the two 0.45 values. The second one is incorrect; it should be -0.91 (double-checked with lme() and lmer()). This appears to be just an output problem though, since the fit of the model is the same (log likelihood = -868.8088 all across).

You can see the same issue at the end of: http://nbviewer.jupyter.org/github/dmbates/slides/blob/master/2014-10-01-Ithaca/lmm%20Examples.ipynb

The first column of the (lower triangular part of the) correlation matrix appears correct, but then all the remaining columns are just copies of the first column.

MethodError with 0.5.7 and rc4

The data frame that instigates the problem can be generated by sourcing the script 008_GLMM_make_yourself.R which can be downloaded (near the bottom of):
http://bodowinter.com/stuttgart_awesomeness/

The specific data frame was extracted with:
write.table(xdata,'bodo-example.csv',row.names=F,sep=',')

julia> df = readtable("bodo-example.csv")
120ร—4 DataFrames.DataFrame
โ”‚ Row โ”‚ Subject โ”‚ Item     โ”‚ Frequency โ”‚ VowelDuration โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1   โ”‚ "S1"    โ”‚ "Item1"  โ”‚ 2.74      โ”‚ 312.409       โ”‚
โ”‚ 2   โ”‚ "S1"    โ”‚ "Item2"  โ”‚ 9.82      โ”‚ 236.582       โ”‚
...
julia> f = VowelDuration ~ Frequency + (1+Frequency|Subject)
Formula: VowelDuration ~ Frequency + ((1 + Frequency) | Subject)

julia> mixed = lmm(f,df)
WARNING: Model has not been fit

julia> fm = fit!(mixed)
Linear mixed model fit by maximum likelihood
 Formula: VowelDuration ~ Frequency + ((1 + Frequency) | Subject)
   logLik    -2 logLik     AIC        BIC    
   -587.3596  1174.7193  1186.7193  1203.4442
...
julia> f = VowelDuration ~ Frequency + (1+Frequency|Subject) + (1|Item)
Formula: VowelDuration ~ Frequency + ((1 + Frequency) | Subject) + (1 | Item)

julia> mixed = lmm(f,df)
ERROR: MethodError: no method matching *(::MixedModels.ScalarReMat{Float64,String,UInt8}, ::MixedModels.VectorReMat{Float64,String,UInt8})
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...) at operators.jl:138
  *{T}(::Diagonal{T}, ::MixedModels.VectorReMat{T,S,R<:Integer}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/remat.jl:327
  *{T}(::T, ::Type{Measures.Length{:cx,T}}) at /Users/sjbespa/.julia/v0.5/Compose/src/measure.jl:9
  ...
 in Ac_mul_B(::MixedModels.ScalarReMat{Float64,String,UInt8}, ::MixedModels.VectorReMat{Float64,String,UInt8}) at ./operators.jl:319
 in MixedModels.LinearMixedModel{T<:AbstractFloat}(::DataFrames.Formula, ::DataFrames.ModelFrame, ::Array{Any,1}, ::Array{LowerTriangular{Float64,Array{Float64,2}},1}, ::Array{Float64,1}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:104
 in #lmm#11(::Array{Any,1}, ::Function, ::DataFrames.Formula, ::DataFrames.DataFrame) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:145
 in lmm(::DataFrames.Formula, ::DataFrames.DataFrame) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:130

[PackageEvaluator.jl] Your package MixedModels may have a testing issue.

This issue is being filed by a script, but if you reply, I will see it.

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their test (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3).

The results of this script are used to generate a package listing enhanced with testing results.

The status of this package, MixedModels, on...

  • Julia 0.2 is 'Package doesn't load.' PackageEvaluator.jl
  • Julia 0.3 is 'No tests, but package loads.' PackageEvaluator.jl

'No tests, but package loads.' can be due to their being no tests (you should write some if you can!) but can also be due to PackageEvaluator not being able to find your tests. Consider adding a test/runtests.jl file.

'Package doesn't load.' is the worst-case scenario. Sometimes this arises because your package doesn't have BinDeps support, or needs something that can't be installed with BinDeps. If this is the case for your package, please file an issue and an exception can be made so your package will not be tested.

This automatically filed issue is a one-off message. Starting soon, issues will only be filed when the testing status of your package changes in a negative direction (gets worse). If you'd like to opt-out of these status-change messages, reply to this message.

linpred!() for type LMMGeneral

Prof. Bates,

Big thanks for making MixedModels for Julia

In the function linpred!() for type LMMGeneral, if dimension of random effect is 1, it is using fma!().

if size(X,2) == 1 fma!(mu, (lm[i][1,1]*u[i])[:,ind], X[:,1])

I had an error "argument dimensions are not map-compatible"....

I was wondering the second argument should be transposed like

if size(X,2) == 1 fma!(mu, (lm[i][1,1]*u[i])[:,ind]', X[:,1])

Thanks
Yonghee Lee

No method matching downdate!...

At the suggestion of a user in the Julia Stats group, I'm cross posting my issue here:
[https://discourse.julialang.org/t/mixedmodels-fit-error/1416]

The input data is proprietary, and very large, so I'm currently working on creating a toy example that will duplicate the error. All of the grouping factors are type String, and all of intercept/slope terms are Float64.

NumericFuns should be imported

It seems the package NumericFuns should be imported in the file MixedModels.jl

using MixedModels
using DataFrames
ds = DataFrame(A = [0.1,0.12,0.31,0.2,0.1,0.1], B =[1, 2, 1, 1,1,2]);
fm1 = lmm(A ~ 1|B, ds)

the above commands give an error message:
Warning: could not import Base.solve into MixedModels
in callback catch
Multiply not defined
in solve! at /home/gaofeng/.julia/MixedModels/src/scalar1.jl:90
in obj at /home/gaofeng/.julia/MixedModels/src/linearmixedmodels.jl:13
in nlopt_callback_wrapper at /home/gaofeng/.julia/NLopt/src/NLopt.jl:387

There is no error when using NumericFuns is added in the file MixedModels.jl

ERROR: fit is not defined for MixedModels.LinearMixedModel{Float64}

I can't exactly share the data that goes with this code, but it used to work on the v0.3 branch and it is now not working with v0.4. fm is a well-formed formula and pfdata is a well-formed DataFrame that contains every column referenced in fm

using MixedModels
fit(lmm(fm, pfdata))

and then I get the above error. I can confirm that if I type methods(fit), nothing in MixedModels shows up, though methods(lmm) definitely shows that MixedModels is exporting the lmm() function

uncorrelated random slope and intercept, with nested levels

Hello,

Brief backstory: participants are nested in centers. two participants in my dataset changed center during the course of the study. Analysis on the full sample can be carried out using a crossed-effects model, which we specify as:

Y ~ ... + (1 | center) + (0 + x | center) + (1 | pid)

This works fine in both lme4 and MixedModels.

However, when we remove both center-switching participants, the dataset suddenly has a neatly nested structure and MixedModels throws an error caused by the lack of a !downdate(Diagonal, Sparse Matrix, Sparse Matrix) method.

The same model still converges happily in lme4

[PkgEval] MixedModels may have a testing issue on Julia 0.3 (2014-07-14)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2014-07-12 the testing status was Tests pass.
  • On 2014-07-14 the testing status changed to Package doesn't load.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Package doesn't load. means that PackageEvaluator did not find tests for your package. Additionally, trying to load your package with using failed.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

INFO: Installing ArrayViews v0.4.6
INFO: Installing BinDeps v0.2.14
INFO: Installing DataArrays v0.1.12
INFO: Installing DataFrames v0.5.6
INFO: Installing Distributions v0.5.2
INFO: Installing GZip v0.2.13
INFO: Installing MixedModels v0.3.4
INFO: Installing NLopt v0.0.3
INFO: Installing NumericExtensions v0.6.2
INFO: Installing NumericFuns v0.2.3
INFO: Installing PDMats v0.2.0
INFO: Installing Reexport v0.0.1
INFO: Installing SortingAlgorithms v0.0.1
INFO: Installing StatsBase v0.5.3
INFO: Installing URIParser v0.0.2
INFO: Building NLopt
INFO: Package database updated
Warning: could not import Sort.sortby into DataFrames
Warning: could not import Sort.sortby! into DataFrames
ERROR: repl_show not defined
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:54
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:51
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
while loading /home/idunning/pkgtest/.julia/v0.3/DataFrames/src/dataframe/reshape.jl, in expression starting on line 163
while loading /home/idunning/pkgtest/.julia/v0.3/DataFrames/src/DataFrames.jl, in expression starting on line 110
while loading /home/idunning/pkgtest/.julia/v0.3/MixedModels/src/MixedModels.jl, in expression starting on line 1
while loading /home/idunning/pkgtest/.julia/v0.3/MixedModels/testusing.jl, in expression starting on line 1
INFO: Package database updated

Note this is possibly due to removal of deprecated functions in Julia 0.3-rc1: JuliaLang/julia#7609

Precompile error on 0.6rc2

Just did Pkg.update():

โžœ  ~ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-rc2.0 (2017-05-18 02:31 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-linux-gnu

julia> using MixedModels
WARNING: Method definition ==(Base.Nullable{S}, Base.Nullable{T}) in module Base at nullable.jl:238 overwritten in module NullableArrays at /home/ohad/.julia/v0.6/NullableArrays/src/operators.jl:128.
INFO: Recompiling stale cache file /home/ohad/.julia/lib/v0.6/MixedModels.ji for module MixedModels.
WARNING: Method definition ==(Base.Nullable{S}, Base.Nullable{T}) in module Base at nullable.jl:238 overwritten in module NullableArrays at /home/ohad/.julia/v0.6/NullableArrays/src/operators.jl:128.
WARNING: The call to compilecache failed to create a usable precompiled cache file for module MixedModels. Got:
WARNING: Module Iterators uuid did not match cache file.
ERROR: LoadError: Declaring __precompile__(true) is only allowed in module files being imported.
Stacktrace:
 [1] __precompile__(::Bool) at ./loading.jl:335
 [2] __precompile__() at ./loading.jl:331
 [3] include_from_node1(::String) at ./loading.jl:569
 [4] eval(::Module, ::Any) at ./boot.jl:235
 [5] _require(::Symbol) at ./loading.jl:483
 [6] require(::Symbol) at ./loading.jl:398
while loading /home/ohad/.julia/v0.6/MixedModels/src/MixedModels.jl, in expression starting on line 1

[PkgEval] MixedModels may have a testing issue on Julia 0.4 (2015-01-17)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.4

  • On 2015-01-16 the testing status was Tests fail, but package loads.
  • On 2015-01-17 the testing status changed to Package doesn't load.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

Package doesn't load. means that PackageEvaluator did not find tests for your package. Additionally, trying to load your package with using failed.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("MixedModels")' log

WARNING: deprecated syntax "[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/NLopt/deps/build.jl:54.
Use "Dict(a=>b, ...)" instead.
INFO: Installing Distributions v0.6.3
INFO: Installing MathProgBase v0.3.8
INFO: Installing MixedModels v0.3.18
INFO: Installing NLopt v0.2.0
INFO: Installing PDMats v0.3.1
INFO: Building NLopt
INFO: Package database updated

>>> 'using MixedModels' log
Warning: New definition 
    + at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:326
is ambiguous with: 
    + at linalg/generic.jl:4.
To fix, define 
    +
before the new definition.
Warning: New definition 
    + at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:350
is ambiguous with: 
    + at linalg/generic.jl:4.
To fix, define 
    +
before the new definition.
Warning: New definition 
    - at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:326
is ambiguous with: 
    - at linalg/generic.jl:5.
To fix, define 
    -
before the new definition.
Warning: New definition 
    - at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:326
is ambiguous with: 
    - at linalg/generic.jl:5.
To fix, define 
    -
before the new definition.
Warning: New definition 
    - at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:350
is ambiguous with: 
    - at linalg/generic.jl:5.
To fix, define 
    -
before the new definition.
Warning: New definition 
    - at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:350
is ambiguous with: 
    - at linalg/generic.jl:5.
To fix, define 
    -
before the new definition.
Warning: New definition 
    - at /home/idunning/pkgtest/.julia/v0.4/DataArrays/src/operators.jl:350
is ambiguous with: 
    - at linalg/generic.jl:5.
To fix, define 
    -
before the new definition.
Julia Version 0.4.0-dev+2756
Commit 4b20e10 (2015-01-17 03:18 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

(AbstractArray{T,N},DataArrays.DataArray{T,N})(AbstractArray{T,2},AbstractArray{T,2})(AbstractArray{T,2},DataArrays.DataArray{T,2})(AbstractArray{T,N},DataArrays.AbstractDataArray{T,N})(AbstractArray{T,2},AbstractArray{T,2})(AbstractArray{T,2},DataArrays.AbstractDataArray{T,2})(AbstractArray{Bool,N},DataArrays.DataArray{Bool,N})(AbstractArray{T,2},AbstractArray{T,2})(AbstractArray{Bool,2},DataArrays.DataArray{Bool,2})(AbstractArray{T,N},DataArrays.DataArray{T,N})(AbstractArray{T,2},AbstractArray{T,2})(AbstractArray{T,2},DataArrays.DataArray{T,2})(AbstractArray{Bool,N},DataArrays.AbstractDataArray{Bool,N})(AbstractArray{T,2},AbstractArray{T,2})(AbstractArray{Bool,2},DataArrays.AbstractDataArray{Bool,2})(DataArrays.AbstractDataArray{T,N},AbstractArray{T,N})(AbstractArray{T,2},AbstractArray{T,2})(DataArrays.AbstractDataArray{T,2},AbstractArray{T,2})(AbstractArray{T,N},DataArrays.AbstractDataArray{T,N})(AbstractArray{T,2},AbstractArray{T,2})(AbstractArray{T,2},DataArrays.AbstractDataArray{T,2})ERROR: LoadError: LoadError: UndefVarError: CholmodSparse! not defined
 in include at ./boot.jl:248
 in include_from_node1 at ./loading.jl:128
 in reload_path at ./loading.jl:152
 in _require at ./loading.jl:67
 in require at ./loading.jl:52
 in include at ./boot.jl:248
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:312
 in _start at ./client.jl:396
while loading /home/idunning/pkgtest/.julia/v0.4/MixedModels/src/MixedModels.jl, in expression starting on line 5
while loading /home/idunning/pkgtest/.julia/v0.4/MixedModels/testusing.jl, in expression starting on line 2

>>> test log
no tests to run
>>> end of log

[PkgEval] MixedModels may have a testing issue on Julia 0.3 (2014-08-23)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2014-08-22 the testing status was Tests pass.
  • On 2014-08-23 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("MixedModels")' log
INFO: Cloning cache of MixedModels from git://github.com/dmbates/MixedModels.jl.git
INFO: Installing ArrayViews v0.4.6
INFO: Installing BinDeps v0.3.3
INFO: Installing DataArrays v0.2.0
INFO: Installing DataFrames v0.5.7
INFO: Installing Distributions v0.5.4
INFO: Installing GZip v0.2.13
INFO: Installing MathProgBase v0.2.5
INFO: Installing MixedModels v0.3.10
INFO: Installing NLopt v0.1.2
INFO: Installing PDMats v0.2.4
INFO: Installing Reexport v0.0.1
INFO: Installing SHA v0.0.2
INFO: Installing SortingAlgorithms v0.0.1
INFO: Installing StatsBase v0.6.3
INFO: Installing URIParser v0.0.2
INFO: Building NLopt
INFO: Package database updated

>>> 'using MixedModels' log
Julia Version 0.3.0-rc4+4
Commit bab9636 (2014-08-20 18:47 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

>>> test log
ERROR: "Tests failed"
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
 in _start_3B_1718 at /home/idunning/julia03/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.3/MixedModels/test/runtests.jl, in expression starting on line 92
    [1m[32mPASSED[0m: plsonescalar.jl
    [1m[32mPASSED[0m: plsonevector.jl
    [1m[32mPASSED[0m: plstwoscalar.jl
    [1m[31mFAILED[0m: plstwovector.jl
    [1m[32mPASSED[0m: plsdiagnested.jl


>>> end of log

[PkgEval] MixedModels may have a testing issue on Julia 0.3 (2014-08-16)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2014-08-15 the testing status was Tests pass.
  • On 2014-08-16 the testing status changed to Package doesn't load.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Package doesn't load. means that PackageEvaluator did not find tests for your package. Additionally, trying to load your package with using failed.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("MixedModels")' log
INFO: Cloning cache of MixedModels from git://github.com/dmbates/MixedModels.jl.git
INFO: Installing ArrayViews v0.4.6
INFO: Installing BinDeps v0.3.0
INFO: Installing DataArrays v0.2.0
INFO: Installing DataFrames v0.5.7
INFO: Installing Distributions v0.5.4
INFO: Installing GZip v0.2.13
INFO: Installing MathProgBase v0.2.5
INFO: Installing MixedModels v0.3.9
INFO: Installing NLopt v0.1.1
INFO: Installing NumericExtensions v0.6.2
INFO: Installing NumericFuns v0.2.3
INFO: Installing PDMats v0.2.3
INFO: Installing Reexport v0.0.1
INFO: Installing SHA v0.0.2
INFO: Installing SortingAlgorithms v0.0.1
INFO: Installing StatsBase v0.6.3
INFO: Installing URIParser v0.0.2
INFO: Building NLopt
INFO: Package database updated
INFO: METADATA is out-of-date a you may not have the latest version of MixedModels
INFO: Use `Pkg.update()` to get the latest versions of your packages

>>> 'using MixedModels' log

ERROR: type: ccall: expected Symbol, got Array{Any,1}
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:54
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:51
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
 in _start_3B_1699 at /home/idunning/julia03/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.3/NLopt/src/NLopt.jl, in expression starting on line 375
while loading /home/idunning/pkgtest/.julia/v0.3/MixedModels/src/MixedModels.jl, in expression starting on line 5
while loading /home/idunning/pkgtest/.julia/v0.3/MixedModels/testusing.jl, in expression starting on line 1

>>> test log
no tests to run
>>> end of log

Residuals

In terms of model diagnostics, what diagnostics can be run for these models? Are the residuals an option to this, and if so, how can we define the residuals?
As Douglas said:
"As for residuals, like many other properties of mixed-effects models, you need to be careful how you define them. You need to decide if the random effects are included in the fitted values or not. Perhaps it is better to define a fitted method for LinearMixedModel, which can then be the basis of a residuals method."

UndefVarError: chm_scale! not defined

I'm getting this error on Julia 0.4.0-rc1:

julia> using MixedModels
ERROR: LoadError: UndefVarError: chm_scale! not defined
  in include at boot.jl:260
  in include_from_node1 at loading.jl:271
  in include at boot.jl:260
  in include_from_node1 at loading.jl:271
  in require at loading.jl:210
while loading [...]\MixedModels\src\utils.jl, in expression starting on line 39
while loading [...]\MixedModels\src\MixedModels.jl, in expression starting on line 44

I didn't do anything but install a fresh version of the release candidate and call Pkg.add("MixedModels").

Extracting from an lmm model.

Hello,

thank you for developing this package. I use R and Julia side by side and I try to do most of the stuff R does in a single function call by hand in Julia. Right now, I want to simulate data from the model distribution. I fit a model of the following form with lmm:
@time fm2 = fit(lmm(Y ~ X + (A | B) + (A | C), df), true)
I am trying to get the following model components from fm2 (An object of type LMMGeneral{Int32}.). I extract:
The residual standard error: std(fm2)[3]
The model matrix: fm2.X.m
The fixed effects coefficients: fixef(fm2) or fm2.beta.
What I donโ€™t understand right now, is how to get the random effects model matrix and the random effects covariance.
In the case of the random effects model matrix, when I look at dump(fm2) I am not sure where it is.
Is the random effects model matrix ccessible via fm2.Xs and the covariance parameters vie fm2.lambda?
If this is the case this gives me a type of Array{Array{Float64, 2, 1} in both cases. If I extracted the right components I am still not sure what to do with these types if I want to use them in simulating data. I would need to bring them in a format where matrix multiplication is possible.

I hope this is the right place to ask this question.

Calling ฮ›() in LinearMixedModels.jl results in a MethodError

I need to access the random effect covariance matrix (D in many texts or ฮฃฮธ in your LME4 paper...)
While experimenting with the module, I exported ฮ›(). However, calling it results in:

ERROR: MethodError: ltri has no method matching ltri(::SparseMatrixCSC{Float64,Int64})
in ฮ› at /Users/sjbespa/.julia/v0.4/MixedModels/src/linearmixedmodels.jl:247

Is there a way to access the covariance matrix? Otherwise, I'll close the issue if fixing the error doesn't get me any closer to what I need for my work...

error with 'convert' types

Dear Doug,
Using fit(lmm(forehead ~ palm + (1|slap), data)), where palm is a PooledDataArray, I get:

julia> ERROR: `convert` has no method matching convert(::Type{Array{Symbol,1}}, ::Array{Any,1})
 in convert at base.jl:13
 in ModelFrame at ~/.julia/v0.3/DataFrames/src/statsmodels/formula.jl:238
 in lmm at ~/.julia/v0.3/MixedModels/src/linearmixedmodels.jl:25

[PkgEval] MixedModels may have a testing issue on Julia 0.4 (2014-10-08)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.4

  • On 2014-10-05 the testing status was Tests pass.
  • On 2014-10-08 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

Special message from @IainNZ: This change may be due to breaking changes to Dict in JuliaLang/julia#8521, or the removal of deprecated syntax in JuliaLang/julia#8607.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("MixedModels")' log

WARNING: deprecated syntax "(String=>String)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/BinDeps.jl:146.
Use "Dict{String,String}()" instead.

WARNING: deprecated syntax "(String=>String)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/BinDeps.jl:147.
Use "Dict{String,String}()" instead.

WARNING: deprecated syntax "(String=>String)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/BinDeps.jl:148.
Use "Dict{String,String}()" instead.

WARNING: deprecated syntax "(String=>String)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/BinDeps.jl:149.
Use "Dict{String,String}()" instead.

WARNING: deprecated syntax "(Symbol=>Any)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/dependencies.jl:224.
Use "Dict{Symbol,Any}()" instead.

WARNING: deprecated syntax "(Symbol=>Any)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/dependencies.jl:383.
Use "Dict{Symbol,Any}()" instead.

WARNING: deprecated syntax "{a=>b, ...}" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/dependencies.jl:387.
Use "Dict{Any,Any}(a=>b, ...)" instead.

WARNING: deprecated syntax "(Any=>Any)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/dependencies.jl:494.
Use "Dict{Any,Any}()" instead.

WARNING: deprecated syntax "(Any=>Any)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/dependencies.jl:555.
Use "Dict{Any,Any}()" instead.

WARNING: deprecated syntax "(Any=>Any)[]" at /home/idunning/pkgtest/.julia/v0.4/BinDeps/src/dependencies.jl:660.
Use "Dict{Any,Any}()" instead.

WARNING: deprecated syntax "[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/NLopt/deps/build.jl:54.
Use "Dict(a=>b, ...)" instead.
INFO: Installing ArrayViews v0.4.6
INFO: Installing BinDeps v0.3.5
INFO: Installing DataArrays v0.2.2
INFO: Installing DataFrames v0.5.9
INFO: Installing Distributions v0.5.4
INFO: Installing GZip v0.2.13
INFO: Installing MathProgBase v0.3.1
INFO: Installing MixedModels v0.3.15
INFO: Installing NLopt v0.1.3
INFO: Installing PDMats v0.2.4
INFO: Installing Reexport v0.0.1
INFO: Installing SHA v0.0.3
INFO: Installing SortingAlgorithms v0.0.2
INFO: Installing StatsBase v0.6.6
INFO: Installing URIParser v0.0.3
INFO: Building NLopt
INFO: Package database updated
INFO: METADATA is out-of-date a you may not have the latest version of MixedModels
INFO: Use `Pkg.update()` to get the latest versions of your packages

>>> 'using MixedModels' log

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/scalarstats.jl:98.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/scalarstats.jl:122.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>Float64)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/counts.jl:162.
Use "Dict{T,Float64}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/counts.jl:192.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>W)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/counts.jl:193.
Use "Dict{T,W}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/misc.jl:66.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/misc.jl:77.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/RDA.jl:11.
Use "Dict(a=>b, ...)" instead.

WARNING: deprecated syntax "(Symbol=>Cenum)[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/NLopt/src/NLopt.jl:79.
Use "Dict{Symbol,Cenum}(a=>b, ...)" instead.

WARNING: deprecated syntax "(Cenum=>Symbol)[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/NLopt/src/NLopt.jl:95.
Use "Dict{Cenum,Symbol}(a=>b, ...)" instead.
Julia Version 0.4.0-dev+998
Commit e24fac0 (2014-10-07 22:02 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

>>> test log

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/scalarstats.jl:98.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/scalarstats.jl:122.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>Float64)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/counts.jl:162.
Use "Dict{T,Float64}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/counts.jl:192.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>W)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/counts.jl:193.
Use "Dict{T,W}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/misc.jl:66.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "(T=>Int)[]" at /home/idunning/pkgtest/.julia/v0.4/StatsBase/src/misc.jl:77.
Use "Dict{T,Int}()" instead.

WARNING: deprecated syntax "[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/RDA.jl:11.
Use "Dict(a=>b, ...)" instead.

WARNING: deprecated syntax "(Symbol=>Cenum)[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/NLopt/src/NLopt.jl:79.
Use "Dict{Symbol,Cenum}(a=>b, ...)" instead.

WARNING: deprecated syntax "(Cenum=>Symbol)[a=>b, ...]" at /home/idunning/pkgtest/.julia/v0.4/NLopt/src/NLopt.jl:95.
Use "Dict{Cenum,Symbol}(a=>b, ...)" instead.
    [1m[31mFAILED[0m: plsonescalar.jl
    [1m[31mFAILED[0m: plsonevector.jl
    [1m[31mFAILED[0m: plstwoscalar.jl
    [1m[31mFAILED[0m: plstwovector.jl
    [1m[31mFAILED[0m: plsdiagnested.jl

ERROR: "Tests failed"
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:293
 in _start at ./client.jl:362
 in _start_3B_3789 at /home/idunning/julia04/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.4/MixedModels/test/runtests.jl, in expression starting on line 26

INFO: Testing MixedModels
=============================[ ERROR: MixedModels ]=============================

failed process: Process(`/home/idunning/julia04/usr/bin/julia /home/idunning/pkgtest/.julia/v0.4/MixedModels/test/runtests.jl`, ProcessExited(1)) [1]

================================================================================
INFO: No packages to install, update or remove
ERROR: MixedModels had test errors
 in error at error.jl:21
 in test at pkg/entry.jl:719
 in anonymous at pkg/dir.jl:28
 in cd at ./file.jl:20
 in cd at pkg/dir.jl:28
 in test at pkg.jl:68
 in process_options at ./client.jl:221
 in _start at ./client.jl:362
 in _start_3B_3789 at /home/idunning/julia04/usr/bin/../lib/julia/sys.so

>>> end of log

`ccdf not defined` when calling `MixedModels.lrt`

I tried to use lrt from MixedModels but I get the following error:

ccdf not defined
while loading In[123], in expression starting on line 1 
in lrt at /Users/jfsantos/.julia/v0.3/MixedModels/src/linearmixedmodels.jl:182

I know the function is not currently exported so maybe it's not expected to be used outside the module, but ccdf(::Chisq, ::Real) is defined and I am even using Distributions in my code. If I define lrt, npar and nฮธ directly in my code, lrt seems to work properly.

Generalize the ฮป components

There is no need to restrict the ฮป components to be triangular matrices. They could equally as well be Diagonal. The formula specification would be trickier.

Need to provide more generalized approaches to

  • counting nฮธ
  • extracting ฮธ
  • assigning ฮธ

New Crash with 0.5.7 and 0.5

I'll send the file to your email acct - the Drop Box is inaccessible...

et-imac-retina:Deming sjbespa$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-apple-darwin15.6.0

julia> using MixedModels
INFO: Recompiling stale cache file /Users/sjbespa/.julia/lib/v0.5/GLM.ji for module GLM.
INFO: Recompiling stale cache file /Users/sjbespa/.julia/lib/v0.5/MixedModels.ji for module MixedModels.

julia> using DataFrames

julia> df = readtable("cms-3yr-2000-gr3.csv");

julia> mixed = lmm(mathz_3 ~ 1 + mathz_1 + mathz_2 + readz_1 + readz_2 + (1 + mathz_1 + mathz_2 + readz_1 + readz_2|school_3),df);

julia> fit!(mixed)
Linear mixed model fit by maximum likelihood
 Formula: mathz_3 ~ 1 + mathz_1 + mathz_2 + readz_1 + readz_2 + ((1 + mathz_1 + mathz_2 + readz_1 + readz_2) | school_3)
Error showing value of type MixedModels.LinearMixedModel{Float64}:
ERROR: dof is not defined for MixedModels.LinearMixedModel{Float64}.
 in dof(::MixedModels.LinearMixedModel{Float64}) at /Users/sjbespa/.julia/v0.5/StatsBase/src/statmodels.jl:43
 in show(::IOContext{Base.Terminals.TTYTerminal}, ::MixedModels.LinearMixedModel{Float64}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:415
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::MixedModels.LinearMixedModel{Float64}) at ./REPL.jl:132
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MixedModels.LinearMixedModel{Float64}) at ./REPL.jl:135
 in display(::MixedModels.LinearMixedModel{Float64}) at ./multimedia.jl:143
 in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:154
 in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:139
 in (::Base.REPL.##22#23{Bool,Base.REPL.##33#42{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:652
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1579
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at /usr/local/lib/julia/sys.dylib:?
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:903
 in run_repl(::Base.REPL.LineEditREPL, ::Base.##930#931) at ./REPL.jl:188
 in _start() at ./client.jl:360
 in _start() at /usr/local/lib/julia/sys.dylib:?

Error "type Symmetric has no field data" for some random effect structures

When adding a per-subject random slope to a model of a psycholinguistic experiment with subject and item grouping factors, I got the following error:

ERROR: type Symmetric has no field data
 in PLSGeneral at /home/<username>/.julia/v0.3/MixedModels/src/plsgeneral.jl:24
 in lmm at /home/<username>/.julia/v0.3/MixedModels/src/linearmixedmodels.jl:79

While I can't share the original data, I was able to recreate the problem on the InstEval data. In the following example, there is no problem fitting fm1 and fm2, but fm3 will cause an error on line 7.

using MixedModels, RDatasets
inst = dataset("lme4","InstEval");
fm1 = lmm(Y ~ Service + (Service | Dept), inst)
fit(fm1)
fm2 = lmm(Y ~ Service + (1 | Dept) + (1 | S), inst)
fit(fm2)
fm3 = lmm(Y ~ Service + (Service | Dept) + (1 | S), inst) # Error on this line
fit(fm3)

This model appears to work normally in lme4 version 1.1-7:

> m <- lmer(y ~ service + (service | dept) + (1 | s), InstEval, REML = FALSE)
> summary(m)
Linear mixed model fit by maximum likelihood  ['lmerMod']
Formula: y ~ service + (service | dept) + (1 | s)
   Data: InstEval

      AIC       BIC    logLik  deviance  df.resid 
 247915.1  247979.5 -123950.6  247901.1     73414 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-2.35045 -0.80788  0.00801  0.79024  2.40056 

Random effects:
 Groups   Name        Variance Std.Dev. Corr 
 s        (Intercept) 0.09903  0.3147        
 dept     (Intercept) 0.01250  0.1118        
          service1    0.05231  0.2287   -0.49
 Residual             1.65386  1.2860        
Number of obs: 73421, groups:  s, 2972; dept, 14

Fixed effects:
            Estimate Std. Error t value
(Intercept)  3.28436    0.03159  103.96
service1    -0.07424    0.06270   -1.18

Correlation of Fixed Effects:
         (Intr)
service1 -0.486

I'm running Julia 0.3.1 installed from the Ubuntu PPA, with MixedModels 0.3.16 installed.
This is my first time using Julia and MixedModels, so my apologies if I've done something strange.

Extracting variance components

I'm trying to save the estimated variance components of each random effect to some variable. However, using VarCorr, I'm only able to extract the error variance component. Is there a way to get the others?

Thank you.

Edit: Sorry, figured it out.

Failure w/ repeated covariate names in LMM formula

Looks like the LMM formula does not allow repetition of covariate names:
fit(lmm(Leestijd ~ Nmorphs + Sex * Nmorphs +(1 |Subject), dat))
PosDefException(4)
while loading In[42], in expression starting on line 1
in cholfact! at linalg/factorization.jl:36
in PLSOne at /Users/kliegl/.julia/v0.3/MixedModels/src/plsone.jl:21
in PLSOne at /Users/kliegl/.julia/v0.3/MixedModels/src/plsone.jl:44
in lmm at /Users/kliegl/.julia/v0.3/MixedModels/src/linearmixedmodels.jl:49

Or:

fit(lmm(Leestijd ~ Nmorphs + Sex * Leesteken + Nmorphs +(1 |Subject), dat))
PosDefException(5)
while loading In[41], in expression starting on line 1
in cholfact! at linalg/factorization.jl:36
in PLSOne at /Users/kliegl/.julia/v0.3/MixedModels/src/plsone.jl:21
in PLSOne at /Users/kliegl/.julia/v0.3/MixedModels/src/plsone.jl:44
in lmm at /Users/kliegl/.julia/v0.3/MixedModels/src/linearmixedmodels.jl:49

This works: Sex*Leesteken are both new factors

m3 = fit(lmm(Leestijd ~ Nmorphs + SurfFreq + AantalGedichten + ChoiceRT + Sex * Leesteken +
(1|Word) + (1 + Nmorphs + SurfFreq|Subject) + (1|Gedicht), dat))
Out[36]:
Linear mixed model fit by maximum likelihood
logLik: 456868.218025, deviance: -913736.436050

Variance components:
Variance Std.Dev.
Word 0.000195 0.013957
Subject 0.000937 0.030607
0.000001 0.000738
0.000021 0.004628
Gedicht 0.005967 0.077244
Residual 0.002080 0.045604
Number of obs: 275996; levels of grouping factors: 2315, 326, 87

Fixed-effects parameters:
Estimate Std.Error z value
[1] 1.96267 0.00922509 212.754
[2] 0.00109424 0.000218563 5.0065
[3] -0.00449959 0.000399532 -11.2622
[4] -0.00410117 0.00147052 -2.78892
[5] 0.00858817 0.00140372 6.11813
[6] -0.00928541 0.00283121 -3.27966
[7] 0.0249195 0.000479612 51.9577
[8] -0.00349357 0.000592984 -5.8915

Crash with latest MixedModels and v0.5.0-rc3...

Using the VAM model (admittedly malformed - and run by mistake):
df = read_scores("ecls.k8.balanced.csv");
mixed = lmm(math_gr_8 ~ math_gr_5 + math_gr_3 + reading_gr_5 + reading_gr_3 + (1 + math_gr_5 + math_gr_3 + reading_gr_5 + reading_gr_3 |school_id) + (1 + math_gr_5 + math_gr_3 + reading_gr_5 + reading_gr_3 |class_id),df);
fit!(mixed)

results in:
julia> fit!(mixed);
in callback catch
ERROR: MethodError: no method matching A_mul_B!(::Base.ReshapedArray{Float64,2,SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},Tuple{}}, ::LowerTriangular{Float64,Array{Float64,2}})
Closest candidates are:
A_mul_B!(::AbstractArray{T,2}, ::Base.LinAlg.AbstractTriangular{T,S<:AbstractArray{T,2}}, ::Tridiagonal{T}) at linalg/triangular.jl:382
A_mul_B!(::AbstractArray{T,2}, ::Base.LinAlg.AbstractTriangular{T,S<:AbstractArray{T,2}}, ::Union{Bidiagonal{T},SymTridiagonal{T},Tridiagonal{T}}) at linalg/bidiag.jl:282
A_mul_B!(::AbstractArray{T,2}, ::Base.LinAlg.AbstractTriangular{T,S<:AbstractArray{T,2}}, ::Union{AbstractArray{T,1},AbstractArray{T,2}}) at linalg/triangular.jl:385
...
in tscale!(::SparseMatrixCSC{Float64,Int64}, ::LowerTriangular{Float64,Array{Float64,2}}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/paramlowertriangular.jl:153
in cfactor!(::MixedModels.LinearMixedModel{Float64}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:158
in (::MixedModels.#obj#16{MixedModels.LinearMixedModel{Float64}})(::Array{Float64,1}, ::Array{Float64,1}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:190
in nlopt_callback_wrapper(::UInt32, ::Ptr{Float64}, ::Ptr{Float64}, ::Ptr{Void}) at /Users/sjbespa/.julia/v0.5/NLopt/src/NLopt.jl:427
in optimize!(::NLopt.Opt, ::Array{Float64,1}) at /Users/sjbespa/.julia/v0.5/NLopt/src/NLopt.jl:526
in fit!(::MixedModels.LinearMixedModel{Float64}, ::Bool, ::Symbol) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:207
in fit!(::MixedModels.LinearMixedModel{Float64}) at /Users/sjbespa/.julia/v0.5/MixedModels/src/pls.jl:179

It wouldn't be hard to send you the file with the data frame.... if that would help (with instructions on where to send/upload it)...

[PkgEval] MixedModels may have a testing issue on Julia 0.4 (2014-08-15)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.4

  • On 2014-08-14 the testing status was Tests pass.
  • On 2014-08-15 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("MixedModels")' log
INFO: Installing ArrayViews v0.4.6
INFO: Installing BinDeps v0.2.14
INFO: Installing DataArrays v0.2.0
INFO: Installing DataFrames v0.5.7
INFO: Installing Distributions v0.5.4
INFO: Installing GZip v0.2.13
INFO: Installing MathProgBase v0.2.5
INFO: Installing MixedModels v0.3.9
INFO: Installing NLopt v0.1.1
INFO: Installing NumericExtensions v0.6.2
INFO: Installing NumericFuns v0.2.3
INFO: Installing PDMats v0.2.3
INFO: Installing Reexport v0.0.1
INFO: Installing SortingAlgorithms v0.0.1
INFO: Installing StatsBase v0.6.3
INFO: Installing URIParser v0.0.2
INFO: Building NLopt
INFO: Package database updated

>>> 'using MixedModels' log
Warning: could not import Base.add! into NumericExtensions

>>> test log
Warning: could not import Base.add! into NumericExtensions
ERROR: "Tests failed"
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
 in _start_3B_1724 at /home/idunning/julia04/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.4/MixedModels/test/runtests.jl, in expression starting on line 92
    [1m[31mFAILED[0m: plsonescalar.jl
    [1m[31mFAILED[0m: plsonevector.jl
    [1m[31mFAILED[0m: plsdiagnested.jl
    [1m[31mFAILED[0m: plsdiagcrossed.jl
    [1m[32mPASSED[0m: plstwo.jl
    [1m[31mFAILED[0m: lrt.jl


>>> end of log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.