var_test2: Two sided or one sided test of hypothesis of 'sigma1^2' and...

View source: R/var_test2.R

var_test2R Documentation

Two sided or one sided test of hypothesis of sigma1^2 and sigma2^2 of two normal samples

Description

Compute the two sided or one sided test of hypothesis of sigma1^2 and sigma2^2 of two normal samples when the population means are known or unknown.

Usage

var_test2(x, y, mu = c(Inf, Inf), side = 0)

Arguments

x

A numeric vector.

y

A numeric vector.

mu

The population means. When it is known, input it, and the function computes the F value using an F distribution with degree of freedom (n1, n2). When it is unknown, ignore it, and the function computes the F value using an F distribution with degree of freedom (n1-1, n2-1).

side

A parameter used to control two sided or one sided test of hypothesis. When inputting side = 0 (default), the function computes two sided test of hypothesis, and H1: sigma1^2 != sigma2^2; when inputting side = -1 (or a number < 0), the function computes one sided test of hypothesis, and H1: sigma1^2 < sigma2^2; when inputting side = 1 (or a number > 0), the function computes one sided test of hypothesis, and H1: sigma1^2 > sigma2^2.

Value

A data.frame with variables:

rate

The estimate of the ratio of population variances, rate = Sx2/Sy2. When the population means mu is known, Sx2 = 1/n1*sum((x-mu[1])^2) and Sy2 = 1/n2*sum((y-mu[2])^2. When mu is unknown, Sx2 = var(x) and Sy2 = var(y).

df1

The first degree of freedom.

df2

The second degree of freedom.

F

The F statistic.

p_value

The P value.

Author(s)

Ying-Ying Zhang (Robert) robertzhangyying@qq.com

References

Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2991/asshm-13.2013.29")}.

Examples

x=rnorm(10, mean = 1, sd = 0.2); x
y=rnorm(20, mean = 2, sd = 0.3); y
var_test2(x, y, mu = c(1, 2), side = 1)
var_test2(x, y, side = 1)

OneTwoSamples documentation built on March 31, 2023, 11:49 p.m.