[R-sig-ME] Predict in glmer using method from Owl data ( Ben Bolker)
Chris Mcowen
cm744 at st-andrews.ac.uk
Tue Sep 21 11:58:47 CEST 2010
Dear List and Ben,
I am having some trouble replicating the method used by Ben for getting predicted values from glmer.
I had heard that as long as the model is selected taking into account the random effects then it should be fine to use a lm and the predict function to get the predicted values. I have done this and the model performs OK with binomial data C value - 0.77 and Bieber score - 0.199. However when i try and do this for a ordinal response then the model performs badly in predicting. I am wondering if this is because it makes no account for random effects so i have decided to revisit mixed models.
> > g1
> Generalized linear mixed model fit by the Laplace approximation
> Formula: THREAT ~ 1 + (1 | order/fam) + BS * FR + HAB + SEA + PD + WO + ALT + REG + BIO + LIF
Where i am trying to predict if a species is threatened or not based on a series of life history traits. I have a list of species where i know their life history but not threat level.
I am using the method Ben used in his example to get the predicted values , however i am having trouble. The output contains a large number of outputs (7000+), where as my data frame only has 993, i feel the problem may arise from setting up the data frame (see below) the output makes no sense in relation to my data for example only 6 species are Arctic where as the data frame has loads?
> > pframe0 <- with(traits,expand.grid(BS=levels(BS),FR=levels(FR),WO=levels(WO),PD=levels(PD),HAB=levels(HAB),SEA=levels(SEA),ALT=levels(ALT),BIO=levels(BIO),REG=levels(REG),LIF=levels(LIF)))
> pframe0
> BS FR WO PD HAB SEA ALT BIO REG LIF
> 1 Bisexual_flower Fleshy Non_woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 2 Unisexual_flowers Fleshy Non_woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 3 Unisexual_plant Fleshy Non_woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 4 Bisexual_flower Non_fleshy Non_woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 5 Unisexual_flowers Non_fleshy Non_woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 6 Unisexual_plant Non_fleshy Non_woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 7 Bisexual_flower Fleshy Woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 8 Unisexual_flowers Fleshy Woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 9 Unisexual_plant Fleshy Woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 10 Bisexual_flower Non_fleshy Woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 11 Unisexual_flowers Non_fleshy Woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 12 Unisexual_plant Non_fleshy Woody Abiotic Epiphyte Annual All Arctic One Bamboo
> 13 Bisexual_flower Fleshy Non_woody Biotic Epiphyte Annual All Arctic One Bamboo
> 14 Unisexual_flowers Fleshy Non_woody Biotic Epiphyte Annual All Arctic One Bamboo
> 15 Unisexual_plant Fleshy Non_woody Biotic Epiphyte Annual All Arctic One Bamboo
> 16 Bisexual_flower Non_fleshy Non_woody Biotic Epiphyte Annual All Arctic One Bamboo
> 17 Unisexual_flowers Non_fleshy Non_woody Biotic Epiphyte Annual All Arctic One Bamboo
> 18 Unisexual_plant Non_fleshy Non_woody Biotic Epiphyte Annual All Arctic One Bamboo
> 19 Bisexual_flower Fleshy Woody Biotic Epiphyte Annual All Arctic One Bamboo
> 20 Unisexual_flowers Fleshy Woody Biotic Epiphyte Annual All Arctic One Bamboo
I then tried to attach the fixed effects predictions, i got values but as there are a huge number of enterys in the data frame i am unsure what they correspond to (see below)
> pframe1 <- data.frame(pframe0,eta=mm%*%fixef(g1))
I am sorry if this is hard to follow, i can supply more data or clarify further if required
Chris
More information about the R-sig-mixed-models
mailing list