STATISTIKA NONPARAMETRIK

PRAKTIKUM TM-4

  1. SIGN TEST
#SOAL 1
Oks= c(1.5, 2.2, 0.9, 1.3, 2.0,1.6, 1.8, 1.5, 2.0, 1.2, 1.7)

library(BSDA)
## Warning: package 'BSDA' was built under R version 4.3.3
## Loading required package: lattice
## 
## Attaching package: 'BSDA'
## The following object is masked from 'package:datasets':
## 
##     Orange
SIGN.test(Oks, md = 1.8, alternative = "two.sided")
## 
##  One-sample Sign-Test
## 
## data:  Oks
## s = 3, p-value = 0.3438
## alternative hypothesis: true median is not equal to 1.8
## 95 percent confidence interval:
##  1.271273 2.000000
## sample estimates:
## median of x 
##         1.6 
## 
## Achieved and Interpolated Confidence Intervals: 
## 
##                   Conf.Level L.E.pt U.E.pt
## Lower Achieved CI     0.9346 1.3000      2
## Interpolated CI       0.9500 1.2713      2
## Upper Achieved CI     0.9883 1.2000      2
#SOAL 2
library(BSDA)

ban_jenis_1 = c(4.2, 4.7, 6.6, 7, 6.7, 4.5, 5.7, 6, 7.4, 4.9, 6.1, 5.2, 5.7, 6.9, 6.8, 4.9)
ban_jenis_2 = c(4.1, 4.9, 6.2, 6.9, 6.8, 4.4, 5.7, 5.8, 6.9, 4.9, 6, 4.9, 5.3, 6.5, 7.1, 4.8)

hasil_st_ban = SIGN.test(ban_jenis_1, ban_jenis_2, alternative=  "less")

print(hasil_st_ban)
## 
##  Dependent-samples Sign-Test
## 
## data:  ban_jenis_1 and ban_jenis_2
## S = 11, p-value = 0.9935
## alternative hypothesis: true median difference is less than 0
## 95 percent confidence interval:
##       -Inf 0.2826053
## sample estimates:
## median of x-y 
##           0.1 
## 
## Achieved and Interpolated Confidence Intervals: 
## 
##                   Conf.Level L.E.pt U.E.pt
## Lower Achieved CI     0.8949   -Inf 0.2000
## Interpolated CI       0.9500   -Inf 0.2826
## Upper Achieved CI     0.9616   -Inf 0.3000
  1. WILCOXON TEST
wilcox.test(Oks, mu = 1.8, alternative = "two.sided")
## Warning in wilcox.test.default(Oks, mu = 1.8, alternative = "two.sided"):
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(Oks, mu = 1.8, alternative = "two.sided"):
## cannot compute exact p-value with zeroes
## 
##  Wilcoxon signed rank test with continuity correction
## 
## data:  Oks
## V = 13, p-value = 0.1522
## alternative hypothesis: true location is not equal to 1.8
  1. BINOMIAL TEST
binom.test(x=8, n=20, p=1/2)
## 
##  Exact binomial test
## 
## data:  8 and 20
## number of successes = 8, number of trials = 20, p-value = 0.5034
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.1911901 0.6394574
## sample estimates:
## probability of success 
##                    0.4
  1. CHI-SQUARE
zodiac_signs <- c("Aries", "Taurus", "Libra", "Gemini", "Cancer", "Leo", "Virgo", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces")
respondent_counts<- c(29, 24, 22, 19, 21, 18, 19, 20, 23, 18, 20, 23)

n <- sum(respondent_counts)
expected_counts <- rep(n/length(respondent_counts), length(respondent_counts)) / n 

chisq_result <- chisq.test(respondent_counts, p = expected_counts)
chisq_result
## 
##  Chi-squared test for given probabilities
## 
## data:  respondent_counts
## X-squared = 5.0938, df = 11, p-value = 0.9265
  1. KOLMOGOROV SMIRNOV