|
1 | 1 | using DataFrames
|
2 | 2 | using Distributions
|
3 | 3 | using MixedModels
|
4 |
| -using Random |
5 | 4 | using Tables
|
6 | 5 | using Test
|
7 | 6 |
|
@@ -139,25 +138,27 @@ end
|
139 | 138 | @test only(m11.θ) ≈ 1.838245201739852 atol=1.e-5
|
140 | 139 | end
|
141 | 140 |
|
| 141 | + |
| 142 | +# NB: "deviance" is complicated in lme4 |
| 143 | +# there are several "deviances" defined: |
| 144 | +# https://github.com/lme4/lme4/issues/375#issuecomment-214494445 |
| 145 | +# this is the way deviance(glmm) is computed in lme4 |
| 146 | +# also called devianceCondRel in |
| 147 | +# https://github.com/lme4/lme4/blob/master/misc/logLikGLMM/logLikGLMM.R |
| 148 | +lme4deviance(x) = sum(x.resp.devresid) |
| 149 | + |
| 150 | + |
142 | 151 | @testset "dispersion parameter" begin
|
143 |
| - @testset "gaussian with non identity link" begin |
| 152 | + @testset "Gaussian with non identity link" begin |
144 | 153 | dyestuff = MixedModels.dataset(:dyestuff)
|
145 |
| - |
146 |
| - # gauss = fit(MixedModel, only(gfms[:dyestuff]), dyestuff, Normal(), LogLink(), fast=true) |
147 |
| - # @test only(gauss.θ) ≈atol=0.001 # value from lme4gaus |
148 |
| - # # this corresponds to the deviance(gauss) from lme4 |
149 |
| - # # NB: "deviance" is complicated in lme4 |
150 |
| - # # this is the way deviance(glmm) is computed in lme4 |
151 |
| - # # but there are several "deviances" defined: |
152 |
| - # # https://github.com/lme4/lme4/issues/375#issuecomment-214494445 |
153 |
| - # @test sum(gauss.resp.devresid) ≈ . atol=0.001 # value from lme4 |
154 |
| - |
155 |
| - # # bobyqa fails here |
156 |
| - # neldermead = GeneralizedLinearMixedModel(only(gfms[:dyestuff]), dyestuff, Normal(), LogLink()); |
157 |
| - # neldermead.optsum.optimizer = :LN_NELDERMEAD; |
158 |
| - # fit!(neldermead) |
159 |
| - # @test only(neldermead.θ) ≈ atol=0.001 # value from lme4 |
160 |
| - # @test sum(neldermead.resp.devresid) ≈ . atol=0.001 # value from lme4 |
| 154 | + gauss = fit(MixedModel, only(gfms[:dyestuff]), dyestuff, Normal(), LogLink(), fast=true) |
| 155 | + |
| 156 | + # reference values from lme4 |
| 157 | + # note that the LL is shifted by exactly (?!) one in Julia |
| 158 | + # I don't know why |
| 159 | + @test loglikelihood(gauss) ≈ -167.36494298739052 + 1 |
| 160 | + @test lme4deviance(gauss) ≈ 115187.5 |
| 161 | + @test only(gauss.θ) ≈ 0.0 |
| 162 | + @test only(gauss.beta) ≈ 7.331387691046023 |
161 | 163 | end
|
162 |
| - |
163 | 164 | end
|
0 commit comments