-
Notifications
You must be signed in to change notification settings - Fork 304
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
lmerTest #126
Comments
I'm in favor of this in principle. It will only work easily if the original model was fitted with |
Anyway, What would be the difference between coef(summary(mylmerTestmodel)) and tidy(mylmerTestmodel) ? |
A couple of small but potentially important differences:
|
OK, thanks @bbolker |
(I'm a little baffled that I can't find this comment when I view it on
GitHub: #126)
The available `effects` values (**not** well documented) are `fixed`,
`ran_pars` (for variances/covariances or std devs/correlations of random
effects) or `ran_modes` (for conditional modes/BLUPs).
Documentation leaves a lot to be desired.
It's possible that some of this stuff has diverged in my fork.
…On Sun, Aug 20, 2017 at 1:11 PM, niroshar ***@***.***> wrote:
I am trying to display tidy output for random effects using lmer function
in lme4. Why I am getting the following error.
tidy(model_ri,effects="random")
Error in tidy.merMod(model_ri, effects = "random") :
unknown effect type random
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAE0Rn0qEp0XDcuNF2-wAZBvtBA1unIwks5saGjAgaJpZM4IZnev>
.
|
@bbolker I removed the comment since I was able to get it solved using "effects = ran_pars" few minutes after. |
In future, probably worth posting your solution rather than removing
the comment (others will be similarly confused in the future ...)
…On 17-08-20 03:29 PM, niroshar wrote:
@bbolker <https://github.com/bbolker> I removed the comment since I was
able to get it solved using "effects = ran_pars" few minutes after.
Thank you very much.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAE0Rt-MAWvwFDXWdlx0r3Ds1HuTR2m2ks5saIkIgaJpZM4IZnev>.
|
That's true. Yeah, I will do so.
On Sun, Aug 20, 2017 at 3:42 PM, Ben Bolker <notifications@github.com>
wrote:
…
In future, probably worth posting your solution rather than removing
the comment (others will be similarly confused in the future ...)
On 17-08-20 03:29 PM, niroshar wrote:
> @bbolker <https://github.com/bbolker> I removed the comment since I was
> able to get it solved using "effects = ran_pars" few minutes after.
> Thank you very much.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#126 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAE0Rt-
MAWvwFDXWdlx0r3Ds1HuTR2m2ks5saIkIgaJpZM4IZnev>.
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APN_bbB0xcs5YgiVnb7akUyu4cbXUusoks5saJo7gaJpZM4IZnev>
.
--
Best regards,
Nirosha.
|
I think this works now in |
Just ran the examples in library(broom)
library(broom.mixed)
#>
#> Attaching package: 'broom.mixed'
#> The following object is masked from 'package:broom':
#>
#> tidyMCMC
library(lme4)
#> Warning: package 'lme4' was built under R version 3.4.4
#> Loading required package: Matrix
#> Warning: package 'Matrix' was built under R version 3.4.4
lmm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
tidy(lmm1)
#> effect group term estimate std.error statistic
#> 1 fixed fixed (Intercept) 251.40510485 6.824556 36.838311
#> 2 fixed fixed Days 10.46728596 1.545789 6.771485
#> 3 ran_pars Subject sd_(Intercept) 24.74044759 NA NA
#> 4 ran_pars Subject sd_Days 5.92213327 NA NA
#> 5 ran_pars Subject cor_(Intercept).Days 0.06555133 NA NA
#> 6 ran_pars Residual sd_Observation 25.59181589 NA NA
tidy(lmm1, effects = "fixed")
#> effect term estimate std.error statistic
#> 1 fixed (Intercept) 251.40510 6.824556 36.838311
#> 2 fixed Days 10.46729 1.545789 6.771485
tidy(lmm1, effects = "fixed", conf.int=TRUE)
#> effect term estimate std.error statistic conf.low conf.high
#> 1 fixed (Intercept) 251.40510 6.824556 36.838311 238.029221 264.78099
#> 2 fixed Days 10.46729 1.545789 6.771485 7.437595 13.49698
tidy(lmm1, effects = "fixed", conf.int=TRUE, conf.method="profile")
#> Computing profile confidence intervals ...
#> effect term estimate std.error statistic conf.low conf.high
#> 1 fixed (Intercept) 251.40510 6.824556 36.838311 237.680695 265.12951
#> 2 fixed Days 10.46729 1.545789 6.771485 7.358653 13.57592
tidy(lmm1, effects = "ran_modes", conf.int=TRUE)
#> Warning: package 'bindrcpp' was built under R version 3.4.4
#> effect group term level estimate std.error conf.low
#> 1 ran_modes Subject (Intercept) 308 2.2585654 12.070837 -21.39983947
#> 2 ran_modes Subject (Intercept) 309 -40.3985769 12.070837 -64.05698171
#> 3 ran_modes Subject (Intercept) 310 -38.9602458 12.070837 -62.61865063
#> 4 ran_modes Subject (Intercept) 330 23.6904985 12.070837 0.03209363
#> 5 ran_modes Subject (Intercept) 331 22.2602027 12.070837 -1.39820213
#> 6 ran_modes Subject (Intercept) 332 9.0395259 12.070837 -14.61887895
#> 7 ran_modes Subject (Intercept) 333 16.8404311 12.070837 -6.81797371
#> 8 ran_modes Subject (Intercept) 334 -7.2325792 12.070837 -30.89098405
#> 9 ran_modes Subject (Intercept) 335 -0.3336958 12.070837 -23.99210066
#> 10 ran_modes Subject (Intercept) 337 34.8903508 12.070837 11.23194592
#> 11 ran_modes Subject (Intercept) 349 -25.2101104 12.070837 -48.86851523
#> 12 ran_modes Subject (Intercept) 350 -13.0699567 12.070837 -36.72836156
#> 13 ran_modes Subject (Intercept) 351 4.5778352 12.070837 -19.08056968
#> 14 ran_modes Subject (Intercept) 352 20.8635924 12.070837 -2.79481241
#> 15 ran_modes Subject (Intercept) 369 3.2754530 12.070837 -20.38295184
#> 16 ran_modes Subject (Intercept) 370 -25.6128694 12.070837 -49.27127428
#> 17 ran_modes Subject (Intercept) 371 0.8070397 12.070837 -22.85136511
#> 18 ran_modes Subject (Intercept) 372 12.3145393 12.070837 -11.34386550
#> 19 ran_modes Subject Days 308 9.1989719 2.304837 4.68157445
#> 20 ran_modes Subject Days 309 -8.6197032 2.304837 -13.13710067
#> 21 ran_modes Subject Days 310 -5.4488799 2.304837 -9.96627739
#> 22 ran_modes Subject Days 330 -4.8143313 2.304837 -9.33172878
#> 23 ran_modes Subject Days 331 -3.0698946 2.304837 -7.58729207
#> 24 ran_modes Subject Days 332 -0.2721707 2.304837 -4.78956813
#> 25 ran_modes Subject Days 333 -0.2236244 2.304837 -4.74102191
#> 26 ran_modes Subject Days 334 1.0745761 2.304837 -3.44282140
#> 27 ran_modes Subject Days 335 -10.7521591 2.304837 -15.26955659
#> 28 ran_modes Subject Days 337 8.6282840 2.304837 4.11088649
#> 29 ran_modes Subject Days 349 1.1734142 2.304837 -3.34398323
#> 30 ran_modes Subject Days 350 6.6142050 2.304837 2.09680752
#> 31 ran_modes Subject Days 351 -3.0152572 2.304837 -7.53265466
#> 32 ran_modes Subject Days 352 3.5360133 2.304837 -0.98138416
#> 33 ran_modes Subject Days 369 0.8722166 2.304837 -3.64518087
#> 34 ran_modes Subject Days 370 4.8224646 2.304837 0.30506714
#> 35 ran_modes Subject Days 371 -0.9881551 2.304837 -5.50555257
#> 36 ran_modes Subject Days 372 1.2840297 2.304837 -3.23336773
#> conf.high
#> 1 25.9169702
#> 2 -16.7401720
#> 3 -15.3018409
#> 4 47.3489033
#> 5 45.9186076
#> 6 32.6979308
#> 7 40.4988360
#> 8 16.4258257
#> 9 23.3247090
#> 10 58.5487556
#> 11 -1.5517055
#> 12 10.5884481
#> 13 28.2362400
#> 14 44.5219973
#> 15 26.9338579
#> 16 -1.9544646
#> 17 24.4654446
#> 18 35.9729442
#> 19 13.7163694
#> 20 -4.1023057
#> 21 -0.9314824
#> 22 -0.2969338
#> 23 1.4475029
#> 24 4.2452268
#> 25 4.2937730
#> 26 5.5919736
#> 27 -6.2347616
#> 28 13.1456814
#> 29 5.6908117
#> 30 11.1316025
#> 31 1.5021403
#> 32 8.0534108
#> 33 5.3896141
#> 34 9.3398621
#> 35 3.5292424
#> 36 5.8014272
head(augment(lmm1, sleepstudy))
#> Reaction Days Subject .fitted .resid .fixed .mu .offset
#> 1 249.5600 0 308 253.6637 -4.103670 251.4051 253.6637 0
#> 2 258.7047 1 308 273.3299 -14.625228 261.8724 273.3299 0
#> 3 250.8006 2 308 292.9962 -42.195586 272.3397 292.9962 0
#> 4 321.4398 3 308 312.6624 8.777356 282.8070 312.6624 0
#> 5 356.8519 4 308 332.3287 24.523198 293.2742 332.3287 0
#> 6 414.6901 5 308 351.9950 62.695140 303.7415 351.9950 0
#> .sqrtXwt .sqrtrwt .weights .wtres
#> 1 1 1 1 -4.103670
#> 2 1 1 1 -14.625228
#> 3 1 1 1 -42.195586
#> 4 1 1 1 8.777356
#> 5 1 1 1 24.523198
#> 6 1 1 1 62.695140
glance(lmm1)
#> sigma logLik AIC BIC deviance df.residual
#> 1 25.59182 -871.8141 1755.628 1774.786 1743.628 174
glmm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial)
tidy(glmm1)
#> effect group term estimate std.error statistic
#> 1 fixed fixed (Intercept) -1.3983429 0.2312140 -6.047828
#> 2 fixed fixed period2 -0.9919250 0.3031506 -3.272053
#> 3 fixed fixed period3 -1.1282162 0.3228301 -3.494767
#> 4 fixed fixed period4 -1.5797454 0.4220492 -3.743037
#> 5 ran_pars herd sd_(Intercept) 0.6420699 NA NA
#> p.value
#> 1 1.468113e-09
#> 2 1.067695e-03
#> 3 4.744754e-04
#> 4 1.818098e-04
#> 5 NA
tidy(glmm1, effects = "fixed")
#> effect term estimate std.error statistic p.value
#> 1 fixed (Intercept) -1.398343 0.2312140 -6.047828 1.468113e-09
#> 2 fixed period2 -0.991925 0.3031506 -3.272053 1.067695e-03
#> 3 fixed period3 -1.128216 0.3228301 -3.494767 4.744754e-04
#> 4 fixed period4 -1.579745 0.4220492 -3.743037 1.818098e-04
head(augment(glmm1, cbpp))
#> herd incidence size period .fitted .resid .fixed .mu
#> 1 1 2 14 1 -0.8087134 -1.4377078 -1.398343 0.30816472
#> 2 1 3 12 2 -1.8006384 0.9884720 -2.390268 0.14177337
#> 3 1 4 9 3 -1.9369296 2.3566883 -2.526559 0.12598556
#> 4 1 0 5 4 -2.3884588 -0.9370227 -2.978088 0.08405701
#> 5 2 3 22 1 -1.6974362 -0.2431732 -1.398343 0.15480041
#> 6 2 1 18 2 -2.6893612 -0.1428294 -2.390268 0.06360406
#> .offset .sqrtXwt .sqrtrwt .weights .wtres .eta
#> 1 0 1.7276542 8.103473 14 -1.3395656 -0.8087134
#> 2 0 1.2083394 9.930984 12 1.0747970 -1.8006384
#> 3 0 0.9954992 9.040690 9 2.8790881 -1.9369296
#> 4 0 0.6204492 8.058678 5 -0.6773884 -2.3884588
#> 5 0 1.6965905 12.967183 22 -0.2390730 -1.6974362
#> 6 0 1.0354006 17.384575 18 -0.1399198 -2.6893612
glance(glmm1)
#> sigma logLik AIC BIC deviance df.residual
#> 1 1 -92.02657 194.0531 204.1799 73.47428 51 The next part gives me some warnings that I though were errors at first but otherwise appears fine: startvec <- c(Asym = 200, xmid = 725, scal = 350)
nm1 <- nlmer(circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym|Tree,
Orange, start = startvec)
tidy(nm1)
#> Warning in vcov.merMod(object, use.hessian = use.hessian): variance-covariance matrix computed from finite-difference Hessian is
#> not positive definite or contains NA values: falling back to var-cov estimated from RX
#> Warning in vcov.merMod(object, correlation = correlation, sigm = sig): variance-covariance matrix computed from finite-difference Hessian is
#> not positive definite or contains NA values: falling back to var-cov estimated from RX
#> effect group term estimate std.error statistic
#> 1 fixed fixed Asym 192.052792 15.58385 12.32383
#> 2 fixed fixed xmid 727.904473 34.43847 21.13637
#> 3 fixed fixed scal 348.072134 26.30812 13.23060
#> 4 ran_pars Tree sd_Asym 31.646324 NA NA
#> 5 ran_pars Residual sd_Observation 7.843009 NA NA
tidy(nm1, effects = "fixed")
#> Warning in vcov.merMod(object, use.hessian = use.hessian): variance-covariance matrix computed from finite-difference Hessian is
#> not positive definite or contains NA values: falling back to var-cov estimated from RX
#> Warning in vcov.merMod(object, use.hessian = use.hessian): variance-covariance matrix computed from finite-difference Hessian is
#> not positive definite or contains NA values: falling back to var-cov estimated from RX
#> effect term estimate std.error statistic
#> 1 fixed Asym 192.0528 15.58385 12.32383
#> 2 fixed xmid 727.9045 34.43847 21.13637
#> 3 fixed scal 348.0721 26.30812 13.23060
head(augment(nm1, Orange))
#> Warning in indices[which(stats::complete.cases(original))] =
#> seq_len(nrow(x)): number of items to replace is not a multiple of
#> replacement length
#> Tree age circumference .fitted .resid .mu .offset .sqrtXwt
#> 1 1 118 30 24.01051 5.989486 24.01051 0 0.1477654
#> 2 1 484 58 53.89014 4.109864 53.89014 0 0.3316505
#> 3 1 664 87 73.80812 13.191884 73.80812 0 0.4542296
#> 4 1 1004 115 111.87829 3.121713 111.87829 0 0.6885209
#> 5 1 1231 120 131.50149 -11.501489 131.50149 0 0.8092860
#> 6 1 1372 142 140.42155 1.578450 140.42155 0 0.8641818
#> .sqrtrwt .weights .wtres .gam
#> 1 1 1 5.989486 162.4908
#> 2 1 1 4.109864 162.4908
#> 3 1 1 13.191884 162.4908
#> 4 1 1 3.121713 162.4908
#> 5 1 1 -11.501489 162.4908
#> 6 1 1 1.578450 162.4908
glance(nm1)
#> sigma logLik AIC BIC deviance df.residual
#> 1 7.843009 -131.5719 273.1438 280.9205 263.1438 30 Closing as all seems to be in order. |
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
It would be great if broom also showed the output of lmerTest alongside the lme4 output.
This package simply adds a new column with the p-value.
The text was updated successfully, but these errors were encountered: