# Order of Independent variables in regression

I've data df and i'm wondering why p-value change according the order of the independent variables product and age ?

How to know which one to place firstly ?

df=structure(list(Age = structure(c(1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 12L, 13L, NA), .Label = c("(10,15]",
"(15,20]", "(20,25]", "(25,30]", "(30,35]", "(35,40]", "(40,45]",
"(45,50]", "(50,55]", "(55,60]", "(60,65]", "(65,70]", "(70,75]",
"(75,80]"), class = "factor"), Product = c(6L, 16L, 4L, 6L, 9L,
11L, 14L, 15L, 17L, 20L, 23L, 26L, 28L, 30L, 32L, 33L, 36L, 44L,
47L, 4L, 6L, 9L, 11L, 14L, 15L, 17L, 18L, 20L, 23L, 25L, 26L,
28L, 30L, 32L, 33L, 36L, 44L, 50L, 51L, 4L, 6L, 9L, 11L, 14L,
15L, 16L, 17L, 18L, 20L, 22L, 23L, 26L, 28L, 29L, 30L, 32L, 33L,
36L, 37L, 39L, 43L, 44L, 50L, 51L, 58L, 4L, 6L, 9L, 11L, 14L,
15L, 17L, 18L, 20L, 23L, 26L, 28L, 30L, 32L, 33L, 36L, 37L, 47L,
58L, 4L, 6L, 9L, 11L, 14L, 15L, 17L, 18L, 20L, 23L, 25L, 26L,
28L, 30L, 33L, 35L, 36L, 44L, 4L, 6L, 9L, 14L, 15L, 17L, 20L,
22L, 23L, 25L, 26L, 28L, 29L, 30L, 33L, 36L, 38L, 43L, 44L, 50L,
51L, 58L, 4L, 6L, 9L, 11L, 14L, 15L, 16L, 17L, 20L, 23L, 25L,
26L, 28L, 30L, 32L, 33L, 35L, 36L, 37L, 43L, 44L, 50L, 51L, 52L,
58L, 4L, 6L, 9L, 11L, 14L, 15L, 16L, 17L, 18L, 20L, 23L, 26L,
28L, 29L, 30L, 32L, 33L, 36L, 43L, 44L, 50L, 51L, 52L, 4L, 6L,
9L, 14L, 17L, 18L, 20L, 23L, 25L, 26L, 28L, 30L, 32L, 33L, 35L,
36L, 43L, 44L, 51L, 52L, 58L, 6L, 9L, 20L, 23L, 26L, 28L, 36L,
4L, 15L, 6L), Yes = c(2L, 1L, 4L, 5L, 2L, 1L, 2L, 2L, 2L, 2L,
1L, 3L, 4L, 4L, 1L, 4L, 1L, 1L, 1L, 6L, 2L, 4L, 4L, 8L, 1L, 4L,
1L, 1L, 3L, 1L, 5L, 1L, 1L, 0L, 2L, 1L, 1L, 1L, 2L, 4L, 4L, 8L,
2L, 6L, 1L, 1L, 4L, 4L, 2L, 1L, 9L, 3L, 3L, 1L, 2L, 1L, 2L, 2L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 3L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 2L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 3L, 0L, 1L, 1L,
0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 3L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L)), class = "data.frame", row.names = c(NA,
-203L), .Names = c("Age", "Product", "Yes", "No"))

attach(df)

anova(glm(cbind(Yes,No) ~ Age + Product, family=binomial),test="Chisq")
Analysis of Deviance Table

Response: cbind(Yes, No)

Terms added sequentially (first to last)

Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL                      201     176.98
Age     12  24.4260       189     152.56  0.01779 *
Product  1   1.8942       188     150.66  0.16873
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>         anova(glm(cbind(Yes,No) ~ Product + Age, family=binomial),test="Chisq")
Analysis of Deviance Table

Response: cbind(Yes, No)

Terms added sequentially (first to last)

Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL                      201     176.98
Product  1   2.9839       200     174.00   0.0841 .
Age     12  23.3364       188     150.66   0.0250 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
• This issue is covered in several other places on this site, including this page. Please look at that page and the links from it, and revise your question to focus on what you still don't understand thereafter. Otherwise this is likely to be closed as a duplicate question.
– EdM
Jan 18, 2018 at 15:31