Skip to main content
9 events
when toggle format what by license comment
May 11, 2020 at 15:58 comment added Nicholas G My calculation of degrees of freedom was off. The correct formula is pearsonTest[obs_List, exp_List] /;Dimensions[obs] == Dimensions[exp] := Block[{t}, t = Total[(Flatten@obs - Flatten@exp)^2/Flatten@exp] // N;{Rule["chisqr", t], Rule[pval, SurvivalFunction[ ChiSquareDistribution[ Times @@Table[Dimensions[exp][[i]] - 1, {i, Length@Dimensions@exp}]],t]]}].
May 11, 2020 at 15:05 comment added Nicholas G Because I want to compare 2-dimensional lists, I adjusted this code to pearsonTest[obs_List, exp_List]/;Dimensions[obs] == Dimensions[exp] :=Block[{t}, t = Total[(Flatten@obs - Flatten@exp)^2/Flatten@exp] // N;{Rule["chisqr", t],Rule[pval,SurvivalFunction[ChiSquareDistribution[Length[Flatten@exp] - 1],t]]}]. However, comparing 2x2 outcomes in Excel and this function gives different values, example observed {{4,6},{6,4}} and expected {{5,5},{5,5}}. Any idea what I am missing?
May 15, 2012 at 19:07 comment added Andy Ross @FrederikBrinckJensen you are welcome. I recommend looking at the following post
May 15, 2012 at 18:56 comment added Frederik Brinck Jensen Thanks for this wonderful reply Andy! Can you give me any reference on where to read about the functions and the syntax of mathematica more deeply?
May 15, 2012 at 18:55 vote accept Frederik Brinck Jensen
May 15, 2012 at 15:18 history edited J. M.'s missing motivation CC BY-SA 3.0
cleaned up links
May 15, 2012 at 15:12 comment added J. M.'s missing motivation Hah. I was scratching my head trying to reconcile the stuff in my textbook with the stuff in Mathematica's docs. Thanks for this!
May 15, 2012 at 15:08 history edited Andy Ross CC BY-SA 3.0
added 23 characters in body
May 15, 2012 at 15:01 history answered Andy Ross CC BY-SA 3.0