Fligner-Killeen Test in R Programming

12 Oct, 2020
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.
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
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
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 packagelibrary(stats)  # Using fligner.test()result = fligner.test(weight ~ group, PlantGrowth)  # print the resultprint(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 packagelibrary(stats)  # Using fligner.test()result = fligner.test(len ~ interaction(supp, dose),                       data = ToothGrowth)  # print the resultprint(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

R Data-science
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming