[R] question about chi values GLM

2014-06-14 Thread Luis Fernando García
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 have used the function ANOVA, but it shows me the deviance but not
the Chi-Square values, can be used these values?

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)
anova(model7,test=Chi)
Sex TimeBehaviour   Count
MaleNight   Exploring   189
MaleNight   Interacting 11
MaleNight   Feeding 170
MaleNight   Mating  13
MaleNight   Resting 240
MaleDay Exploring   58
MaleDay Interacting 1
MaleDay Feeding 12
MaleDay Mating  3
MaleDay 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
ImmatureNight   Exploring   186
ImmatureNight   Interacting 15
ImmatureNight   Feeding 175
ImmatureNight   Resting 200
ImmatureDay Exploring   68
ImmatureDay Interacting 8
ImmatureDay Feeding 6
__
R-help@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.


Re: [R] question about chi values GLM

2014-06-14 Thread peter dalgaard
The column labeled Deviance pretty much _is_ the chi-square, specifically the 
likelihood ratio test statistic, which has an asymptotic chi-square 
distribution. (Using test=Rao gives you the alternative Rao efficient score 
test, which in your case doesn't make much of a difference.) 

Notice though, that those displays are sequential and it is not clear that the 
one in the image you attach is made in the same way (or in a sensible way for 
that matter).  In particular, you have highly significant interaction terms, in 
which case the main effects tests are mostly irrelevant. You may need to 
consult a textbook on Poisson modelling or generalized linear modelling -- the 
discussion is a bit too long to be fitted into a mailing list.

-pd

On 14 Jun 2014, at 10:01 , Luis Fernando García luysgar...@gmail.com 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. I have used the function ANOVA, but it shows me the deviance but not
 the Chi-Square values, can be used these values?
 
 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)
 anova(model7,test=Chi)
 ricis3.txt__
 R-help@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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@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.


Re: [R] question about chi values GLM

2014-06-14 Thread Prof Brian Ripley

On 14/06/2014 09:45, peter dalgaard wrote:

The column labeled Deviance pretty much _is_ the chi-square, specifically the 
likelihood ratio test statistic, which has an asymptotic chi-square distribution. (Using 
test=Rao gives you the alternative Rao efficient score test, which in your case doesn't 
make much of a difference.)

Notice though, that those displays are sequential and it is not clear that the 
one in the image you attach is made in the same way (or in a sensible way for 
that matter).  In particular, you have highly significant interaction terms, in 
which case the main effects tests are mostly irrelevant. You may need to 
consult a textbook on Poisson modelling or generalized linear modelling -- the 
discussion is a bit too long to be fitted into a mailing list.


We do not know what is meant by the entries in those tables.  Many years 
ago (before even the term 'deviance' was coined) H.O. Lancaster and 
others partitioned chi-squared tests, with a similar table to an 
analysis of deviance but different numerical quantities.  Although 
Peter's guess is the most likely one, it is not the only possible one.


As an overall test of fit in a Poisson log-linear model there is a 
likelihood-ratio aka deviance test (sometimes called a G^2 test or 
G-test) and a Chi-squared test (which is different).


The 'df' in the table make no sense.  For three binary variables, Season 
x sex has more df than Season or Sex, and Time x Sex has fewer  
Even if we had the reference (and the OP really should have given us 
that to allow him to reproduce it under 'fair use' copyright law) I 
guess we would be little the wiser.



-pd

On 14 Jun 2014, at 10:01 , Luis Fernando García luysgar...@gmail.com 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. I have used the function ANOVA, but it shows me the deviance but not
the Chi-Square values, can be used these values?

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)
anova(model7,test=Chi)
ricis3.txt__
R-help@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.





--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.