Luciano


---------- Forwarded message ----------
From: Luciano Selzer <luciano.selzer@gmail.com>
Date: 2010/9/21
Subject: Re: [R-sig-ME] Predict in glmer using method from Owl data ( Ben
Bolker)
To: Chris Mcowen <cm744@st-andrews.ac.uk>
Cc: R-mixed models mailing list <r-sig-mixed-models@r-project.org>


Hi Chris, I don't know much about your prediction issue with your model. But
I can tell that you are getting loads of Arctic species in your prediction
data frame. You are using expand.grid to create it, so you are making a data
frame that contains all the possible combinations of factors. See
?expand.grid for more information.
As for your prediction issue maybe someone more knowledgeable than myself
can provide help.

HTH
Luciano


2010/9/21 Chris Mcowen <cm744@st-andrews.ac.uk>

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
> _______________________________________________
> R-sig-mixed-models@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]


