I'm new to R and statistical data analysis in general.
Here is what I am trying to do:
I have data from patients before and after a therapy. I want to compare the means of the two measures to see if there is a significant difference to see if the therapy had any effect.
First I checked whether the data is normal distributed by doing a shapiro-wilk test:
differences <- data$SymptomsBefore - data$SymptomsAfter #calculate the differences
shapiro.test(differences) #do the test
Output:
Shapiro-Wilk normality test
data: differences
W = 0.92445, p-value = 0.2878
--> Since the p-value is bigger than 0.05, I can assume that the data is normal distributed.
So now I can do a paired samples t-test. Since I don't know if the effect is positive or negative I choose the two-tailed option.
t.test(data$SymptomsBefore, data$SymptomsAfter, paired = TRUE, alternative = "two")
Here is the result:
Paired t-test
data: data$SymptomsBefore and data$SymptomsAfter
t = -2.8939, df = 12, p-value = 0.01348
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.5506404 -0.2185903
sample estimates:
mean of the differences
-0.8846154
So, if I interpret the results correctly, this means there was a significant difference in the means (because the p-value was less than 0.05), meaning the therapy had an effect.
Also, on average the symptoms were -0.8846154 lower than before the therapy.
In a paper I would report that like this: "The results indicate that the therapy resulted in an decrease in Symptoms, t(12) = -2.8939, p = .01348."
Is my interpretation of the R-output correct? Am I missing something? Is there something I still need to check that I didn't think of?
Thank you for your help.
wilcox.test()
. $\endgroup$SymptomsBefore
is a count, are very unlikely to be true....) For example, here's what happens if you run shapiro tests with very non-normal data:tmp <- replicate(1000, {x <- runif(13); shapiro.test(x)$p.value}) ; table(tmp < 0.05)
. I get power of about 10% to reject normality. $\endgroup$