Issue with Df in a one way ANOVA

Hi! I have been performing a variety of ANOVA tests with a set of data involving a group of plant species and a variable. Most have come out fine, but I am having some issues with several results, where the Df is one number less (14) than it should be (15). I even have the results of a mirror test with two more species where the Df is 17 (as it should be), so I am quite puzzled by how some are still 14 instead of 15. Any ideas on what could be the issue? Here is my code, ANOVA results and dataset:

one.wayWPDMay <- aov(WaterPot_Dawn ~ Art, data=dataMay)
summary(one.wayWPDMay)
Df Sum Sq Mean Sq F value Pr(>F)
Art 14 0.6805 0.04861 2.067 0.043 *
Residuals 33 0.7760 0.02352


Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1
37 observations deleted due to missingness

dput(dataMay)
structure(list(Art = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L,
5L, 5L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 13L,
13L, 13L, 13L, 13L, 16L, 16L, 16L, 16L, 16L, 18L, 18L, 18L, 18L,
18L, 20L, 20L, 20L, 20L, 20L, 22L, 22L, 22L, 22L, 22L, 24L, 24L,
24L, 24L, 24L, 25L, 25L, 25L, 25L, 25L), levels = c("Acer buergerianum ",
"Acer rufinerve ", "Caprinus japonica ", "Celtis australis ",
"Celtis occidentalis ", "Cladrastis lutea", "Cladrastis lutea ",
"Cornus controversa", "Cornus controversa ", "Cornus officinalis ",
"Magnolia denudata ", "Ostrya carpinifolia ", "Ostrya japonica",
"Ostrya japonica ", "Phellodendrok amurense", "Phellodendrok amurense ",
"Pterocarya fraxinifolia", "Pterocarya fraxinifolia ", "Quercus cerris ",
"Quercus shumardii", "Quercus shumardii ", "Quercus texana",
"Quercus texana ", "Quercus x hispanica ", "Zelkova serrata "
), class = "factor"), Date = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), levels = c("AMay", "BJune", "CJuly", "DAugust", "ESeptember"
), class = "factor"), Ind = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L,
1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L,
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L,
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), WaterPot_Dawn = c(NA,
NA, 0.41, 0.596, 0.78, NA, NA, 0.62, 0.75, 0.448, 0.12, 0.488,
0.73, NA, NA, 0.355, 0.28, 0.41, 0.278, 0.505, 0.565, 0.57, 0.66,
0.378, 0.87, 0.462, NA, 0.54, NA, 0.46, 0.461, 0.42, 0.32, NA,
NA, 0.28, 0.75, 0.28, NA, NA, 0.401, 0.43, 0.47, NA, NA, 0.56,
0.54, 0.87, NA, NA, 0.65, 0.6, 0.77, NA, NA, 0.46, 0.46, NA,
0.357, NA, 0.38, 0.62, 0.362, NA, NA, 0.79, NA, 0.89, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.46, 0.54, 0.422, NA,
NA), WaterPot_Noon = c(NA, NA, 0.14, 0.28, 0.31, NA, NA, 0.255,
0.42, 0.182, 0.31, 0.62, 0.91, NA, NA, 0.85, 0.93, 0.52, NA,
NA, 0.227, 0.58, 0.48, NA, NA, 0.25, NA, 0.24, NA, 0.28, 0.77,
1.24, 0.49, NA, NA, 0.55, 0.84, 0.82, NA, NA, 0.26, 0.51, 0.68,
NA, NA, 0.65, 1.14, 0.74, NA, NA, 0.47, 0.49, 0.68, NA, NA, 0.47,
0.58, NA, 0.48, NA, 0.69, 0.71, 0.606, NA, NA, 0.85, 0.86, 0.26,
NA, NA, 0.22, 0.78, 0.56, NA, NA, NA, NA, NA, NA, NA, 0.86, 0.43,
0.47, NA, NA), ChloroCont = c(NA, NA, 21.2, 18.1, 18.4, NA, NA,
26.1, 24.7, 26, 27.4, 24.3, 24.8, 26.7, 23.9, 31.6, 6.2, 17.2,
29.5, 18.7, NA, NA, NA, NA, NA, 13.9, NA, 15.3, NA, 14.4, 29.5,
25.8, 26.9, 22.3, 23, 28.4, 25.9, 33.8, 36.6, 33.1, 14.4, 22,
16.8, 18.1, 26.2, 28, 25.4, 24.3, 28.4, 27.5, 25, 23.4, 27.1,
25.2, 25.4, 17.4, 17, NA, 19, NA, 24.3, 26.2, 25.5, 25.8, 20.4,
9.1, 17, 16.4, 16.3, 13.1, 14, 12.6, 12.5, NA, 7.6, NA, NA, NA,
NA, NA, 19.1, 19.1, 16.9, 17, 17.5), Leaf_area = c(NA, NA, 52.6,
63.29, 22.97, NA, NA, 332, 318.04, 338.9, 41.76, 56.04, 47.83,
65.03, 56.11, 5.92, 2.99, 7, 5.95, 3.57, NA, NA, NA, NA, NA,
23.9, NA, 34.83, NA, 25.03, 142.84, 113.32, 158.48, 63.24, 94.13,
41.2, 59.1, 87.64, 51.47, 88.47, 161, 184.5, 197.38, 201.05,
160.03, 56.2, 48.26, 28.4, 83.74, 35.55, 43.72, 61.86, 37.18,
67.41, 80.3, 78.69, 42.49, NA, 62.85, NA, 315.57, 242.21, 333.31,
266.55, 43.12, 33.01, 34.55, 65.6, 36.52, 26.7, 18.17, 28.44,
31.74, NA, 29.78, NA, NA, NA, NA, NA, 126.7, 119.21, 95.46, 148.23,
126.16), Fresh_weight = c(NA, NA, 1.16, 1.26, 0.79, NA, NA, 7.23,
5.84, 5.05, 1.06, 1.29, 1.22, 1.46, 1.24, 0.6, 0.57, 0.61, 0.62,
0.6, 0.58, 0.57, 0.59, 0.57, 0.57, 1.62, NA, 2.12, NA, 1.69,
2.81, 2.37, 2.87, 1.52, 2.1, 1.08, 1.28, 1.89, 1.31, 1.88, 3.09,
3.51, 3.89, 3.49, 3.25, 0.87, 0.76, 0.5, 1.32, 0.7, 0.99, 1.12,
0.89, 1.13, 1.31, 3.19, 1.93, NA, NA, NA, 9.77, 7.36, 9.92, 9.73,
1.55, 0.68, 0.74, 0.85, 0.94, 0.74, 0.71, 0.86, 0.97, NA, 0.96,
NA, NA, NA, NA, NA, 1.81, 1.51, 1.3, 2.14, 1.85), Dry_weight = c(NA,
NA, 0.26, 0.27, 0.1, NA, NA, 2.25, 1.84, 1.6, 0.31, 0.39, 0.3,
0.44, 0.37, 0.047, 0.024, 0.035, 0.049, 0.039, 0.021, 0.018,
0.019, 0.015, 0.023, 0.41, NA, 0.49, NA, 0.36, 0.68, 0.56, 0.74,
0.34, 0.5, 0.3, 0.41, 0.57, 0.36, 0.63, 0.62, 0.75, 0.78, 0.77,
0.76, 0.36, 0.29, 0.2, 0.52, 0.3, 0.28, 0.31, 0.24, 0.34, 0.41,
0.68, 0.37, NA, 0.57, NA, 1.9, 1.49, 1.97, 1.82, 0.25, 0.2, 0.19,
0.22, 0.24, 0.16, 0.12, 0.16, 0.18, NA, 0.13, NA, NA, NA, NA,
NA, 0.51, 0.42, 0.39, 0.57, 0.46), DBH = c(NA, NA, 18, 14.8,
9.8, NA, NA, 10, 10, 10.2, 11.4, 10, 11.6, 11.2, 9.6, 12, 11.8,
11.8, 13.2, 13.7, 10.4, 11, 13, 11, 11.2, 8, NA, 10.2, NA, 10.6,
12, 12.2, 12.4, 10.2, 12, 10.4, 8, 9, 9, 9.4, 9, 8.6, 8.6, 8.2,
8.2, 9.4, 10.4, 11.2, 9.8, 10, 8, 8.2, 10.2, 10.2, 10.4, 13,
17.8, NA, 13.4, NA, 20.2, 21, 17.8, 22, 272, 13.2, 9, 12.2, 9.2,
8.6, 11.8, 13, 13.6, NA, 13.8, NA, NA, NA, NA, NA, 19.4, 12.6,
15.8, 16.6, 12.1), Height = c(NA, NA, 371L, 397L, 303L, NA, NA,
352L, 309L, 337L, 251L, 293L, 313L, 307L, 270L, 372L, 379L, 372L,
362L, 385L, 337L, 338L, 318L, 316L, 318L, 327L, NA, 368L, NA,
351L, 331L, 324L, 332L, 273L, 301L, 307L, 331L, 338L, 261L, 300L,
331L, 301L, 327L, 343L, 310L, 300L, 425L, 374L, 343L, 384L, 367L,
336L, 372L, 379L, 379L, 325L, 273L, NA, 341L, NA, 437L, 502L,
409L, 393L, 565L, 383L, 432L, 449L, 403L, 409L, 412L, 444L, 446L,
NA, 408L, NA, NA, NA, NA, NA, 462L, 444L, 392L, 425L, 374L),
X1st_leaf = c(NA, NA, 189, 179.5, 185, NA, NA, 182.5, 169,
178, 157, 173, 195, 168, 164, 196, 210, 185, 189, 195, 230,
185, 210, 194, 189, 172, NA, 203, NA, 176, 189, 179, 196,
185, 176, 164, 148, 148, 157, 146, 193, 206, 158, 193, 194,
169, 175, 150, 174, 171, 170, 210, 176, 175, 176, 191, 215,
NA, 224, NA, 157, 202, 183, 200, 244, 140, 158, 178, 183,
149, 171, 154, 175, NA, 158, NA, NA, NA, NA, NA, 137, 216,
206, 226, 168), Axis_1 = c(NA, NA, 123, 146, 80, NA, NA,
87, 61, 68, 95, 116, 118, 94, 124, 50, 63, 67, 65, 70, 83,
82, 93, 57, 56, 52, NA, 97, NA, 67, 128, 127, 150, 51, 114,
74, 30, 50, 50, 62, 33, 56, 46, 128, 68, 128, 86, 98, 106,
45, 63, 87, 85, 98, 78, 74, 121, NA, 81, NA, 135, 180, 160,
162, 210, 125, 136, 108, 136, 57, 82, 59, 90, NA, 63, NA,
NA, NA, NA, NA, 229, 175, 205, 230, 160), Axis_2 = c(NA,
NA, 112, 106, 90, NA, NA, 92, 58, 63, 81, 104, 133, 105,
109, 94, 68, 69, 59, 53, 89, 98, 78, 68, 73, 66, NA, 77,
NA, 87, 141, 156, 137, 39, 101, 66, 27, 41, 45, 64, 51, 59,
72, 110, 67, 133, 74, 66, 103, 48, 61, 84, 96, 93, 61, 58,
81, NA, 79, NA, 118, 110, 106, 57, 180, 98, 113, 103, 125,
80, 67, 93, 89, NA, 64, NA, NA, NA, NA, NA, 190, 145, 195,
143, 177), Canopy_size = c(NA, NA, 182, 217.5, 118, NA, NA,
169.5, 140, 159, 94, 120, 118, 139, 106, 176, 169, 187, 173,
190, 107, 153, 108, 122, 129, 155, NA, 165, NA, 175, 142,
145, 136, 88, 125, 143, 183, 190, 104, 154, 138, 95, 169,
150, 116, 131, 250, 224, 169, 213, 197, 126, 196, 204, 203,
134, 58, NA, 117, NA, 280, 300, 226, 193, 321, 243, 274,
271, 220, 260, 241, 290, 271, NA, 250, NA, NA, NA, NA, NA,
325, 228, 186, 199, 206), Leaf_dry_cont = c(NA, NA, 0.224137931,
0.214285714, 0.126582278, NA, NA, 0.31120332, 0.315068493,
0.316831683, 0.29245283, 0.302325581, 0.245901639, 0.301369863,
0.298387097, 0.078333333, 0.042105263, 0.057377049, 0.079032258,
0.065, 0.036206897, 0.031578947, 0.03220339, 0.026315789,
0.040350877, 0.25308642, NA, 0.231132075, NA, 0.213017751,
0.241992883, 0.23628692, 0.257839721, 0.223684211, 0.238095238,
0.277777778, 0.3203125, 0.301587302, 0.27480916, 0.335106383,
0.200647249, 0.213675214, 0.200514139, 0.220630372, 0.233846154,
0.413793103, 0.381578947, 0.4, 0.393939394, 0.428571429,
0.282828283, 0.276785714, 0.269662921, 0.300884956, 0.312977099,
0.213166144, 0.191709845, NA, NA, NA, 0.194472876, 0.202445652,
0.19858871, 0.18705036, 0.161290323, 0.294117647, 0.256756757,
0.258823529, 0.255319149, 0.216216216, 0.169014085, 0.186046512,
0.18556701, NA, 0.135416667, NA, NA, NA, NA, NA, 0.281767956,
0.278145695, 0.3, 0.26635514, 0.248648649), Crown_volume = c(NA,
NA, 10502268.84, 14099593.49, 3558796.158, NA, NA, 5682839.517,
2074791.564, 2853219.581, 3029877.619, 6064027.804, 7757187.07,
5746726.946, 6001262.971, 3464967.257, 3032667.353, 3621213.321,
2779073.805, 2952678.215, 3310857.477, 5150151.067, 3281632.288,
1980761.602, 2208966.892, 2228268.837, NA, 5162202.217, NA,
4272880.168, 10735098.56, 12033305.17, 11706830.86, 733172.3271,
6028716.302, 2925501.345, 620904.3721, 1631533.785, 980176.9079,
2559652.408, 972863.2802, 1314777.469, 2344583.164, 8846724.913,
2213758.868, 9341605.342, 6664365.216, 6068853.29, 7728912.736,
1927178.597, 3171211.589, 3857071.531, 6699383.502, 7788033.321,
4045843.55, 2409090.533, 2381151.302, NA, 3136076.017, NA,
18683679.83, 24881413.82, 16055465.3, 7465102.729, 50825942.59,
12468981.24, 17638291.84, 12627543.71, 15666075.37, 4966229.667,
5546184.426, 6665328.638, 9092648.785, NA, 4222300.526, NA,
NA, NA, NA, NA, 59232635.09, 24234245.73, 31145121.25, 27416092.66,
24437066.95), Specific_leaf = c(NA, NA, 202.3076923, 234.4074074,
229.7, NA, NA, 147.5555556, 172.8478261, 211.8125, 134.7096774,
143.6923077, 159.4333333, 147.7954545, 151.6486486, 125.9574468,
124.5833333, 200, 121.4285714, 91.53846154, NA, NA, NA, NA,
NA, 58.29268293, NA, 71.08163265, NA, 69.52777778, 210.0588235,
202.3571429, 214.1621622, 186, 188.26, 137.3333333, 144.1463415,
153.754386, 142.9722222, 140.4285714, 259.6774194, 246, 253.0512821,
261.1038961, 210.5657895, 156.1111111, 166.4137931, 142,
161.0384615, 118.5, 156.1428571, 199.5483871, 154.9166667,
198.2647059, 195.8536585, 115.7205882, 114.8378378, NA, 110.2631579,
NA, 166.0894737, 162.557047, 169.1928934, 146.456044, 172.48,
165.05, 181.8421053, 298.1818182, 152.1666667, 166.875, 151.4166667,
177.75, 176.3333333, NA, 229.0769231, NA, NA, NA, NA, NA,
248.4313725, 283.8333333, 244.7692308, 260.0526316, 274.2608696
)), row.names = c(NA, -85L), class = "data.frame")

