Question

IQ scores of 5 persons are measured before and after training. Test whether there is any change in IQ.

before <- c(110, 120, 123, 132, 125)
after <- c(120, 118, 125, 136, 121)

data.frame(Candidate = c("I", "II", "III", "IV", "V"),
           IQ_Before = before,
           IQ_After = after,
           Difference = after - before)
##   Candidate IQ_Before IQ_After Difference
## 1         I       110      120         10
## 2        II       120      118         -2
## 3       III       123      125          2
## 4        IV       132      136          4
## 5         V       125      121         -4

Hypotheses

result <- t.test(after, before, paired = TRUE, alternative = "two.sided")
result
## 
##  Paired t-test
## 
## data:  after and before
## t = 0.8165, df = 4, p-value = 0.4601
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -4.800874  8.800874
## sample estimates:
## mean difference 
##               2
if (result$p.value < alpha) {
  cat("Decision: Reject H0 at 5% significance level.\n")
  cat("Conclusion: There is a significant change in IQ after training.")
} else {
  cat("Decision: Fail to reject H0 at 5% significance level.\n")
  cat("Conclusion: No significant change in IQ is detected after training.")
}
## Decision: Fail to reject H0 at 5% significance level.
## Conclusion: No significant change in IQ is detected after training.