Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deviance for families with dispersion parameter #206

Open
palday opened this issue Oct 1, 2019 · 0 comments · May be fixed by #291
Open

Deviance for families with dispersion parameter #206

palday opened this issue Oct 1, 2019 · 0 comments · May be fixed by #291
Labels
Milestone

Comments

@palday
Copy link
Member

palday commented Oct 1, 2019

Currently, the dispersion parameter for families with one isn't taken into account when calculating the deviance for GLMMs. For example, in Julia we have:

julia> lexdec_glmm_gamma
Generalized Linear Mixed Model fit by maximum likelihood (nAGQ = 1)
  rt_raw ~ 1 + Class + NativeLanguage + Class & NativeLanguage + (1 | Subject) + (1 | Word)
  Distribution: Gamma{Float64}
  Link: IdentityLink()

  Deviance: 91.9052

Variance components:
             Column    Variance Std.Dev. 
 Word    (Intercept)     0.0000  0.00000
 Subject (Intercept)  1508.7803 38.84302
 Number of obs: 1659; levels of grouping factors: 79, 21

Fixed-effects parameters:
──────────────────────────────────────────────────────────────────────────────
                                       Estimate  Std.Error    z value  P(>|z|)
──────────────────────────────────────────────────────────────────────────────
(Intercept)                           563.552      6.69785  84.1393     <1e-99
Class: plant                            6.43673    9.20547   0.699229   0.4844
NativeLanguage: Other                 114.543     11.2587   10.1737     <1e-23
Class: plant & NativeLanguage: Other  -29.3668    15.495    -1.89524    0.0581
──────────────────────────────────────────────────────────────────────────────

julia> loglikelihood(lexdec_glmm_gamma)
ERROR: MethodError: no method matching Gamma{Float64}(::Float64)
Closest candidates are:
  Gamma{Float64}(::Any, ::Any) where T at /home/XXX/.julia/packages/Distributions/Vcqls/src/univariate/continuous/gamma.jl:30
Stacktrace:
 [1] loglikelihood(::GeneralizedLinearMixedModel{Float64}) at /home/XXX/Work/MixedModels.jl/src/generalizedlinearmixedmodel.jl:301
 [2] top-level scope at none:0

But in R we have:

R> summary(lexdec_glmm_gamma)
Generalized linear mixed model fit by maximum likelihood (Laplace
  Approximation) [glmerMod]
 Family: Gamma  ( identity )
Formula: rt_raw ~ 1 + Class * NativeLanguage + (1 | Subject) + (1 | Word)
   Data: lexdec

     AIC      BIC   logLik deviance df.resid 
 20339.4  20377.3 -10162.7  20325.4     1652 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-1.7910 -0.5810 -0.1798  0.3265  8.2691 

Random effects:
 Groups   Name        Variance  Std.Dev.
 Word     (Intercept) 1.533e+03 39.1482 
 Subject  (Intercept) 1.915e+03 43.7595 
 Residual             4.142e-02  0.2035 
Number of obs: 1659, groups:  Word, 79; Subject, 21

Fixed effects:
                               Estimate Std. Error t value Pr(>|z|)    
(Intercept)                     588.839     11.955  49.255   <2e-16 ***
Classplant                        4.894     11.218   0.436   0.6627    
NativeLanguageOther             115.619     13.578   8.515   <2e-16 ***
Classplant:NativeLanguageOther  -28.138      9.379  -3.000   0.0027 ** 
---
Signif. codes:  0***0.001**0.01*0.05.0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) Clsspl NtvLnO
Classplant  -0.109              
NtvLnggOthr -0.044 -0.071       
Clsspln:NLO  0.039 -0.085  0.034

R> deviance(lexdec_glmm_gamma)
[1] 52.56222
R> -2 * logLik(lexdec_glmm_gamma)
'log Lik.' 20325.38 (df=7)

See also lme4/lme4#375.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant