TEST.mean: Test on the mean

View source: R/UBStats_Main_Visible_ALL_202406.R

TEST.meanR Documentation

Test on the mean

Description

TEST.mean() tests hypotheses on the mean of a population.

Usage

TEST.mean(
  x,
  sigma = NULL,
  mu0 = 0,
  alternative = "two.sided",
  digits = 2,
  force.digits = FALSE,
  use.scientific = FALSE,
  data,
  ...
)

Arguments

x

An unquoted string identifying the numeric variable whose mean is of interest. x can be the name of a vector in the workspace or the name of one of the columns in the data frame specified in the data argument.

sigma

An optional numeric value specifying the population standard deviation. If NULL (default) the population standard deviation is estimated using the data.

mu0

Numeric value that specifies the null hypothesis to test for (default is 0).

alternative

A length-one character vector specifying the direction of the alternative hypothesis. Allowed values are "two.sided" (population mean differs from mu0; default), or "less" (population mean is lower than mu0), or "greater" (population mean is higher than mu0).

digits

Integer value specifying the number of decimals used to round statistics; default to 2. If the chosen rounding formats some non-zero values as zero, the number of decimals is increased so that all values have at least one significant digit, unless the argument force.digits is set to TRUE.

force.digits

Logical value indicating whether reported values should be forcedly rounded to the number of decimals specified in digits even if non-zero values are rounded to zero (default to FALSE).

use.scientific

Logical value indicating whether numbers in tables should be displayed using scientific notation (TRUE); default to FALSE.

data

An optional data frame containing x. If not found in data, x is taken from the environment from which TEST.mean() is called.

...

Additional arguments to be passed to low level functions.

Value

A table reporting the results of the test on the population mean. If the variance is unknown, the test is run using percentiles from both the normal and the Student's t distribution.

Author(s)

Raffaella Piccarreta raffaella.piccarreta@unibocconi.it

See Also

CI.mean() to build confidence intervals for the population mean.

Examples

data(MktDATA, package = "UBStats")

# Test on the mean; KNOWN variance
# - Bilateral test
TEST.mean(NStore_Purch, sigma = 9, mu0 = 5, 
          alternative = "two.sided", data = MktDATA)
# - Unilateral test
TEST.mean(NStore_Purch, sigma = 9,mu0 = 5,
          alternative = "greater", data = MktDATA)

# Test on the mean; UNKNOWN variance;
# - Unilateral test
TEST.mean(TotVal, mu0 = 600, alternative = "less",
          data = MktDATA)

# Arguments force.digits and use.scientific
# An input variable taking very low values
SmallX<-MktDATA$AOV/500
# Default output
TEST.mean(SmallX, mu0 = 0.1)
# Request to use the exact number of digits (default, 2)
TEST.mean(SmallX, mu0 = 0.1,force.digits=TRUE)
# Request to allow scientific notation
TEST.mean(SmallX, mu0 = 0.1,use.scientific=TRUE)

# Output results
out.test_mean<-TEST.mean(TotVal, mu0 = 600, alternative = "less",
                         data = MktDATA)


UBStats documentation built on Sept. 11, 2024, 6:52 p.m.