Residuals from LinearMixed Models (Julia 0.6.3)

question

#1

I am in the process of migrating the Julia .3.2 version to 0.6.3 … We had a function/variable in 0.3.2 “resid” to extract the residual from the model. Do we have any equivalent function in 0.6.3?

lmm= fit!(LinearMixedModel(@formula(A~ 1 + B+ C+ ( ( 0 + B) | byVar) + ( ( 0 + C) | byVar) ),df),true)
lmm.resid?

Regards,
Harish


#2

It is best to use the generic extractor functions from the StatsBase

julia> m1 = fit(LinearMixedModel, @formula(Y ~ 1 + (1|G)), dat[:Dyestuff])
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.3332 37.260344
 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


julia> StatsBase.residuals(m1)
30-element Array{Float64,1}:
  34.1282
 -70.8718
 -70.8718
   9.12822
  69.1282
  12.1305
  27.1305
 -37.8695
  32.1305
 -32.8695
  40.5253
  -4.47467
  50.5253
 -44.4747
   5.52533
 -60.6986
 -65.6986
  89.3014
 -40.6986
  39.3014
  13.9202
  48.9202
 -66.0798
  53.9202
  43.9202
  34.9943
 -30.0057
 -35.0057
  -5.00566
 -40.0057

If you depend upon a field name by using, e.g., lmm.resid, then everything falls apart when the internal representation changes, which, in my packages, it does frequently. My favorite Oscar Wilde quote is

Consistency is the last refuge of the unimaginative.

For the next release (not the one from earlier today), I’ll reexport the residuals name so you don’t need to use using StatsBase or StatsBase.residuals.


#3

Thank you.;