ANOVA: aov() refueses to estimate two-way interaction even if it is in the model formula

Viewed 64

I ran a 2-way interaction aov() on data5 but it didn't estimate the interaction term. What goes wrong?

data5 <- structure(list(salary_in_usd = c(180000L, 120000L, 215300L, 158200L,
140400L, 215300L, 31615L, 35590L, 52396L, 40000L, 122346L, 135000L,
205300L, 140400L, 140000L, 183228L, 91614L, 185100L, 200000L,
120000L, 230000L, 100000L, 165000L, 86703L, 140000L, 210000L,
140000L, 210000L, 140000L, 210000L, 140000L, 230000L, 150000L,
120000L, 160000L, 130000L, 100000L, 48000L), company_size = c("L",
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
"M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "M", "M", "M", "M", "S", "S", "S", "S", "S", "S"), employment_type = c("FT",
"FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT",
"FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT",
"FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT", "FT",
"FT", "FT", "PT", "FT")), class = "data.frame", row.names = c(NA,
-38L))

anova2i.result <- aov(salary_in_usd ~ company_size * employment_type, data = data5)

#            Df    Sum Sq   Mean Sq F value Pr(>F)
#company_size     2 1.361e+10 6.807e+09   2.278  0.118
#employment_type  1 3.888e+08 3.888e+08   0.130  0.721
#Residuals       34 1.016e+11 2.988e+09
1 Answers

You want to estimate three model terms:

salary_in_usd ~ company_size + employment_type + company_size:employment_type

But your categorical variable employment_type is badly unbalanced:

table(data5$employment_type)
#FT PT 
#37  1 

Estimating employment_type is already the limit. There is no information to further estimating company_size:employment_type.


Mathematically speaking, the model matrix does not have full rank, and all coefficients for company_size:employment_type are set to NA.

## or using: coef(anova2i.result, complete = TRUE)
anova2i.result$coefficients
#                    (Intercept)                   company_sizeM 
#                     127989.071                       34324.540 
#                  company_sizeS               employment_typePT 
#                      -6389.071                      -21600.000 
#company_sizeM:employment_typePT company_sizeS:employment_typePT 
#                             NA                              NA 
Related