[R] Logistic regression with factorial effect
Bert Gunter
gunter.berton at gene.com
Thu Nov 18 19:03:48 CET 2010
You would be better off posting to R-sig-mixed-models or R-sig-ecology
-- Bert
On Thu, Nov 18, 2010 at 9:32 AM, Billy.Requena <billy.requena at gmail.com> wrote:
>
> Hello,
>
> I’d like to evaluate the temporal effect on the relationship between a
> continuous variable (e.g. size) and the probability of mate success.
> Initially I was trying to do a logistic regression model incorporating the
> temporal effect, but I don’t know if that is the best option. I simulated
> some data and that’s the problem:
>
>
> rep(c("Jan","Feb","Mar","Apr","May"), each=20) -> month
> as.factor(month)
>
> rep(LETTERS[seq(1:20)], 5) -> ind
>
> rep(sort(rnorm(20, 5.5, 0.2)), 5) -> size
> size
>
> c(c(rep(0,12), rep(1,8)), c(rep(0,12), rep(1,8)),
> c(rep(c(0,1), 10)),
> c(rep(1,8), rep(0,12)),
> c(rep(1,8), rep(0,12))) -> success1
> success1
>
> With the object ‘success1’, only the highest values of size are successful
> at the two first months, but only the lowest values of size are successful
> at the two last months. So, the overall effect of size on the successful
> probability should not exist, but if we consider the interaction between
> size and time, we should be able to see that effect.
>
>
> glm(success1 ~ size, family=binomial) -> test1.1
> glmer(success1 ~ size + (1|ind), family=binomial) -> test2.1
> glmer(success1 ~ size + month + (1|ind), family=binomial) -> test3.1
> glmer(success1 ~ size : month + (1|ind), family=binomial) -> test4.1
>
>
> However, the expected result is not observed in the output of all these
> models. Using a model selection approach and comparing the AIC values of all
> models, it seems that ‘test1.1’ model is the most likely. All the deviances
> are almost at the same level and the differences in AIC values are due for
> the new parameters added.
>
> Given the data was simulated to generate differences between models and
> model ‘test4.1’ is supposed to be the best one, I’m probably doing something
> wrong.
> Has anyone faced this kind of problem? Or has anyone any idea how to solve
> that?
>
> Thanks and Regards
> Gustavo Requena
> PhD student - Laboratory of Arthropod Behavior and Evolution
> Universidade de São Paulo
> http://ecologia.ib.usp.br/opilio/gustavo.html
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Logistic-regression-with-factorial-effect-tp3049208p3049208.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Bert Gunter
Genentech Nonclinical Biostatistics
More information about the R-help
mailing list