Following some discussions with colleagues, I'm seeking for clarification on how to visualize an ANCOVA with visreg, and what the visualization actually shows.
I would like to run the following ANCOVA (data are at the end of this post), and then visualize the effect of "Treatment" on "Infection.Frequency" using visreg:
model <- lm(Infection.Frequency ~ Replicate + Treatment + Size, d)
visreg(model,"Treatment")
My questions:
At default, visreg plots 'conditional' plots. Instead, one can also plot 'contrast' plots like this:
visreg(model,"Treatment",type="contrast")
I'd like to get some input whether you would show a conditional plot in a publication to visualize the effect of 'Treatment', or rather the "contrast" plot? Why?
I don't understand what the gray dots are in the conditional plot. These dots cannot represent the raw data, as some values are below zero but the raw values are all between 0 and 1.
2.1 What do the gray dots show?
2.2 Would you see a problem to instead underlie the model result with the real (raw) data? How would I plot the raw data instead?
At default, visreg plots the 95% CI (gray shading), while other plotting packages (e.g., the "effects" R-package) plot SE instead at default. What makes more sense in your opinion?
Assuming that the conditional plot would be good to visualize the effect of 'Treatment' (i.e., visreg(model,"Treatment")), how would you describe in a respective figure legend what is shown? Something like: "Depicted is the partial effect of Treatment on infection frequency. Blue lines depict XXXX surrounded by 95% CI (gray shading), with gray dots indicating XXXX."
Here are my data:
structure(list(ID = 1:486, Replicate = 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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1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 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, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("no",
"yes"), class = "factor"), Size = c(157.65, 145, 142.12,
142.35, 133.67, 146.48, 141.47, 135.46, 136.47, 132.8, 133.24,
141.34, 156.35, 131.81, 131.4, 135.62, 129.79, 130.99, 134.72,
153.48, 156.83, 129.47, 128.13, 133.72, 129.6, 160.32, 129.17,
159.64, 167.23, 152.78, 154, 151.81, 151.21, 145.42, 163.38,
162.8, 150.93, 156.2, 156.9, 155.25, 147.39, 162.33, 158.37,
150.96, 154.25, 161.04, 147.95, 151.35, 155.35, 150.04, 147.13,
149.74, 144.59, 155.81, 152.91, 163.86, 146.12, 154, 162.63,
152.78, 160.11, 157.81, 156.62, 151.18, 154.18, 161.27, 163.64,
155.37, 154.68, 155.28, 150.9, 150.68, 151.49, 157.76, 162.57,
153.54, 151.26, 147.88, 146.09, 146.54, 146.1, 145.68, 148.76,
143.8, 143.7, 139.64, 159.69, 155.51, 158.86, 156.24, 154.67,
161.87, 159.43, 156.01, 165.73, 156.3, 156.07, 154.9, 153.87,
151.69, 158.87, 160.65, 147.2, 156.32, 149.1, 149.55, 148.83,
151.35, 150.13, 154.37, 150.16, 163.96, 163.37, 162.64, 161.89,
161.73, 154.09, 154.89, 160.17, 162.48, 163.28, 155.78, 157.08,
149.99, 153.39, 150.38, 153.22, 149, 158.33, 153.65, 156.59,
153.42, 158.14, 147.56, 145.88, 150.83, 148.53, 140.33, 156.79,
152.05, 158.9, 159.38, 162.26, 155.06, 155.76, 147.85, 153.98,
160.62, 156.08, 144.76, 141.77, 152.68, 144.41, 144.87, 145.02,
143.98, 143.72, 162.94, 137.3, 134.55, 139.03, 136.46, 137.81,
132.84, 132.57, 132.76, 159.84, 167.01, 158.79, 163.68, 157.71,
152.31, 161.27, 160.11, 156.96, 165.69, 144.63, 155.6, 153.83,
161.22, 158.13, 154.06, 156.89, 157.31, 158.42, 158.33, 151.99,
153.59, 147.73, 159.22, 165.05, 153.33, 156.68, 149.17, 145.81,
149.65, 147.82, 147.48, 140.48, 142.58, 157.15, 162.69, 154.92,
161.11, 157.05, 159.73, 160.97, 159.83, 150.19, 149.75, 155.63,
151.99, 152.68, 157.09, 150.15, 155.54, 149.04, 149.41, 147.51,
156.42, 143.8, 151.34, 144.5, 146.57, 147.09, 138.36, 149.88,
160.64, 154.98, 163.59, 153.95, 158.39, 165.91, 164.23, 161.06,
158.33, 153.13, 160.46, 146.19, 147.85, 141.79, 156.88, 164.38,
159.07, 159.4, 150.57, 145.56, 142.46, 146.27, 147.79, 153.58,
146.41, 149.66, 137.71, 136.2, 160.72, 140.54, 126.43, 142.06,
127.99, 132.91, 145.9, 141.6, 151.76, 158.83, 156.66, 155.05,
153.76, 151.65, 149.41, 156.94, 156.89, 155.34, 141.51, 149.79,
150.4, 151.48, 153.33, 157.49, 157.28, 162.08, 151.3, 154.16,
150.62, 162.96, 166.48, 146.1, 155.47, 159.12, 160.27, 162.02,
148.22, 146.11, 151.94, 139.32, 146.76, 155.41, 136.2, 139.78,
133.53, 143.86, 138.02, 145.07, 135.91, 136.86, 131.58, 144,
134.32, 153.05, 162.54, 155.41, 162.58, 155.3, 163.16, 157.23,
150.75, 152.19, 152.6, 152.43, 150.21, 151.53, 150.8, 146.46,
146.2, 152.01, 146.78, 149.46, 146.59, 143.8, 145.13, 139.27,
135.42, 134.04, 130.73, 160.81, 155.78, 163.16, 159.74, 160.68,
155.54, 157.87, 155.35, 160.49, 155.59, 156.26, 152.39, 148.83,
161.35, 150.9, 157.71, 156.31, 156.6, 154.77, 142.44, 141.99,
155.9, 150.95, 147.17, 141.63, 141.03, 146.07, 156.74, 152.76,
156.66, 150.5, 148.39, 166.19, 162.73, 157.39, 152.46, 159.62,
151.22, 149.21, 147.35, 151.54, 145.67, 156.06, 143.3, 155.18,
139.14, 155.19, 163.97, 146.69, 149.62, 144.95, 138.92, 143.2,
129.25, 143.79, 141.64, 140.74, 141.38, 137.68, 140.43, 130.33,
134.52, 157.68, 136.02, 136.46, 137.57, 140.55, 133.57, 151.01,
148.56, 158.66, 161.24, 150.6, 159.28, 152.83, 152.79, 157.07,
158.08, 159.66, 154.62, 150.8, 157.01, 162.5, 158.37, 140.15,
157.62, 143.56, 147.63, 165.17, 160.16, 145.13, 159.51, 149.09,
145.65, 148.72, 142.57, 152.57, 138.88, 152.07, 153.03, 166.66,
158.92, 165.65, 163.69, 162.44, 157.61, 160.84, 163.3, 159.72,
152.97, 164.64, 158.04, 158.01, 153.76, 153.1, 155.84, 159.64,
145.36, 160.56, 147.04, 147.35, 156.84, 154.37, 149.9, 156.72,
146.95, 155.63, 141.59, 147.37, 164.76, 161.8, 160.5, 155.13,
154.33, 150.87, 152.64, 159.85, 154.68, 153.07, 150.23, 151.85,
152.05, 150.59, 142.87, 139.43, 143.72, 141.89, 141.62, 140.03,
133.78, 132.09, 138.19), Infection.Frequency = c(0.283730159,
0.677655678, 0.284090909, 0.176948052, 0.170995671, 0.170995671,
0.170995671, 0.254329004, 0.282106782, 0, 0.043927064, 0.170995671,
0.513257576, 0, 0.2263178, 0.300595238, 0.005952381, 0, 0.12195122,
0.385551948, 0.313852814, 0.113636364, 0.300757576, 0.076923077,
0.013704319, 0.581349206, 0, 0.590638528, 0.47481685, 0.071428571,
0.200757576, 0.170995671, 0.105263158, 0.184615385, 0.504329004,
0.486471861, 0.15, 0.25, 0.196428571, 0, 0.142857143, 0.170995671,
0.170995671, 0.111111111, 0.254329004, 0.320757576, 0.011363636,
0.073051948, 0.542919799, 0.431818182, 0, 0, 0.070422535,
0.073051948, 0.244047619, 0.273809524, 0.19047619, 0.494875223,
0.170995671, 0.170995671, 0.608766234, 0.318404635, 0.44047619,
0.25, 0.611471861, 0.585227273, 0.102813853, 0.011494253,
0, 0.102813853, 0.073051948, 0.352813853, 0.333333333, 0.426564027,
0.438852814, 0.041666667, 0.064814815, 0, 0.443722944, 0.108108108,
0.009009009, 0.086956522, 0.273809524, 0.288059163, 0.12797619,
0.170995671, 0.005952381, 0.442307692, 0.117063492, 0.273559774,
0.504578755, 0.323051948, 0.554924242, 0.385281385, 0.428030303,
0.420995671, 0, 0.602813853, 0.420995671, 0.494047619, 0.237794613,
0.450757576, 0.170995671, 0.112676056, 0.198051948, 0.133333333,
0.170995671, 0.193548387, 0.422979798, 0.233333333, 0, 0.226898102,
0.4375, 0.170995671, 0.54788961, 0.44047619, 0.416666667,
0.4375, 0.053191489, 0.477813853, 0.073051948, 0.357534707,
0.420995671, 0.22362725, 0.370995671, 0.006993007, 0.348214286,
0.28, 0.181818182, 0.543019481, 0.370995671, 0, 0.401764902,
0.323051948, 0.25, 0, 0.375683527, 0.184615385, 0.323051948,
0, 0.489177489, 0.489718615, 0.663961039, 0.487662338, 0.177218615,
0.25, 0.237662338, 0.496031746, 0.244047619, 0, 0.153846154,
0.01, 0.480769231, 0.200757576, 0.073051948, 0.241246499,
0.44047619, 0.44047619, 0.522727273, 0.254329004, 0.170995671,
0, 0.088235294, 0.176948052, 0, 0.051406926, 0.244047619,
0.56871118, 0.567424242, 0.410714286, 0.323051948, 0.415960851,
0.41294245, 0.170995671, 0.628663004, 0.275162338, 0.058823529,
0.412608225, 0.218885281, 0.587662338, 0.029761905, 0.250757576,
0.310530555, 0.244047619, 0.270995671, 0.170995671, 0.425865801,
0.308823529, 0.013452915, 0, 0.25, 0.038461538, 0.050632911,
0.200757576, 0.037313433, 0.220995671, 0, 0.016683023, 0.02739726,
0, 0.323051948, 0.661283892, 0.261904762, 0.431526807, 0.448051948,
0.470238095, 0.459325397, 0.431526807, 0.352813853, 0.25,
0.504329004, 0.513257576, 0.229761905, 0.073051948, 0.600732601,
0.498168498, 0.284090909, 0.013333333, 0.525162338, 0.170995671,
0.005780347, 0, 0.337662338, 0.392857143, 0, 0.210211357,
0.170995671, 0.641233766, 0.275162338, 0.343614719, 0.369047619,
0.513528139, 0.323051948, 0.273809524, 0.671245421, 0.200757576,
0.433608059, 0.450757576, 0, 0.611471861, 0, 0.44047619,
0.3125, 0.142857143, 0.170995671, 0.210526316, 0.45, 0.256313131,
0, 0.176948052, 0.205128205, 0.005952381, 0.573809524, 0.170995671,
0, 0.392857143, 0.126623377, 0, 0.022619048, 0, 0.337121212,
0, 0.013888889, 0.388528139, 0, 0.47797619, 0.44047619, 0.420995671,
0.545995671, 0.053571429, 0.451632926, 0.287714097, 0.311868687,
0, 0.420995671, 0, 0, 0.131875477, 0.420995671, 0.489718615,
0.513257576, 0.400757576, 0.406289789, 0.358495671, 0.2,
0.170995671, 0.406385281, 0.700757576, 0.597466259, 0.367424242,
0.25, 0.015873016, 0.005952381, 0.458333333, 0.170995671,
0, 0.420995671, 0.005952381, 0.048629829, 0.005952381, 0,
0.176948052, 0.170995671, 0, 0, 0.170995671, 0, 0, 0.25,
0.25, 0.190162907, 0.327380952, 0.200757576, 0.284090909,
0.551587302, 0.422619048, 0.163636364, 0.083333333, 0.188852814,
0.068965517, 0.039215686, 0.391233766, 0, 0.016129032, 0.195825799,
0, 0.028169014, 0.02, 0.220899471, 0.019230769, 0.047619048,
0, 0, 0.006711409, 0.660714286, 0.420995671, 0.326388889,
0.463528139, 0.19731146, 0.192307692, 0.532106782, 0.420995671,
0.636273449, 0, 0.313852814, 0.450757576, 0.420995671, 0.420995671,
0.153846154, 0.25, 0.65, 0.170995671, 0.715638528, 0.006622517,
0.082875458, 0.176470588, 0.263257576, 0.19047619, 0.005952381,
0.005952381, 0.170995671, 0.113207547, 0.641233766, 0.420995671,
0.470238095, 0.44047619, 0.367424242, 0.571428571, 0.01826484,
0.385281385, 0.19047619, 0.235294118, 0.25, 0.010638298,
0.613095238, 0.337662338, 0.358652313, 0.084745763, 0.331349206,
0.44047619, 0.529761905, 0.201028139, 0.343614719, 0.029761905,
0.498506023, 0.239219114, 0.472582973, 0.273809524, 0.026315789,
0.176948052, 0.068223443, 0.43452381, 0.19047619, 0.071428571,
0.222069597, 0.306709957, 0.029761905, 0, 0.575396825, 0.200757576,
0.246212121, 0.200757576, 0.027777778, 0.410714286, 0.561904762,
0.285714286, 0.090909091, 0.398214286, 0.009615385, 0.1754329,
0.083333333, 0.042857143, 0.273809524, 0.587662338, 0.170995671,
0.301587302, 0.25, 0.076923077, 0.013333333, 0.69534632,
0, 0, 0.384920635, 0.395400433, 0, 0.06122449, 0.3, 0, 0.015748031,
0.361471861, 0.41504329, 0, 0.170995671, 0.179166667, 0.418019481,
0.170995671, 0.388528139, 0.391233766, 0.024691358, 0.220238095,
0.361471861, 0.613095238, 0.206709957, 0, 0.550757576, 0.541666667,
0.04, 0.079545455, 0.043478261, 0.073051948, 0.041666667,
0.244047619, 0.200757576, 0.029761905, 0.361471861, 0.184163059,
0.291666667, 0.164383562, 0.361471861, 0.235240334, 0.443722944,
0.037037037, 0.276258829, 0.632575758, 0.361471861, 0, 0.43452381,
0.667027417, 0.43452381, 0.19047619, 0.422979798, 0.073051948,
0.513528139, 0.404761905, 0.491233766, 0.542919799, 0.311868687,
0, 0.553051948, 0.073051948, 0, 0.498971861, 0.200757576,
0.282106782, 0.170995671, 0.272186147)), row.names = c(NA,
486L), class = "data.frame")