在 R 编程中执行 F-Test – var.test() 方法
R 编程语言中的 var.test() 方法在两个正常总体之间执行 f 检验,并假设在 R 编程中两个总体的方差相等。
R 语法中的 var.test() 方法
Syntax: var.test()
Return: Returns the F-Test score for some hypothesis.
R 编程语言示例中的 var.test() 方法
示例 1:
R
x <- rnorm(50, mean=0)
y <- rnorm(50, mean=1)
# Using var.test() method
gfg <- var.test(x, y)
print(gfg)
R
x <- rnorm(50, mean=1.2)
y <- rnorm(50, mean=1.8)
# Using var.test() method
gfg <- var.test(x, y)
print(gfg)
输出:
F test to compare two variances
data: x and y
F = 1.0779, num df = 49, denom df = 49, p-value = 0.794
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.6116778 1.8994484
sample estimates:
ratio of variances
1.077892
示例 2:
R
x <- rnorm(50, mean=1.2)
y <- rnorm(50, mean=1.8)
# Using var.test() method
gfg <- var.test(x, y)
print(gfg)
输出:
F test to compare two variances
data: x and y
F = 2.382, num df = 49, denom df = 49, p-value = 0.002911
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
1.351715 4.197491
sample estimates:
ratio of variances
2.381976