Re: [R] contingency table analysis; generalized linear model

From: Mark Difford <mark_difford_at_yahoo.co.uk>
Date: Tue 09 Jan 2007 - 11:13:41 GMT


Dear List,

I would appreciate help on the following matter:

I am aware that higher dimensional contingency tables can be analysed using either log-linear models or as a poisson regression using a generalized linear model:

log-linear:
loglm(~Age+Site, data=xtabs(~Age+Site, data=SSites.Rev, drop.unused.levels=T))

GLM:
glm.table <- as.data.frame(xtabs(~Age+Site, data=SSites.Rev, drop.unused.levels=T)) glm(Freq ~ Age + Site, data=glm.table, family='poisson')

where Site is a factor and Age is cast as a factor by xtabs() and treated as such.

**Question**:
Is it acceptable to step away from contingency table analysis by recasting Age as a numerical variable, and redoing the analysis as:

glm(Freq ~ as.numeric(Age) + Site, data=glm.table, family='poisson')

My reasons for wanting to do this are to be able to include non-linear terms in the model, using say restricted or natural cubic splines.

Thank you in advance for your help.
Regards,
Mark Difford.



Mark Difford
Ph.D. candidate, Botany Department,
Nelson Mandela Metropolitan University,

Port Elizabeth, SA.

R-help@stat.math.ethz.ch 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. Received on Tue Jan 09 23:21:59 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 Jan 2007 - 13:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.