[R] glmer, Error: Downdated X'X is not positive definite,49
Douglas Bates
bates at stat.wisc.edu
Tue Nov 16 18:43:39 CET 2010
It is often more effective to send questions about lmer or glmer to
the R-SIG-Mixed-Models at R-project.org mailing list, which I am cc:ing
on this response.
On Tue, Nov 16, 2010 at 3:25 AM, Annika <annika.opperbeck at jyu.fi> wrote:
>
> Dear list,
>
> I am new to this list and I am new to the world of R. Additionally I am not
> very firm in statistics either but have to deal. So here is my problem:
> I have a dataset (which I attach at the end of the post) with a binomial
> response variable (alive or not) and three fixed factors
> (trapping,treat,sex). I do have repeated measures and would like to include
> one (enclosure) random factor.
> I chose to use the glmer function (and tried the lmer as well).
>
> m1<-glmer(alive~treat*sex*trapping*ID+(1|enclosure),family=binomial,data=survadult)
Is ID a factor? In the data you posted it is an integer value but I
am guessing it should be a factor. If so, you can't incorporate it in
the model because there is only one binary observation per level of
ID.
If I omit the ID in the fixed-effects part of the formula I can fit
the model with glmer.
> summary(m1 <- glmer(alive ~ trapping * treat * sex + (1|enclosure), trap, binomial))
Generalized linear mixed model fit by maximum likelihood ['summary.mer']
Family: binomial
Formula: alive ~ trapping * treat * sex + (1 | enclosure)
Data: trap
AIC BIC logLik deviance
213.2111 334.5440 -73.6056 147.2111
Random effects:
Groups Name Variance Std.Dev.
enclosure (Intercept) 1.372 1.171
Number of obs: 292, groups: enclosure, 13
Fixed effects:
Estimate Std. Error z value
(Intercept) 10.61897 45.92452 0.231
trappingtrapping2 0.03992 65.59766 0.001
trappingtrapping3 -0.01196 64.74665 0.000
trappingtrapping4 -0.74441 71.77010 -0.010
treatm/p -0.26605 72.78328 -0.004
treatp/m -0.18007 81.63861 -0.002
treatp/p 0.50290 64.45725 0.008
sexm -8.61299 45.92746 -0.188
trappingtrapping2:treatm/p -0.03657 103.39000 0.000
trappingtrapping3:treatm/p -0.04916 101.87680 0.000
trappingtrapping4:treatm/p -10.26432 91.32210 -0.112
trappingtrapping2:treatp/m -0.04047 115.80425 0.000
trappingtrapping3:treatp/m -8.59631 93.53334 -0.092
trappingtrapping4:treatp/m -7.92162 98.52543 -0.080
trappingtrapping2:treatp/p -0.05942 91.39839 -0.001
trappingtrapping3:treatp/p -7.83591 78.98418 -0.099
trappingtrapping4:treatp/p -9.60581 84.83662 -0.113
trappingtrapping2:sexm 0.92624 65.61333 0.014
trappingtrapping3:sexm -1.45692 64.75568 -0.022
trappingtrapping4:sexm -0.88035 71.77685 -0.012
treatm/p:sexm 8.69446 93.57164 0.093
treatp/m:sexm 8.61957 106.06371 0.081
treatp/p:sexm 0.86615 64.46538 0.013
trappingtrapping2:treatm/p:sexm -9.03327 118.95919 -0.076
trappingtrapping3:treatm/p:sexm -7.51474 117.64003 -0.064
trappingtrapping4:treatm/p:sexm 0.81873 108.62671 0.008
trappingtrapping2:treatp/m:sexm -9.51400 134.16089 -0.071
trappingtrapping3:treatp/m:sexm 0.48425 115.47998 0.004
trappingtrapping4:treatp/m:sexm -2.37780 119.56181 -0.020
trappingtrapping2:treatp/p:sexm -0.93097 91.42477 -0.010
trappingtrapping3:treatp/p:sexm 7.55060 79.00487 0.096
trappingtrapping4:treatp/p:sexm 9.47461 84.85476 0.112
> Both give the following error message:
> Error in mer_finalize(ans) : Downdated X'X is not positive definite,
> 49.
> Additionally: Warning:
> glm.fit: fitted probabilities numerically 0 or 1 occurred
> I get that there is something wrong in my dataframe, but I don`t understand
> what and how I could change it.
> If I run a glm without the random factor
> m1<-glm(alive~treat*sex*trapping*ID,family=binomial,data=survadult)
> it works out really fine, but is the wrong analysis in my opinion. (Does glm
> actually consider the repeated measures? Does glmer?)
>
> Is glmer the right function for me and how do I deal with the error I get?
>
> Thanks for any help for a non-professional :)
>
> Annika
>
>
> trapping treat sex alive ID enclosure
> trapping1 m/m f 1 400 1
> trapping1 m/m f 1 401 1
> trapping1 m/m f 1 402 1
> trapping1 m/m m 0 403 1
> trapping1 m/m m 1 404 1
> trapping1 m/m m 1 405 1
> trapping1 m/p f 1 406 2
> trapping1 m/p f 1 407 2
> trapping1 m/p f 1 408 2
> trapping1 m/p m 1 409 2
> trapping1 m/p m 1 410 2
> trapping1 m/p m 1 411 2
> trapping1 p/p f 1 412 3
> trapping1 p/p f 1 413 3
> trapping1 p/p f 1 414 3
> trapping1 p/p m 1 415 3
> trapping1 p/p m 1 416 3
> trapping1 p/p m 1 417 3
> trapping1 p/p f 1 418 4
> trapping1 p/p f 1 419 4
> trapping1 p/p f 1 420 4
> trapping1 p/p m 1 421 4
> trapping1 p/p m 1 422 4
> trapping1 p/p m 1 423 4
> trapping1 m/m f 1 424 5
> trapping1 m/m f 1 425 5
> trapping1 m/m f 1 426 5
> trapping1 m/m m 1 427 5
> trapping1 m/m m 1 428 5
> trapping1 m/m m 1 429 5
> trapping1 p/m f 1 430 6
> trapping1 p/m f 1 431 6
> trapping1 p/m f 1 432 6
> trapping1 p/m m 1 433 6
> trapping1 p/m m 1 434 6
> trapping1 p/m m 1 435 6
> trapping1 m/p f 1 436 7
> trapping1 m/p f 1 437 7
> trapping1 m/p f 1 438 7
> trapping1 m/p m 1 439 7
> trapping1 m/p m 1 440 7
> trapping1 m/p m 1 441 7
> trapping1 p/p f 1 442 8
> trapping1 p/p f 1 443 8
> trapping1 p/p f 1 444 8
> trapping1 p/p m 1 445 8
> trapping1 p/p m 1 446 8
> trapping1 p/p m 1 447 8
> trapping1 m/m f 1 448 9
> trapping1 m/m f 1 449 9
> trapping1 m/m f 1 450 9
> trapping1 m/m m 1 451 9
> trapping1 m/m m 1 452 9
> trapping1 m/m m 1 453 9
> trapping1 p/m f 1 454 10
> trapping1 p/m f 1 455 10
> trapping1 p/m f 1 456 10
> trapping1 p/m m 1 457 10
> trapping1 p/m m 1 458 10
> trapping1 p/m m 1 459 10
> trapping1 m/m f 1 460 11
> trapping1 m/m f 1 461 11
> trapping1 m/m f 1 462 11
> trapping1 m/m m 1 463 11
> trapping1 m/m m 1 464 11
> trapping1 m/m m 0 465 11
> trapping1 p/p f 1 466 12
> trapping1 p/p f 1 467 12
> trapping1 p/p f 1 468 12
> trapping1 p/p m 1 469 12
> trapping1 p/p m 0 470 12
> trapping1 p/p m 1 471 12
> trapping1 m/p f 1 472 13
> trapping1 m/p f 1 473 13
> trapping1 m/p f 1 474 13
> trapping1 m/p m 1 475 13
> trapping1 m/p m 1 476 13
> trapping1 m/p m 1 477 13
> trapping2 m/m f 1 478 1
> trapping2 m/m f 1 479 1
> trapping2 m/m f 1 480 1
> trapping2 m/m m 1 481 1
> trapping2 m/m m 1 482 1
> trapping2 m/m m 1 483 1
> trapping2 m/p f 1 484 2
> trapping2 m/p f 1 485 2
> trapping2 m/p f 1 486 2
> trapping2 m/p m 0 487 2
> trapping2 m/p m 1 488 2
> trapping2 m/p m 1 489 2
> trapping2 p/p f 1 490 3
> trapping2 p/p f 1 491 3
> trapping2 p/p f 1 492 3
> trapping2 p/p m 1 493 3
> trapping2 p/p m 1 494 3
> trapping2 p/p m 1 495 3
> trapping2 p/p f 1 496 4
> trapping2 p/p f 1 497 4
> trapping2 p/p f 1 498 4
> trapping2 p/p m 1 499 4
> trapping2 p/p m 1 500 4
> trapping2 p/p m 1 501 4
> trapping2 m/m f 1 502 5
> trapping2 m/m f 1 503 5
> trapping2 m/m f 1 504 5
> trapping2 m/m m 1 505 5
> trapping2 m/m m 1 506 5
> trapping2 m/m m 1 507 5
> trapping2 p/m f 1 508 6
> trapping2 p/m f 1 509 6
> trapping2 p/m f 1 510 6
> trapping2 p/m m 1 511 6
> trapping2 p/m m 1 512 6
> trapping2 p/m m 1 513 6
> trapping2 m/p f 1 514 7
> trapping2 m/p f 1 515 7
> trapping2 m/p f 1 516 7
> trapping2 m/p m 1 517 7
> trapping2 m/p m 1 518 7
> trapping2 m/p m 1 519 7
> trapping2 p/p f 1 520 8
> trapping2 p/p f 1 521 8
> trapping2 p/p f 1 522 8
> trapping2 p/p m 1 523 8
> trapping2 p/p m 1 524 8
> trapping2 p/p m 1 525 8
> trapping2 m/m f 1 526 9
> trapping2 m/m f 1 527 9
> trapping2 m/m f 1 528 9
> trapping2 m/m m 1 529 9
> trapping2 m/m m 1 530 9
> trapping2 m/m m 1 531 9
> trapping2 p/m f 1 532 10
> trapping2 p/m f 1 533 10
> trapping2 p/m f 1 534 10
> trapping2 p/m m 1 535 10
> trapping2 p/m m 1 536 10
> trapping2 p/m m 0 537 10
> trapping2 m/m f 1 538 11
> trapping2 m/m f 1 539 11
> trapping2 m/m f 1 540 11
> trapping2 m/m m 1 541 11
> trapping2 m/m m 0 542 11
> trapping2 m/m m 1 543 11
> trapping2 p/p f 1 544 12
> trapping2 p/p f 1 545 12
> trapping2 p/p f 1 546 12
> trapping2 p/p m 0 547 12
> trapping2 p/p m 1 548 12
> trapping2 p/p m 1 549 12
> trapping2 m/p f 1 550 13
> trapping2 m/p f 1 551 13
> trapping2 m/p f 1 552 13
> trapping2 m/p m 1 553 13
> trapping2 m/p m 1 554 13
> trapping2 m/p m 1 555 13
> trapping3 m/m f 1 556 1
> trapping3 m/m f 1 557 1
> trapping3 m/m f 1 558 1
> trapping3 m/m m 1 559 1
> trapping3 m/m m 1 560 1
> trapping3 m/m m 1 561 1
> trapping3 m/p f 1 562 2
> trapping3 m/p f 1 563 2
> trapping3 m/p f 1 564 2
> trapping3 m/p m 1 565 2
> trapping3 m/p m 1 566 2
> trapping3 m/p m 0 567 2
> trapping3 p/p f 1 568 3
> trapping3 p/p f 1 569 3
> trapping3 p/p f 1 570 3
> trapping3 p/p m 1 571 3
> trapping3 p/p m 1 572 3
> trapping3 p/p m 1 573 3
> trapping3 p/p f 1 574 4
> trapping3 p/p f 1 575 4
> trapping3 p/p f 1 576 4
> trapping3 p/p m 1 577 4
> trapping3 p/p m 1 578 4
> trapping3 p/p m 1 579 4
> trapping3 m/m f 1 580 5
> trapping3 m/m f 1 581 5
> trapping3 m/m f 1 582 5
> trapping3 m/m m 1 583 5
> trapping3 m/m m 0 584 5
> trapping3 m/m m 1 585 5
> trapping3 p/m f 1 586 6
> trapping3 p/m f 1 587 6
> trapping3 p/m f 1 588 6
> trapping3 p/m m 0 589 6
> trapping3 p/m m 1 590 6
> trapping3 p/m m 1 591 6
> trapping3 m/p f 1 592 7
> trapping3 m/p f 1 593 7
> trapping3 m/p f 1 594 7
> trapping3 m/p m 1 595 7
> trapping3 m/p m 1 596 7
> trapping3 m/p m 1 597 7
> trapping3 p/p f 1 598 8
> trapping3 p/p f 1 599 8
> trapping3 p/p f 1 600 8
> trapping3 p/p m 1 601 8
> trapping3 p/p m 1 602 8
> trapping3 p/p m 1 603 8
> trapping3 m/m f 1 604 9
> trapping3 m/m f 1 605 9
> trapping3 m/m f 1 606 9
> trapping3 m/m m 0 607 9
> trapping3 m/m m 1 608 9
> trapping3 m/m m 1 609 9
> trapping3 p/m f 1 610 10
> trapping3 p/m f 0 611 10
> trapping3 p/m f 1 612 10
> trapping3 p/m m 1 613 10
> trapping3 p/m m 1 614 10
> trapping3 p/m m 0 615 10
> trapping3 m/m f 1 616 11
> trapping3 m/m f 1 617 11
> trapping3 m/m f 1 618 11
> trapping3 m/m m 0 619 11
> trapping3 m/m m 0 620 11
> trapping3 m/m m 0 621 11
> trapping3 p/p f 1 622 12
> trapping3 p/p f 0 623 12
> trapping3 p/p f 1 624 12
> trapping3 p/p m 0 625 12
> trapping3 p/p m 0 626 12
> trapping3 p/p m 0 627 12
> trapping3 m/p f 1 628 13
> trapping3 m/p f 1 629 13
> trapping3 m/p f 1 630 13
> trapping3 m/p m 1 631 13
> trapping3 m/p m 1 632 13
> trapping3 m/p m 0 633 13
> trapping4 m/m f 1 634 1
> trapping4 m/m f 1 635 1
> trapping4 m/m f 1 636 1
> trapping4 m/m m 1 637 1
> trapping4 m/m m 1 638 1
> trapping4 m/m m 1 639 1
> trapping4 m/p f 1 640 2
> trapping4 m/p f 1 641 2
> trapping4 m/p f 0 642 2
> trapping4 m/p m 1 643 2
> trapping4 m/p m 1 644 2
> trapping4 m/p m 0 645 2
> trapping4 p/p f 1 646 3
> trapping4 p/p f 0 647 3
> trapping4 p/p f 1 648 3
> trapping4 p/p m 1 649 3
> trapping4 p/p m 0 650 3
> trapping4 p/p m 1 651 3
> trapping4 p/p f 1 652 4
> trapping4 p/p f 1 653 4
> trapping4 p/p f 1 654 4
> trapping4 p/p m 1 655 4
> trapping4 p/p m 1 656 4
> trapping4 p/p m 1 657 4
> trapping4 m/m f 1 658 5
> trapping4 m/m f 1 659 5
> trapping4 m/m f 1 660 5
> trapping4 m/m m 1 661 5
> trapping4 m/m m 0 662 5
> trapping4 m/m m 0 663 5
> trapping4 p/m f 1 664 6
> trapping4 p/m f 1 665 6
> trapping4 p/m f 1 666 6
> trapping4 p/m m 1 667 6
> trapping4 p/m m 0 668 6
> trapping4 p/m m 0 669 6
> trapping4 m/p f 0 670 7
> trapping4 m/p f 0 671 7
> trapping4 m/p f 0 672 7
> trapping4 m/p m 0 673 7
> trapping4 m/p m 0 674 7
> trapping4 m/p m 0 675 7
> trapping4 p/p f 1 676 8
> trapping4 p/p f 1 677 8
> trapping4 p/p f 0 678 8
> trapping4 p/p m 1 679 8
> trapping4 p/p m 1 680 8
> trapping4 p/p m 1 681 8
> trapping4 m/m f 1 682 9
> trapping4 m/m f 1 683 9
> trapping4 m/m f 1 684 9
> trapping4 m/m m 1 685 9
> trapping4 m/m m 1 686 9
> trapping4 m/m m 0 687 9
> trapping4 p/m f 0 688 10
> trapping4 p/m f 1 689 10
> trapping4 p/m f 1 690 10
> trapping4 p/m m 0 691 10
> --
> View this message in context: http://r.789695.n4.nabble.com/glmer-Error-Downdated-X-X-is-not-positive-definite-49-tp3044470p3044470.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list