README.md (4556B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # flignerTest 22 23 > Compute the Fligner-Killeen test for equal variances. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var flignerTest = require( '@stdlib/stats/fligner-test' ); 37 ``` 38 39 #### flignerTest( a\[,b,...,k]\[, opts] ) 40 41 For input arrays `a`, `b`, ... holding numeric observations, this function calculates the Fligner-Killeen test, which tests the null hypothesis that the variances in all `k` groups are the same. 42 43 ```javascript 44 // Data from Hollander & Wolfe (1973), p. 116: 45 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ]; 46 var y = [ 3.8, 2.7, 4.0, 2.4 ]; 47 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ]; 48 49 var out = flignerTest( x, y, z ); 50 /* returns 51 { 52 'rejected': false, 53 'alpha': 0.05, 54 'df': 2, 55 'pValue': ~0.074, 56 'statistic': ~5.209, 57 ... 58 } 59 */ 60 ``` 61 62 The function accepts the following `options`: 63 64 - **alpha**: `number` in the interval `[0,1]` giving the significance level of the hypothesis test. Default: `0.05`. 65 - **groups**: an `array` of group indicators. If set, the function assumes that only a single numeric array is provided holding all observations. 66 67 By default, the test is carried out at a significance level of `0.05`. To choose a custom significance level, set the `alpha` option. 68 69 ```javascript 70 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ]; 71 var y = [ 3.8, 2.7, 4.0, 2.4 ]; 72 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ]; 73 74 var out = flignerTest( x, y, z, { 75 'alpha': 0.1 76 }); 77 /* returns 78 { 79 'rejected': true, 80 'alpha': 0.1, 81 'df': 2, 82 'pValue': ~0.074, 83 'statistic': ~5.209, 84 ... 85 } 86 */ 87 ``` 88 89 The function provides an alternate interface by supplying an array of group indicators to the `groups` option. In this case, it is assumed that only a single numeric array holding all observations is provided to the function. 90 91 <!-- eslint-disable array-element-newline --> 92 93 ```javascript 94 var arr = [ 95 2.9, 3.0, 2.5, 2.6, 3.2, 96 3.8, 2.7, 4.0, 2.4, 97 2.8, 3.4, 3.7, 2.2, 2.0 98 ]; 99 var groups = [ 100 'a', 'a', 'a', 'a', 'a', 101 'b', 'b', 'b', 'b', 102 'c', 'c', 'c', 'c', 'c' 103 ]; 104 out = flignerTest( arr, { 105 'groups': groups 106 }); 107 ``` 108 109 The returned object comes with a `.print()` method which when invoked will print a formatted output of the results of the hypothesis test. `print` accepts a `digits` option that controls the number of decimal digits displayed for the outputs and a `decision` option, which when set to `false` will hide the test decision. 110 111 ```javascript 112 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ]; 113 var y = [ 3.8, 2.7, 4.0, 2.4 ]; 114 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ]; 115 116 var out = flignerTest( x, y, z ); 117 console.log( out.print() ); 118 /* => 119 Fligner-Killeen test of homogeneity of variances 120 121 Null hypothesis: The variances in all groups are the same. 122 123 pValue: 0.0739 124 statistic: 5.2092 125 df: 2 126 127 Test Decision: Fail to reject null in favor of alternative at 5% significance level 128 */ 129 ``` 130 131 </section> 132 133 <!-- /.usage --> 134 135 <section class="examples"> 136 137 ## Examples 138 139 <!-- eslint no-undef: "error" --> 140 141 ```javascript 142 var flignerTest = require( '@stdlib/stats/fligner-test' ); 143 144 // Data from Hollander & Wolfe (1973), p. 116: 145 var x = [ 2.9, 3.0, 2.5, 2.6, 3.2 ]; 146 var y = [ 3.8, 2.7, 4.0, 2.4 ]; 147 var z = [ 2.8, 3.4, 3.7, 2.2, 2.0 ]; 148 149 var out = flignerTest( x, y, z ); 150 /* returns 151 { 152 'rejected': false, 153 'alpha': 0.05, 154 'df': 2, 155 'pValue': ~0.074, 156 'statistic': ~5.209, 157 ... 158 } 159 */ 160 161 var table = out.print(); 162 /* returns 163 Fligner-Killeen test of homogeneity of variances 164 165 Null hypothesis: The variances in all groups are the same. 166 167 pValue: 0.0739 168 statistic: 5.2092 169 df: 2 170 171 Test Decision: Fail to reject null in favor of alternative at 5% significance level 172 */ 173 ``` 174 175 </section> 176 177 <!-- /.examples --> 178 179 <section class="references"> 180 181 </section> 182 183 <!-- /.references --> 184 185 <section class="links"> 186 187 </section> 188 189 <!-- /.links -->