having dim memories of subject uni, i'm struggling bit fitting polynomial binomial mixed effects model 2 nested random effects.
my data counts of success , failures (s , f) @ variety of values of x. there 2 random effects, r1 , nested random effect r2.
i try fitting polynomial model, ninth order , use aic values find minimum adequate model, i'm unsure of syntax.
so i've got 3 questions really:
is code below correct?
what syntax fit glmer polynomial?
is whole thing statistical nonsense, , should try different approach?
thanks help, code below:
require(lme4) ## sample set: ## x fixed effect ## s count success ## f count fail ## r1 random effect 1 ## r2 random effect 2 sample.set <- data.frame(x = runif(1000,-100,100), s = round(runif(1000,100,1000),0), f = round(runif(1000,100,10000),0), r1 = c(rep("a",250), rep("b",250), rep("c",250), rep("d",250))) sample.set$r2 <- sapply(sample.set$r1,function(x){if(x == "a") {as.character(round(runif(1,1,5), 0 ))} else if(x == "b") {as.character(round(runif(1,6,10), 0))} else if(x == "c") {as.character(round(runif(1,11,15),0))} else {as.character(round(runif(1,16,20),0))}}) prop.tab <- cbind(sample.set$s,sample.set$f) mm.model <- glmer(prop.tab ~ sample.set$x + (sample.set$x | sample.set$r1) + (sample.set$x | sample.set$r2), family = binomial, control = glmercontrol(optimizer = "bobyqa"), nagq = 0)
Comments
Post a Comment