Analysis of variance
Analysis of variance (Anova) is used to fit data to a linear model when all explanatory variables are categorical. Each of these categorical explanatory variables is known as a factor, and each factor can have two or more levels. When a single factor is present with three or more levels, we use a one-way Anova to analyze the data. If we had a single factor with two levels, we would use a student's t-test to analyze the data. When there are two or more factors, we would use a two-way or three-way Anova. You can easily perform an Anova in R using the aov()
function.
In the first example, we will look at the effect of the dose of drugA
on the level of fatigue reported by the 20 patients as follows:
> patient.fatigue <- read.table(header=TRUE, text=' patients fatigue drugA_dose 1 1 low 0.2 2 2 low 0.2 3 3 med 0.2 4 4 med 0.2 5 5 med 0.2 6 6 low ...