With regards to **z-test**, there is NO `z.test()`

function in R, unfortunately. However, the package

contains a **TeachingDemos**`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 H
_{a}. The null hypothesis H_{0 }states that the sample mean is NOT different from the population mean. Your alternative hypothesis H_{a}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”.

More info about

`TeachingDemos`

is available here.R returns several lines of text. One of them provides a

**p-value**while the next line states the**alternative hypothesis**which depends on the parameter alternative=”XXX” that you have entered in the`z.test()`

. This alternative hypothesis H_{a}is considered valid when the p-value is less than 0.05.