Open In App
Related Articles

Performing F-Test in R programming – var.test() Method

Improve Article
Improve
Save Article
Save
Like Article
Like

var.test() Method in R Programming language perform the f-test between two normal populations with some hypothesis that variances of two populations are equal in R programming. 

var.test() Method in R Syntax

Syntax: var.test()

Return: Returns the F-Test score for some hypothesis. 
 

var.test() Method in R Programming language Example

Example 1: 

R




x <- rnorm(50, mean=0)
y <- rnorm(50, mean=1)
 
# Using var.test() method
gfg <- var.test(x, y)
 
print(gfg)


Output:

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 

Example 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)


Output:

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 

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 07 Jan, 2022
Like Article
Save Article
Previous
Next
Similar Reads