-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathrepl.txt
89 lines (66 loc) · 2.38 KB
/
repl.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{{alias}}( x[, options] )
Performs a chi-square independence test.
For a two-way contingency table, the function computes a chi-square
independence test for the null hypothesis that the joint distribution of the
cell counts is the product of the row and column marginals (i.e. that the
row and column variables are independent).
The chi-square approximation may be incorrect if the observed or expected
frequencies in each category are too small. Common practice is to require
frequencies greater than five. The Yates' continuity correction is enabled
by default for 2x2 tables to account for this, although it tends to
over-correct.
The function returns an object containing the test statistic, p-value, and
decision.
Parameters
----------
x: ndarray|Array<Collection<number>>
Two-way table of observed frequencies.
options: Object (optional)
Options.
options.alpha: number (optional)
Significance level of the hypothesis test. Must be on the interval
[0,1]. Default: 0.05.
options.correct: boolean (optional)
Boolean indicating whether to use Yates' continuity correction when
provided a 2x2 contingency table. Default: true.
Returns
-------
out: Object
Test results object.
out.alpha: number
Significance level.
out.rejected: boolean
Test decision.
out.pValue: number
Test p-value.
out.statistic: number
Test statistic.
out.df: number
Degrees of freedom.
out.expected: ndarray
Expected frequencies.
out.method: string
Test name.
out.toString: Function
Serializes results as formatted output.
out.toJSON: Function
Serializes results as JSON.
Examples
--------
> var x = [ [ 20, 30 ], [ 30, 20 ] ];
> var out = {{alias}}( x );
> var o = out.toJSON()
{ 'rejected': false, 'pValue': ~0.072, 'statistic': 3.24, ... }
> out.toString()
// Set significance level...
> var opts = { 'alpha': 0.1 };
> out = {{alias}}( x, opts );
> o = out.toJSON()
{ 'rejected': true, 'pValue': ~0.072, 'statistic': 3.24, ... }
> out.toString()
// Disable Yates' continuity correction (primarily used with small counts):
> opts = { 'correct': false };
> out = {{alias}}( x, opts );
> out.toString()
See Also
--------