ounad10=read.table("http://www.tlu.ee/~jaagup/andmed/muu/ounad/ounad10.txt", header=TRUE, sep=",")
ounad10
## ounasort diameeter
## 1 Kuldrenett 3.11
## 2 Kuldrenett 3.18
## 3 Liivi sibul 2.75
## 4 Liivi sibul 1.23
## 5 Liivi sibul 3.06
## 6 Kuldrenett 3.10
## 7 Kuldrenett 2.02
## 8 Kuldrenett 4.75
## 9 Liivi sibul 3.86
## 10 Kuldrenett 5.51
hist(ounad10$diameeter)
t.test(ounad10$diameeter)
##
## One Sample t-test
##
## data: ounad10$diameeter
## t = 8.3615, df = 9, p-value = 1.552e-05
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 2.375835 4.138165
## sample estimates:
## mean of x
## 3.257
Selgitusi testi vastuse kohta: Aritmeetiline keskmine: 3.257 Nende andmete põhjal 95% tõenäosusega (95-l juhul sajast arvan õigesti, et ) on sarnaste õunte diameetrite aritmeetiline keskmine vahemikus 2.375835 kuni 4.138165
One Sample t-test
data: ounad10$diameeter t = 8.3615, df = 9, p-value = 1.552e-05 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 2.375835 4.138165 sample estimates: mean of x 3.257
t.test(ounad10$diameeter, conf.level=0.9) #Piirdun 90% täpsusega
##
## One Sample t-test
##
## data: ounad10$diameeter
## t = 8.3615, df = 9, p-value = 1.552e-05
## alternative hypothesis: true mean is not equal to 0
## 90 percent confidence interval:
## 2.542958 3.971042
## sample estimates:
## mean of x
## 3.257
#saan veidi kitsama vahemiku - 2.542958 kuni 3.971042
#Leidke keskmise diameetri hinnangu usaldusvahemik 80% täpsusega
ounad100=read.table("http://www.tlu.ee/~jaagup/andmed/muu/ounad/ounad100.txt", header=TRUE, sep=",")
t.test(ounad100$diameeter)
##
## One Sample t-test
##
## data: ounad100$diameeter
## t = 21.197, df = 99, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 2.948132 3.557068
## sample estimates:
## mean of x
## 3.2526
t.test(ounad100$diameeter, mu=3) #pakutav keskmine 2cm
##
## One Sample t-test
##
## data: ounad100$diameeter
## t = 1.6462, df = 99, p-value = 0.1029
## alternative hypothesis: true mean is not equal to 3
## 95 percent confidence interval:
## 2.948132 3.557068
## sample estimates:
## mean of x
## 3.2526
t.test(ounad100$diameeter, mu=3, alternative="greater")
##
## One Sample t-test
##
## data: ounad100$diameeter
## t = 1.6462, df = 99, p-value = 0.05145
## alternative hypothesis: true mean is greater than 3
## 95 percent confidence interval:
## 2.997822 Inf
## sample estimates:
## mean of x
## 3.2526
p-value = 0.05145 5,1% tõenäosusega ei ole õunte keskmine diameeter suurem kui 3 cm ehk 94.9% tõenäosusega on õunte keskmine diameeter suurem kui 3 cm
95 percent confidence interval: 2.997822 Inf 95% tõenäosusega on õunte keskmine diameeter suurem kui 2,997
Harjutus: Võtke tuhande õunaga fail Kuvage keskmise usaldusvahemikud 99, 95, 80 % täpsusega Leidke, millisest väärtusest on 90% tõenäosusega õunte keskmine suurem Leidke, millisest väärtusest on 99% tõenäosusega õunte keskmine väiksem (less)
kuldrenetid=ounad100[ounad100$ounasort=="Kuldrenett", "diameeter"]
sibulounad=ounad100[ounad100$ounasort=="Liivi sibul", "diameeter"]
kuldrenetid
## [1] 3.99 3.65 5.52 2.53 9.76 3.65 8.16 5.50 7.48 5.53 1.71 1.82 1.93 0.42
## [15] 3.49 6.13 1.64 2.06 6.92 0.75 3.65 6.84 1.17 1.32
sibulounad
## [1] 3.68 1.79 3.66 1.95 3.26 2.56 2.91 2.85 3.67 3.47 2.80 1.01 2.85 4.03
## [15] 1.95 3.49 3.44 2.28 3.06 1.99 3.58 2.22 2.81 2.13 2.19 3.87 3.48 3.91
## [29] 4.01 2.74 4.04 2.64 3.48 3.05 3.21 2.51 2.00 2.59 4.43 3.41 2.27 3.35
## [43] 1.43 2.76 2.77 2.96 3.44 5.67 2.55 2.74 2.85 3.52 1.99 4.53 2.39 2.98
## [57] 4.50 2.18 3.23 4.30 3.11 1.99 4.42 5.20 2.36 1.85 4.13 3.96 2.11 3.34
## [71] 1.66 3.21 2.66 1.57 2.56 4.10
t.test(kuldrenetid, sibulounad)
##
## Welch Two Sample t-test
##
## data: kuldrenetid and sibulounad
## t = 1.7798, df = 24.757, p-value = 0.08738
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.1518338 2.0770093
## sample estimates:
## mean of x mean of y
## 3.984167 3.021579
#näha kummagi õunasordi keskmine diameeter
#95% tõenäosusega on nende keskmiste vahe
# -0.1518338 kuni 2.0770093 cm
#Kuna keskmine on nullpunkti mõlemal poolel, siis ma ei saa suuruste
#kohta praegu midagi väita
t.test(kuldrenetid, sibulounad, conf.level=0.9)
##
## Welch Two Sample t-test
##
## data: kuldrenetid and sibulounad
## t = 1.7798, df = 24.757, p-value = 0.08738
## alternative hypothesis: true difference in means is not equal to 0
## 90 percent confidence interval:
## 0.03841949 1.88675595
## sample estimates:
## mean of x mean of y
## 3.984167 3.021579
#90% tõenäosusega on kulrenetid suuremad
# 0.03841949 kuni 1.88675595 cm
plot(density(sibulounad), xlim=c(0, 10))
lines(density(kuldrenetid), col="green")
abline(v=mean(sibulounad))
abline(v=mean(kuldrenetid), col="green")