With regards to z-test, there is NO
z.test() function in R, unfortunately. However, the package
TeachingDemos contains a
z.test() function which will be helpful. You must install and load the
TeachingDemos package in the same manner as you previously installed
pastecs (see here).
Assuming that you have stored your sample data in the variable
data, the command to use is
z.test(data, mu = Y, stdev = W, alternative="XXX") where:
- Y shall be replaced by the value of the population mean,
- W shall be replaced by the standard deviation of the population (since it is known),
- “XXX” shall be replaced by “greater” OR “less” OR “two.sided” depending of your alternative hypothesis Ha. The null hypothesis H0 states that the sample mean is NOT different from the population mean. Your alternative hypothesis Ha is one of the following:
- the sample mean is greater than the population mean >> use “greater”
- the sample mean is less than the population mean >> use “less”
- the sample mean is either smaller or greater than the population mean >> use “two.sided”.
TeachingDemosis available here.
z.test(). This alternative hypothesis Ha is considered valid when the p-value is less than 0.05.