MixedModels.jl icon indicating copy to clipboard operation
MixedModels.jl copied to clipboard

added text in `constructors.md` to say NaN correlation is printed as a dot, fixes #819

Open ajinkya-k opened this issue 9 months ago • 4 comments

fixes #819

ajinkya-k avatar Mar 31 '25 05:03 ajinkya-k

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.33%. Comparing base (1be8517) to head (0eb0e3c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #822   +/-   ##
=======================================
  Coverage   97.33%   97.33%           
=======================================
  Files          36       36           
  Lines        3495     3495           
=======================================
  Hits         3402     3402           
  Misses         93       93           
Flag Coverage Δ
current 96.99% <ø> (ø)
minimum 97.33% <ø> (ø)
nightly 96.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Mar 31 '25 05:03 codecov[bot]

I think we might try to explain that result a little better while we are making this correction. The output looks like

julia> m1 = fit(MixedModel, @formula(reaction ~ 1 + days + (1|subj) + (days|subj)), MixedModels.dataset(:sleepstudy); contrasts=Dict(:days => DummyCoding()))
Minimizing 3068    Time: 0:00:00 ( 0.14 ms/it)
Linear mixed model fit by maximum likelihood
 reaction ~ 1 + days + (1 | subj) + (days | subj)
   logLik   -2 logLik     AIC       AICc        BIC    
  -819.1592  1638.3185  1752.3185  1806.5152  1934.3170

Variance components:
            Column    Variance  Std.Dev.   Corr.
subj     (Intercept)   882.08342 29.69989
         days: 1       403.87992 20.09676   .  
         days: 2       785.87492 28.03346   .   +0.76
         days: 3      1160.51146 34.06628   .   +0.74 +0.89
         days: 4      1375.06073 37.08181   .   +0.58 +0.67 +0.93
         days: 5      2177.61478 46.66492   .   +0.44 +0.42 +0.72 +0.85
         days: 6      3730.64143 61.07898   .   +0.27 +0.48 +0.70 +0.78 +0.76
         days: 7      1688.60255 41.09261   .   +0.16 +0.41 +0.55 +0.59 +0.64 +0.72
         days: 8      3029.32800 55.03933   .   +0.25 +0.32 +0.59 +0.71 +0.91 +0.73 +0.75
         days: 9      2999.41317 54.76690   .   +0.24 +0.11 +0.41 +0.57 +0.78 +0.38 +0.53 +0.86
Residual                54.66356  7.39348
 Number of obs: 180; levels of grouping factors: 18

  Fixed-effects parameters:
───────────────────────────────────────────────────
                 Coef.  Std. Error      z  Pr(>|z|)
───────────────────────────────────────────────────
(Intercept)  256.652       7.21398  35.58    <1e-99
days: 1        7.84395     5.33962   1.47    0.1418
days: 2        8.71009     7.05219   1.24    0.2168
days: 3       26.3402      8.3992    3.14    0.0017
days: 4       31.9976      9.08108   3.52    0.0004
days: 5       51.8667     11.2717    4.60    <1e-05
days: 6       55.5265     14.6059    3.80    0.0001
days: 7       62.0988      9.99425   6.21    <1e-09
days: 8       79.9777     13.2049    6.06    <1e-08
days: 9       94.1994     13.1418    7.17    <1e-12
───────────────────────────────────────────────────

and the dots are in the correlations of the random effects of days: 1 with other days: x random effects and the "variance component" is not estimated as zero. This is an over-specified model (more random effects than observations) so I am not even sure what these numbers mean.

Perhaps we could find a better example to illustrate the point we are trying to make. If someone (@palday ?) could tell me what the point of the discussion is, I can take a stab at illustrating it.

dmbates avatar Mar 31 '25 16:03 dmbates

I agree it's a bad example. If I recall correctly, the idea was to show the interaction of the amalgamate behavior with categorical predictors

palday avatar Apr 01 '25 02:04 palday

BTW, I was incorrect about an over-specified model because the days: 0 random effects are dropped. However, I'm still not sure what the model means.

dmbates avatar Apr 01 '25 16:04 dmbates