Dear list members, I am trying to fit some models to investigate the effects of some predictors (weight, age) on fertility. As the effect of age on fertility is typically quadratic (lower fertility for the extreme age-classes and higher fertility for intermediate age-classes), I fitted the full additive model as: fertility ~ weight + poly(age, 2, raw=TRUE) I would also like to fit a model with an interaction term between weight and age, but I fail to understand the correct syntax. Should the interaction be between weight and the full polynomial term: fertility ~ weight * poly(age, 2, raw=TRUE) or should it simply be between weight and the age^2? fertility ~ weight + age + I(age^2) + weight : I(age^2) Cheers, Luca
Syntax interaction polynomial term
2 messages · Luca Corlatti, Thierry Onkelinx
Dear Luca, This questions has nothing to do with with mixed models. You should have send it to r-help. weight * poly(age, 2, raw=TRUE) is equivalent with weight + age + I(age^2) + weight : I(age^2) + weight:age. So you need the add the first order interaction as well. However you better use the orthogonal polynomials that the raw polynomials. Because the raw polynomials might be highly correlated. Have a look at this examples. age <- 15:50 cor(cbind(age, age ^ 2, age ^ 3)) cor(poly(age, 3, raw = TRUE)) cor(poly(age, 3)) c_age <- scale(age, center = TRUE, scale = FALSE) cor(cbind(c_age, c_age ^ 2, c_age ^ 3)) s_age <- scale(age, center = TRUE, scale = TRUE) cor(cbind(s_age, s_age ^ 2, s_age ^ 3)) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2017-05-16 9:58 GMT+02:00 Luca Corlatti <luca.corlatti at boku.ac.at>:
Dear list members, I am trying to fit some models to investigate the effects of some predictors (weight, age) on fertility. As the effect of age on fertility is typically quadratic (lower fertility for the extreme age-classes and higher fertility for intermediate age-classes), I fitted the full additive model as: fertility ~ weight + poly(age, 2, raw=TRUE) I would also like to fit a model with an interaction term between weight and age, but I fail to understand the correct syntax. Should the interaction be between weight and the full polynomial term: fertility ~ weight * poly(age, 2, raw=TRUE) or should it simply be between weight and the age^2? fertility ~ weight + age + I(age^2) + weight : I(age^2) Cheers, Luca
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models