[Lme4-commits] r1792 - pkg/lme4/testsx
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 19 22:25:07 CET 2012
Author: bbolker
Date: 2012-12-19 22:25:06 +0100 (Wed, 19 Dec 2012)
New Revision: 1792
Modified:
pkg/lme4/testsx/testcrab.R
Log:
updated, added coefplot2 and MCMCglmm stuff
Modified: pkg/lme4/testsx/testcrab.R
===================================================================
--- pkg/lme4/testsx/testcrab.R 2012-10-20 20:43:40 UTC (rev 1791)
+++ pkg/lme4/testsx/testcrab.R 2012-12-19 21:25:06 UTC (rev 1792)
@@ -7,8 +7,8 @@
library(ggplot2)
library(grid)
-zmargin <- opts(panel.margin=unit(0,"lines"))
-theme_update(theme_bw())
+zmargin <- theme(panel.margin=unit(0,"lines"))
+theme_set(theme_bw())
g1 <- ggplot(randdata0,aes(x=snail.size,y=surv,colour=snail.size,fill=snail.size))+
geom_hline(yintercept=1,colour="black")+
stat_sum(aes(size=factor(..n..)),alpha=0.6)+
@@ -19,24 +19,53 @@
library(lme4)
+## FIXME: this test doesn't quite work, CRAN-lme4 is now 0.999999-0
if (packageVersion("lme4")>"0.999375-42") {
## using development lme4 ...
try(glmer1 <- glmer(fr2,weights=initial.snail.density,family ="binomial", data=randdata))
## pwrssUpdate did not converge
try(glmer1B <- glmer(fr,family ="binomial", data=randdata))
if (require("lme4.0")) {
- detach("package:lme4")
+ detach("package:lme4",unload=TRUE)
## prop/weights formulation
glmer1 <- glmer(fr2,weights=initial.snail.density,family ="binomial", data=randdata)
## alive/dead formulation
glmer1B <- glmer(fr,family ="binomial", data=randdata)
coef(glmer1B)
+ fixef(glmer1B)
detach("package:lme4.0")
}
if (require("glmmADMB")) {
## prop/weights formulation
- glmer1B <- glmmadmb(fr,family ="binomial", data=randdata)
+ glmer1C <- glmmadmb(fr,family ="binomial", data=randdata)
}
+ if (require("MCMCglmm")) {
+ ## prop/weights formulation
+ ff <- lme4:::nobars(fr)
+ ff <- ff[-2] ## delete response
+ X <- model.matrix(ff,data=randdata)
+ npar <- ncol(X)
+ fit1D <- MCMCglmm(cbind(final.snail.density, snails.lost) ~
+ crab.speciesS + crab.speciesW +
+ crab.sizeS + crab.sizeM + snail.sizeS + crab.speciesS:crab.sizeS +
+ crab.speciesS:crab.sizeM + crab.speciesS:snail.sizeS +
+ crab.speciesW:snail.sizeS +
+ crab.sizeS:snail.sizeS + crab.sizeM:snail.sizeS +
+ crab.speciesS:crab.sizeS:snail.sizeS +
+ crab.speciesS:crab.sizeM:snail.sizeS,
+ random=~us(1+snail.size):plot,
+ family="multinomial2",
+ data=randdata,
+ prior=list(B=list(mu=rep(0,npar),V=diag(npar)*1e3),
+ G=list(list(nu=10,V=diag(2))),
+ R=list(nu=10,V=1)),
+ verbose=FALSE)
+ }
+ if (require("coefplot2")) {
+ cc2 <- coeftab(fit1D)
+ rownames(cc2) <- gsub("^Sol\\.","",rownames(cc2))
+ coefplot2(list(glmer1B,glmer1C,cc2),col=c(1,2,4))
+ }
} else {
## CRAN version of lme4
glmer1 <- glmer(fr2,weights=initial.snail.density,family ="binomial", data=randdata)
@@ -47,3 +76,6 @@
fixef(glmer1B)
## note in this case that variances are not converging to zero
VarCorr(glmer1)
+
+if (FALSE) {
+ library(glmmADMB)
More information about the Lme4-commits
mailing list