Abstract
Spostrzeżenie podczas pracy z analizą danych T. Szweda.Po pierwsze Sprawdzamy testem Shapiro-Wilka czy dane mają rozkład normalny.
Hipotezy zerowa i alternatywna w tym teście są następujące:
Jeżeli p>alpha nie możemy odrzucić H0 czyli dane są normalnie dystrybuowane
with(DTS, shapiro.test(Matura.P[Płeć == "M"]))
##
## Shapiro-Wilk normality test
##
## data: Matura.P[Płeć == "M"]
## W = 0.9332, p-value = 1.521e-08
with(DTS, shapiro.test(Matura.P[Płeć == "M" & Kategoria.Szkoły=="A"]))
##
## Shapiro-Wilk normality test
##
## data: Matura.P[Płeć == "M" & Kategoria.Szkoły == "A"]
## W = 0.93922, p-value = 0.01255
Jeżeli dane nie są normalnie dystrybuowane to trzeba stosować test Wilcoxona Hipotezy testu Wilcoxona są następujące:
wilcox.test(Matura.P ~ Płeć, data = DTS)
##
## Wilcoxon rank sum test with continuity correction
##
## data: Matura.P by Płeć
## W = 20306, p-value = 0.04899
## alternative hypothesis: true location shift is not equal to 0
wilcox.test(Matura.P ~ Płeć, data = DTS, subset=Kategoria.Szkoły=="A")
##
## Wilcoxon rank sum test with continuity correction
##
## data: Matura.P by Płeć
## W = 755.5, p-value = 0.3912
## alternative hypothesis: true location shift is not equal to 0
Jeżeli dane są normalnie dystrybuowane stosujemy test Levene’a (test F) aby sprawdzić jednorodność wariancji Hipotezy testu F są następujące:
var.test(Matura.P ~ Płeć, data = DTS, subset=Kategoria.Szkoły=="A")
##
## F test to compare two variances
##
## data: Matura.P by Płeć
## F = 0.81651, num df = 33, denom df = 49, p-value = 0.5437
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.441967 1.569236
## sample estimates:
## ratio of variances
## 0.8165129
Jeżeli dane mają taką samą wariancją stosujemy test t-Studenta Hipotezy testu F są następujące:
t.test(Matura.P ~ Płeć, data = DTS)
##
## Welch Two Sample t-test
##
## data: Matura.P by Płeć
## t = 2.1783, df = 319.83, p-value = 0.03011
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.538475 10.584582
## sample estimates:
## mean in group K mean in group M
## 48.80368 43.24215
t.test(Matura.P ~ Płeć, data = DTS, subset=Kategoria.Szkoły=="A")
##
## Welch Two Sample t-test
##
## data: Matura.P by Płeć
## t = -1.0708, df = 75.56, p-value = 0.2876
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -7.385744 2.221038
## sample estimates:
## mean in group K mean in group M
## 21.61765 24.20000
Jeżeli dane mają różną wariancją to również stosujemy test t ale podajemy var.equal = FALSE (tak t.test działa domyślnie!)
t.test(Matura.P ~ Płeć, data = DTS)
##
## Welch Two Sample t-test
##
## data: Matura.P by Płeć
## t = 2.1783, df = 319.83, p-value = 0.03011
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.538475 10.584582
## sample estimates:
## mean in group K mean in group M
## 48.80368 43.24215
t.test(Matura.P ~ Płeć, data = DTS, subset=Kategoria.Szkoły=="A")
##
## Welch Two Sample t-test
##
## data: Matura.P by Płeć
## t = -1.0708, df = 75.56, p-value = 0.2876
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -7.385744 2.221038
## sample estimates:
## mean in group K mean in group M
## 21.61765 24.20000
Jednokierunkowy test ANOVA możesz stosować dla kilku danych zgrupowanych w oddzielnych grupach jednak musisz zapewnić, że: