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

From: Mark Difford <>
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:

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

glm.table <-, 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.

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.
Mark Difford.

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

Port Elizabeth, SA. mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.