Accord.Statistics.Testing.McNemarTest.McNemarTest C# (CSharp) Method

McNemarTest() public method

Creates a new McNemar test.
public McNemarTest ( ConfusionMatrix matrix, bool yatesCorrection = false ) : System
matrix Accord.Statistics.Analysis.ConfusionMatrix The contingency table to test.
yatesCorrection bool True to use Yate's correction of /// continuity, falser otherwise. Default is false.
return System
        public McNemarTest(ConfusionMatrix matrix, bool yatesCorrection = false)
        {
            int a = matrix.TruePositives;
            int b = matrix.FalseNegatives;
            int c = matrix.FalsePositives;
            int d = matrix.TrueNegatives;

            double u = b - c;
            
            if (yatesCorrection)
                 u = Math.Abs(u) - 0.5;

            double chiSquare = (u * u) / (b + c);

            int df = 1;

            Compute(chiSquare, df);
        }
McNemarTest