Thanks a lot!

Hi @Tired22,
In your data I notice that several species are present in two forms (one string in each case has a trailing space).
Is that correct? e.g. both "Ostrya japonica" and "Ostrya japonica ".
These will be taken as different species (factor levels) in the analysis, will lead to possibly unexpected numbers of missing values, and possibly incorrect degrees-of-freedom in your aov. It would be best to remove all the trailing white space from the species names.

levels(dataMay$Art)
 [1] "Acer buergerianum "       "Acer rufinerve "          "Caprinus japonica "      
 [4] "Celtis australis "        "Celtis occidentalis "     "Cladrastis lutea"        
 [7] "Cladrastis lutea "        "Cornus controversa"       "Cornus controversa "     
[10] "Cornus officinalis "      "Magnolia denudata "       "Ostrya carpinifolia "    
[13] "Ostrya japonica"          "Ostrya japonica "         "Phellodendrok amurense"  
[16] "Phellodendrok amurense "  "Pterocarya fraxinifolia"  "Pterocarya fraxinifolia "
[19] "Quercus cerris "          "Quercus shumardii"        "Quercus shumardii "      
[22] "Quercus texana"           "Quercus texana "          "Quercus x hispanica "    
[25] "Zelkova serrata "

> levels(as.factor(trimws(dataMay$Art)))
 [1] "Acer buergerianum"       "Acer rufinerve"          "Caprinus japonica"      
 [4] "Celtis australis"        "Celtis occidentalis"     "Cladrastis lutea"       
 [7] "Cornus controversa"      "Cornus officinalis"      "Magnolia denudata"      
[10] "Ostrya carpinifolia"     "Ostrya japonica"         "Phellodendrok amurense" 
[13] "Pterocarya fraxinifolia" "Quercus shumardii"       "Quercus texana"         
[16] "Quercus x hispanica"     "Zelkova serrata"

Hope this helps.

2 Likes

Thank you for your response. Any idea on how I could remove it? I have tried doing it in the original csv file, but to no avail. Df is still 14.

You are missing entire levels of 'Art' in your variables once missing data are account for:

dataMay2 <- dataMay %>% tidyr::drop_na(WaterPot_Dawn)
unique(dataMay2$Art)

I recommend using nlme::gls() instead and coding your factor variables as "character" instead. These linear modelling functions will do automatic conversion to a factor, dropping the unused levels as needed.

1 Like

I have added those lines and changed the code accordingly, but the result of the ANOVA still has a Df of 14. Any more ideas on how I could fix it? Thank you.

That is the correct df. That is how many levels you have.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.