RStudio: Inferential Statistics

Type of Data: Quantitative (Numerical)

  • Z- Procedure: σ Known
  • t-Procedure: σ Unknown

PACKAGE: BSDA

GENERAL FORM OF R COMMAND:

z.test(dataframename$variablename, alternative = " ", mu = munull, sigma.x = knownstandarddeviation, conf.level = 0.95)

alternative could be equal to "greater", "less", or "two.sided".

EXAMPLE:

Dataset:

We are asked to analyze the average height of individuals of Italian nationality. The variance of the Italian population is known to be 5. Here is the data:

175, 168, 168, 190, 156, 181, 182, 175, 174, 179

We will test the hypothesis that the true mean height is different than 170, and construct a confidence interval.

Since the data set is small we will enter the data directly to R without using a data frame.

a = c(175, 168, 168, 190, 156, 181, 182, 175, 174, 179)

library(BSDA)

z.test(a, alternative = "two.sided", mu = 170, sigma.x = 2.24, conf.level = 0.95)

Note that we have been given the varaince, you need to take the square root of 5 for the standard deviation.

EXERCISE: Construct a 99% confidence interval for this problem