Dear all, I am making an analysis using a GLM using three explanatory variables and a response variable. I need to obtain a table similar to this one, http://postimg.org/image/5sau79wlt/r nevertheless, I have not been able to do it. I am having a hard time specially getting the chi square values. I would like to know how to obatin them. I also would like to know what function could help me to make ad hoc comparisons for single variables and interactions. If any of you knows how to do both estimations, I would really appreciate it. All the best!!! This is my script a=read.table("ricis3.txt",header=T) attach(a) model7=glm(Count~Sex+Time+Behaviour+Sex*Time+Sex*Behaviour+Time+Behaviour*Sex,family=poisson) summary(model7) -------------- next part -------------- Sex Time Behaviour Count Male Night Exploring 189 Male Night Interacting 11 Male Night Feeding 170 Male Night Mating 13 Male Night Resting 240 Male Day Exploring 58 Male Day Interacting 1 Male Day Feeding 12 Male Day Mating 3 Male Day Resting 399 Female Night Exploring 187 Female Night Interacting 10 Female Night Feeding 95 Female Night Mating 8 Female Night Resting 175 Female Day Exploring 45 Female Day Interacting 6 Female Day Feeding 10 Female Day Mating 4 Female Day Resting 406 Immature Night Exploring 186 Immature Night Interacting 15 Immature Night Feeding 175 Immature Night Resting 200 Immature Day Exploring 68 Immature Day Interacting 8 Immature Day Feeding 6
Question about GLM post hoc and chi square
4 messages · Luis Fernando García, Bob OHara, Angel Lopez +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140614/c6e9b0e6/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20140614/5cfa1b0a/attachment.pl>
Hi, just a minor comment below. Bob O'Hara p??e v So 14. 06. 2014 v 09:45 +0200:
On 06/14/2014 03:05 AM, Luis Fernando Garca wrote:
Dear all, I am making an analysis using a GLM using three explanatory variables and a response variable. I need to obtain a table similar to this one, http://postimg.org/image/5sau79wlt/r nevertheless, I have not been able to do it. I am having a hard time specially getting the chi square values. I would like to know how to obatin them.
Use anova(). The deviance follows a chi-squared distribution (usually - if you have overdispersion it gets a bit more complicated).
I also would like to know what function could help me to make ad hoc comparisons for single variables and interactions.
These comparisons are called contrasts. There is a contrasts() function in R, and also a contrast package (which, I'm guessing will be of more use). Googling "R contrast" might help too - there seems to be plenty of material, so hopefully one or two results will be exactly what you want. Contrasts can get esoteric, so if you can find some a page with code that gives you the comparisons you want, that should help a lot. Good luck! Bob
If any of you knows how to do both estimations, I would really appreciate
it.
All the best!!!
This is my script
a=read.table("ricis3.txt",header=T)
attach(a)
model7=glm(Count~Sex+Time+Behaviour+Sex*Time+Sex*Behaviour+Time+Behaviour*Sex,family=poisson)
summary(model7)
It seem so me that your model is misspecified: if expanded and reordered, your model would look like: Count~Sex+Sex+Sex+Sex+Time+Time+Time+Behaviour+Behaviour+Behaviour +Sex:Time+Sex:Behaviour+Sex:Behaviour So: note the ":" and "*" difference, see help(formula) Some less related tip: step-by-step work with deviance (anova) tables and contrasts is done in Crawley: The R book. Even more distant things, ignore if familiar with glms: a,if residual deviance of your model >> degrees of freedom, you have overdispersion (see summary(your.model)). Try family=quasipoisson and testing with F distribution instead of Chi (test="F" in the anova command) then (or glm.nb from the MASS package). b, if numerical problems occur, try to standardise your predictors: subtract each predictor's mean from the actual values (so mean(new.predictor)==0 (not exactly, machine precision)), divide the rest by the standard deviation of the original predictor (so most of the values fall within -3,+3), see help(scale). Beware, you loose your original scale with this. HTH. Best, Martin
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
------------------------------ Pokud je tento e-mail sou??st? obchodn?ho jedn?n?, P??rodov?deck? fakulta Univerzity Karlovy v Praze: a) si vyhrazuje pr?vo jedn?n? kdykoliv ukon?it a to i bez uveden? d?vodu, b) stanovuje, ?e smlouva mus? m?t p?semnou formu, c) vylu?uje p?ijet? nab?dky s dodatkem ?i odchylkou, d) stanovuje, ?e smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech n?le?itostech smlouvy.