var.test | R Documentation |
This function performs the test for a single variance or two variances given the vectors. This function is a generalization of var.test
function from stats
package.
var.test(
x,
y = NULL,
alternative = "two.sided",
null.value = 1,
conf.level = 0.95
)
x |
a (non-empty) numeric vector of data values. |
y |
an optional (non-empty) numeric vector of data values. |
alternative |
a character string specifying the alternative
hypothesis, must be one of |
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. |
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. |
data.name |
a character string giving the name of the data. |
# One sample -----
# Interval confidence
duration <- c(1470, 1510, 1690, 1740, 1900, 2000, 2030,
2010, 2190, 2200, 2290, 2380, 2390, 2480,
2500, 2580, 2700)
var.test(x=duration, conf.level=0.95)
# Hypothesis testing
# H0: sigma2 = 100
# H1: sigma2 > 100
weight <- c(775, 780, 781, 795, 803, 810, 823)
res1 <- var.test(x=weight, alternative='greater', null.value=100)
res1
# Using the plot function
plot(res1)
# Two samples -----
# Hypothesis testing
# H0: sigma1/sigma2 = 1
# H1: sigma1/sigma2 != 1
x1 <- rnorm(50, mean = 0, sd = 2)
x2 <- rnorm(30, mean = 1, sd = 1)
res2 <- var.test(x1, x2)
res2
plot(res2, from=0, to=10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.