2.2.4. Feladatok megoldása páros t-próbára
A 8.11. példát oldjuk meg újra a páros t-próba végrehajtásával:
idoszak.1 <- c(5260, 5470, 5640, 6180, 6390, 6515, 6805, 7515, 7515, 8230, 8770)
idoszak.2 <- c(3910, 4220, 3885, 5160, 5645, 4680, 5265, 5975, 6790, 6900, 7335)
t.test(idoszak.1, idoszak.2, paired = T)
Paired t-test
data: idoszak.1 and idoszak.2
t = 11.94, df = 10, p-value = 0.0000003059
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
1074 1567
sample estimates:
mean of the differences
1320
Ha kivonjuk egymásból a két időszakban mért értékeket egy D
objektumban, akkor egymintás t-próbát is végrehajthatunk (az egyébként alapértelmezett mu=0
argumentum megadásával), amelynek outputja megegyezik a páros t-próba eredményével.
D <- idoszak.1 - idoszak.2
t.test(x = D, mu = 0)
One Sample t-test
data: D
t = 11.94, df = 10, p-value = 0.0000003059
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
1074 1567
sample estimates:
mean of x
1320
Először oldjuk meg a feldatot a t.test()
függvénnyel, hogy lássuk a klasszikus outputot:
idoszak.1 <- c(5260, 5470, 5640, 6180, 6390, 6515, 6805, 7515, 7515, 8230, 8770)
idoszak.2 <- c(3910, 4220, 3885, 5160, 5645, 4680, 5265, 5975, 6790, 6900, 7335)
t.test(idoszak.1, idoszak.2, paired = T)
Paired t-test
data: idoszak.1 and idoszak.2
t = 11.94, df = 10, p-value = 0.0000003059
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
1074 1567
sample estimates:
mean of the differences
1320
Az lsr
csomag pairedSamplesTTest()
függvénye hosszú és széles formutmú adattáblákat is elfogad a formula=
argumentumában. Most a széles formátumnak megfelelő hívást hajtjuk végre. Az aoutpot numerikus értékei megegyeznek a fenti t.test()
hívás eredményével.
library(lsr)
pairedSamplesTTest(formula = ~idoszak.1 + idoszak.2)
Paired samples t-test
Variables: idoszak.1 , idoszak.2
Descriptive statistics:
idoszak.1 idoszak.2 difference
mean 6753.636 5433.182 1320.455
std dev. 1142.123 1216.833 366.746
Hypotheses:
null: population means equal for both measurements
alternative: different population means for each measurement
Test results:
t-statistic: 11.94
degrees of freedom: 10
p-value: <.001
Other information:
two-sided 95% confidence interval: [1074.072, 1566.838]
estimated effect size (Cohen's d): 3.6