02. Statistical tests
July 20, 2023Less than 1 minute
z-test
# This is a sample from a population with known standard deviation
x <- rnorm(12, mean=0, sd=2)
BSDA::z.test(x, mu = 1, sigma.x = 2, conf.level = 0.95)
##
## One-sample z-Test
##
## data: x
## z = -1.6353, p-value = 0.102
## alternative hypothesis: true mean is not equal to 1
## 95 percent confidence interval:
## -1.075717 1.187454
## sample estimates:
## mean of x
## 0.0558687
Null hypothesis for the test was that mean equal 1. You know this is not true, as x was generated from the normal distribution with mean equal 0. Unfortunately, the sample size is so small that there are not enough evidences to reject the null hypothesis.
The P-value is greater than the significance level of 5%. Hence, we fail to reject a null hypothesis - based on the data we have, the population mean is equal 1 or it can be equal 1.
95% confidence interval for the mean includes the hypothesised mean 1. Again, it is impossible to reject a null hypothesis.
Try to run the same code but for a larger sample and a story will be very different.