00001 using System;
00002 using System.Collections.Generic;
00003
00004 namespace StephenAshley.Biostatistics
00005 {
00006 using NUMBER = Decimal;
00007
00015 public class McNemarsGroupsCollection : GroupsCollection
00016 {
00017 #region *** constructors ***
00021 public McNemarsGroupsCollection()
00022 : base()
00023 {
00024 }
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00039 public McNemarsGroupsCollection(List<Group> lstGroups)
00040 : base(lstGroups)
00041 { }
00042 #endregion
00043 #region *** properties ***
00050 public NUMBER ChiSquared()
00051 {
00052 NUMBER decA = groupsArray[0][0];
00053 NUMBER decB = groupsArray[1][0];
00054 NUMBER decC = groupsArray[0][1];
00055 NUMBER decD = groupsArray[1][1];
00056 NUMBER decX, decY;
00057 if ((decX = decB + decC) == 0)
00058 throw new BiostatisticsException(
00059 "b + c cannot equal 0.");
00060 decY = DecMath.Abs(decB - decC) - 1.0m;
00061 return decY * decY / decX;
00062 }
00063
00070 public NUMBER ChiSquaredUnadjusted()
00071 {
00072 NUMBER decA = groupsArray[0][0];
00073 NUMBER decB = groupsArray[1][0];
00074 NUMBER decC = groupsArray[0][1];
00075 NUMBER decD = groupsArray[1][1];
00076 NUMBER decX, decY;
00077 if ((decX = decB + decC) == 0)
00078 throw new BiostatisticsException(
00079 "b + c cannot equal 0.");
00080 decY = DecMath.Abs(decB - decC);
00081 return decY * decY / decX;
00082 }
00083
00089 public NUMBER p()
00090 {
00091 return Convert.ToDecimal(Distributions.ProbabilityChiSq(
00092 Convert.ToDouble(ChiSquared()), 1));
00093 }
00094
00100 public NUMBER pUnadjusted()
00101 {
00102 return Convert.ToDecimal(Distributions.ProbabilityChiSq(
00103 Convert.ToDouble(ChiSquaredUnadjusted()), 1));
00104 }
00105 #endregion
00106 }
00107 }