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.

Reply via email to