var_test: Variance test using values

View source: R/var_test.R

var_testR Documentation

Variance test using values

Description

This function performs the test for a single variance or two variances using values, not the vectors.

Usage

var_test(
  varx,
  nx,
  vary = NULL,
  ny = NULL,
  alternative = "two.sided",
  null.value = 1,
  conf.level = 0.95
)

Arguments

varx

sample variance for sample x.

nx

sample size for sample x.

vary

sample variance for sample y.

ny

sample size for sample y.

alternative

a character string specifying the alternative hypothesis, must be one of two.sided (default), greater or less. You can specify just the initial letter.

null.value

the hypothesized number (variance or ratio of the variances) in the null hypothesis.

conf.level

confidence level of the interval, by default its value is 0.95.

Value

A list with class htest containing the following components:

statistic

the value of the statistic.

p.value

the p-value for the test.

conf.int

a confidence interval for the variance.

estimate

the sample variance (or ratio of the sample variances)

null.value

the specified hypothesized value for alternative hypothesis.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating the type of test performed.

Examples

# Examples with ONE sample

# Example 7.7.1 from Wayne (2013), http://tinyurl.com/y6z49hrw
var_test(varx=670.81, nx=16, null.value=600, alternative='two.sided')

# Exercise 7.7.5 from Wayne (2013), http://tinyurl.com/y6z49hrw
var_test(varx=30, nx=25, null.value=25, alternative='greater')

# Using the plot to illustrate Hypothesis Test
mytest1 <- var_test(varx=30, nx=25, null.value=25, alternative='greater')
mytest1
plot(mytest1)

# Examples with TWO samples

# Example 7.8 from Montgomery (1996)
var_test(varx=5.1^2, nx=12, vary=4.7^2, ny=15, conf.level=0.90)

# Example 8.17 from Montgomery (1996)
mytest2 <- var_test(varx=3.84, nx=20, vary=4.54, ny=20)
mytest2
plot(mytest2)


fhernanb/stests documentation built on March 29, 2025, 10:36 a.m.