1

I try a model on whatsoever data :

$ \ln \mu_i = \beta_0 + \beta_1 t_i $

and then compare it with :

$ \ln \mu_i = \beta_0 + \beta_1 t_i + \beta_2 t_i^2$

For the first model I wrote in R :

general_reg = glm(cases ~ year, family = poisson)

and I was told to write the second model :

general_reg = glm(cases ~ year + I(year^2), family = poisson)

I don't understand why writing the following gives the same as the first model :

general_reg = glm(cases ~ year + year^2, family = poisson)

Can someone explain it to me please? I write on cross validated because it is a statistics question even thought I focus on the code. Let me know if you think I am wrong.

  • 3
    This seems more like an R syntax question than a statistical question. You may find the following useful on Stack Overflow: https://stackoverflow.com/q/27050431/3093387 – josliber Feb 24 '20 at 15:19
  • 2
    A good way to include polynomial terms is by using the `poly` function. For raw polynomials, use `poly(x, 2, raw = TRUE)` and for orthogonal polynomials use the default `poly(x, 2)`. Orthogonal polynomials have some benefits, as discussed [here](https://stats.stackexchange.com/questions/258307/raw-or-orthogonal-polynomial-regression). – COOLSerdash Feb 24 '20 at 15:22
  • @COOLSerdash thank you, I coudn't find anything. Now I understand :) – Marine Galantin Feb 24 '20 at 16:02
  • It's a legitimate question--but because the answer is found by consulting the `R` manual page for `formula`, it's purely a matter of `R` syntax. – whuber Feb 24 '20 at 16:39

0 Answers0