glmmADMB (mixed binomal random effects)
On 14-02-28 05:19 PM, Julian Chen wrote:
Hello: I am new to this and now running a simple model of mixed effects negative binomial regression by using glmmADMB my data is very simple as follows: Counts Year Test1 Test2 Here counts is the number of students annually admitted (could be zero) Year 1 to 6 (totally 6 numbers represnts six years) Test 1 is the score of test one range from (0 to 100) Test 2 is the score of test two range from (0 to 100) Here I asssume Variable Year is random effects. The following is the model I used: rnb1<-glmmadmb(ACC ~ F1 + F2 + (1|YR), data=dat, family="nbinom", link="log"); But I always got the wrong message as below: rnb1<-glmmadmb(Counts ~ Test1 + Test2 + (1|Year), data=dat, family="nbinom", link="log"); Error in Droplevels(eval(parse(text = x), data)) : all grouping variables in random effects must be factors I have no idea what I should do now? Please give me some comments. Many thanks!
[cc'ing to r-sig-mixed-models]
make sure that your grouping variable (Year) is a factor.
Year is coded as numeric. Your choices:
1. convert to a factor on the fly:
Counts ~ Test1 + Test2 + (1|factor(Year)
2. convert to a factor in the data frame:
dat <- transform(dat,Year=factor(Year))
3. make a new factor variable in the data frame:
dat <- transform(dat,fYear=factor(Year))
Counts ~ Test1 + Test2 + (1|fYear)
#1 is quickest but might be slightly less robust sometimes
#2 is robust but you might want to keep Year as numeric for other purposes
#3 keeps year as numeric and adds an additional factor version of the
variable