Learn R Programming

TH (version 1.0.0)

tz2: Two-Sample Z Test

Description

Performs a Z test for comparing two population means when both population variances are known.

Usage

tz2(
  dadosX = NULL,
  dadosY = NULL,
  vpX,
  vpY,
  alfa = 0.05,
  Ha = 1,
  mX = NULL,
  nX = NULL,
  mY = NULL,
  nY = NULL,
  plot = TRUE
)

Value

Invisibly returns an object of classes th_test and htest containing the test statistic, degrees of freedom when applicable, p-value, estimates, critical values, significance level, and decision. When plot = TRUE, the educational graph is produced as a side effect.

Arguments

dadosX

Numeric vector for the first sample. Use NULL when summary statistics are supplied.

dadosY

Numeric vector for the second sample. Use NULL when summary statistics are supplied.

vpX

Known population variance for the first population.

vpY

Known population variance for the second population.

alfa

Significance level.

Ha

Alternative hypothesis. Use 1 or "two.sided", 2 or "greater", and 3 or "less".

mX

Mean of the first sample when dadosX = NULL.

nX

Size of the first sample when dadosX = NULL.

mY

Mean of the second sample when dadosY = NULL.

nY

Size of the second sample when dadosY = NULL.

plot

Logical. If TRUE (default), draw the educational graph; if FALSE, return the result without plotting.

Author

Willian Silva Barros

Details

Raw-data and summary-statistics modes are mutually exclusive. The function accepts raw data or summary statistics for two samples and displays the hypothesis test graphically.

Main assumptions:

  • independent samples;

  • known population variances;

  • normal populations or adequately large samples;

Examples

Run this code
X <- c(15, 16, 14, 17, 15, 16, 14, 15)
Y <- c(11, 12, 13, 10, 12, 11, 13, 12)
tz2(X, Y, vpX = 4, vpY = 4, alfa = 0.05, Ha = 2, plot = FALSE)

Run the code above in your browser using DataLab