uji 1 populasi
set.seed(195) #untuk hasil yang acak agar mengunci data agar tidak berubah
waktu_belajar = rnorm(30, mean = 6.2, sd=0.8)
uji one-sample t-test
t.test(waktu_belajar, mu=6)
##
## One Sample t-test
##
## data: waktu_belajar
## t = 1.0752, df = 29, p-value = 0.2912
## alternative hypothesis: true mean is not equal to 6
## 95 percent confidence interval:
## 5.872761 6.409290
## sample estimates:
## mean of x
## 6.141025
bangkitkan nilai dari tiga jurusan
statistika= rnorm(15,82,4)
matematika = rnorm(15,88,4)
aktuaria = rnorm(15,75,4)
Gabungkan data
nilai= c(statistika,matematika,aktuaria)
jurusan= factor(rep(c("statistika","matematika", "aktuaria"), each=15))
model anova
anova_model = aov(nilai~jurusan)
summary(anova_model)
## Df Sum Sq Mean Sq F value Pr(>F)
## jurusan 2 890.3 445.2 31.38 4.62e-09 ***
## Residuals 42 595.8 14.2
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ujii lanjut ataupun untuk melihat perbedaan
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = nilai ~ jurusan)
##
## $jurusan
## diff lwr upr p adj
## matematika-aktuaria 10.832474 7.491162 14.173787 0.0000000
## statistika-aktuaria 6.428379 3.087067 9.769692 0.0000889
## statistika-matematika -4.404095 -7.745408 -1.062783 0.0071877
uji proporsi one sample proportion test
#bangkitkan data binomial
set.seed(123)
jumlah_sarapan1= rbinom(1, size=40, prob=0.65)
total_mahasiswa1= 40
jumlah_sarapan1
## [1] 28
uji proporsi
prop.test (jumlah_sarapan1,total_mahasiswa1, p=0.5,
alternative="greater", correct=FALSE)
##
## 1-sample proportions test without continuity correction
##
## data: jumlah_sarapan1 out of total_mahasiswa1, null probability 0.5
## X-squared = 6.4, df = 1, p-value = 0.005706
## alternative hypothesis: true p is greater than 0.5
## 95 percent confidence interval:
## 0.5712915 1.0000000
## sample estimates:
## p
## 0.7
prop.test(jumlah_sarapan1, total_mahasiswa1, p = 0.5, alternative = "greater",correct = FALSE)
##
## 1-sample proportions test without continuity correction
##
## data: jumlah_sarapan1 out of total_mahasiswa1, null probability 0.5
## X-squared = 6.4, df = 1, p-value = 0.005706
## alternative hypothesis: true p is greater than 0.5
## 95 percent confidence interval:
## 0.5712915 1.0000000
## sample estimates:
## p
## 0.7