The Wayback Machine - https://web.archive.org/web/20240619121201/https://www.geeksforgeeks.org/fligner-killeen-test-in-r-programming/
Open In App

Fligner-Killeen Test in R Programming

Last Updated : 12 Oct, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The Fligner-Killeen test is a non-parametric test for homogeneity of group variances based on ranks. It is useful when the data are non-normally distributed or when problems related to outliers in the dataset cannot be resolved. It is also one of the many tests for homogeneity of variances which is most robust against departures from normality. There are several solutions to test for the equality (homogeneity) of variance across groups, including:

  • F-test
  • Bartlett’s test
  • Levene’s test
  • Fligner-Killeen test

It is very much easy to perform these tests in R programming. In this article let’s perform the Fligner-Killeen test in R.

Statistical Hypotheses for Fligner-Killeen test

A hypothesis is a statement about the given problem. Hypothesis testing is a statistical method that is used in making a statistical decision using experimental data. Hypothesis testing is basically an assumption that we make about a population parameter. It evaluates two mutually exclusive statements about a population to determine which statement is best supported by the sample data. To know more about the statistical hypothesis please refer to Understanding Hypothesis Testing. For Fligner-Killeen test the statistical hypotheses are:

  • Null Hypothesis: All populations variances are equal
  • Alternative Hypothesis: At least two of them differ

Implementation in R

The R provides a function fligner.test() which is available in stats package that can be used to compute the Fligner-Killeen test. The syntax for this function is given below:

Syntax:

fligner.test(formula, dataset)

 

Parameters:

formula: a formula of the form values ~ groups

dataset: a matrix or data frame

Examples of Fligner-Killeen test

Fligner-Killeen test with one independent variable:

Consider the R’s inbuilt PlantGrowth dataset that gives the dried weight of three groups of ten batches of plants, wherever every group of ten batches got a different treatment. The weight variable gives the weight of the batch and the group variable gives the treatment received either ctrl, trt1 or trt2. To view the data set please type below command:

R




print(PlantGrowth)


Output:

    weight group
1    4.17  ctrl
2    5.58  ctrl
3    5.18  ctrl
4    6.11  ctrl
5    4.50  ctrl
6    4.61  ctrl
7    5.17  ctrl
8    4.53  ctrl
9    5.33  ctrl
10   5.14  ctrl
11   4.81  trt1
12   4.17  trt1
13   4.41  trt1
14   3.59  trt1
15   5.87  trt1
16   3.83  trt1
17   6.03  trt1
18   4.89  trt1
19   4.32  trt1
20   4.69  trt1
21   6.31  trt2
22   5.12  trt2
23   5.54  trt2
24   5.50  trt2
25   5.37  trt2
26   5.29  trt2
27   4.92  trt2
28   6.15  trt2
29   5.80  trt2
30   5.26  trt2

As mentioned above, the Fligner-Killeen test is useful when the data are non-normally distributed or when problems related to outliers in the dataset cannot be resolved. Here let’s consider only one independent variable. To perform the test, use the below command:

R




# R program to illustrate
# Fligner-Killeen test
  
# Import required package
library(stats)
  
# Using fligner.test()
result = fligner.test(weight ~ group, PlantGrowth)
  
# print the result
print(result)


Output:

Fligner-Killeen test of homogeneity of variances

data:  weight by group
Fligner-Killeen:med chi-squared = 2.3499, df = 2, p-value = 0.3088

Fligner-Killeen test with multiple independent variables:

If one wants to do the test with multiple independent variables then the interaction() function must be used to collapse multiple factors into a single variable containing all combinations of the factors. Here let’s take the R’s inbuilt ToothGrowth data set.

R




# R program to illustrate
# Fligner-Killeen test
  
# Import required package
library(stats)
  
# Using fligner.test()
result = fligner.test(len ~ interaction(supp, dose), 
                      data = ToothGrowth)
  
# print the result
print(result)


Output:

Fligner-Killeen test of homogeneity of variances

data:  len by interaction(supp, dose)
Fligner-Killeen:med chi-squared = 7.7488, df = 5, p-value = 0.1706


Similar Reads

Performing Binomial Test in R programming - binom.test() Method
With the help of binom.test() method, we can get the binomial test for some hypothesis of binomial distribution in R Programming. Syntax: binom.test(x, n, p-value) Return: Returns the value of binomial test. Example 1: # Using binom.test() method gfg <- binom.test(58, 100) print(gfg) Output: Exact binomial test data: 58 and 100 number of success
1 min read
Performing F-Test in R programming - var.test() Method
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: C/C++ C
1 min read
Differences Between two-sample, t-test and paired t-test
Statistical tests are essential tools in data analysis, helping researchers make inferences about populations based on sample data. Two common tests used to compare the means of different groups are the two-sample t-test and the paired t-test. Both tests are based on the t-distribution, but they have distinct use cases and assumptions. In this arti
7 min read
T-Test Approach in R Programming
We will be trying to understand the T-Test in R Programming with the help of an example. Suppose a businessman with two sweet shops in a town wants to check if the average number of sweets sold in a day in both stores is the same or not. So, the businessman takes the average number of sweets sold to 15 random people in the respective shops. He foun
6 min read
One-Proportion Z-Test in R Programming
The One proportion Z-test is used to compare an observed proportion to a theoretical one when there are only two categories. For example, we have a population of mice containing half male and half females (p = 0.5 = 50%). Some of these mice (n = 160) have developed spontaneous cancer, including 95 males and 65 females. We want to know, whether canc
4 min read
Kolmogorov-Smirnov Test in R Programming
The Kolmogorov-Smirnov Test is a type of non-parametric test of the equality of discontinuous and continuous a 1D probability distribution that is used to compare the sample with the reference probability test (known as one-sample K-S Test) or among two samples (known as two-sample K-S test). A K-S Test quantifies the distance between the cumulativ
4 min read
Shapiro–Wilk Test in R Programming
The Shapiro-Wilk's test or Shapiro test is a normality test in frequentist statistics. The null hypothesis of Shapiro's test is that the population is distributed normally. It is among the three tests for normality designed for detecting all kinds of departure from normality. If the value of p is equal to or less than 0.05, then the hypothesis of n
4 min read
Two-Proportions Z-Test in R Programming
A two-proportion z-test allows us to compare two proportions to see if they are the same. It calculates the range of values that is likely to include the difference between the population proportions. The z-test is based on a standard normal distribution. It has a critical value i.e. 1.96. for 5% two-tailed. In R, the function used for performing a
6 min read
Fisher’s F-Test in R Programming
Fisher’s F test calculates the ratio between the larger variance and the smaller variance. We use the F test when we want to check whether the means of three or more groups are different or not. F-test is used to assess whether the variances of two populations (A and B) are equal. The method is simple; it consists of taking the ratio between the la
4 min read
Wilcoxon Signed Rank Test in R Programming
The Wilcoxon signed-rank test is a non-parametric statistical hypothesis test used to compare two related samples, matched samples, or repeated measurements on a single sample to estimate whether their population means ranks differ e.g. it is a paired difference test. It can be applied as an alternative to the paired Student's t-test also known as
7 min read