ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 01 May 2017 11:13:48 -0500Finding a p-value in goodness of fit testhttp://ask.sagemath.org/question/37481/finding-a-p-value-in-goodness-of-fit-test/I'm trying to find the p-value in a goodness of fit test comparing a set of observed values to a set of expected values. In Maple I can do it with **ChiSquareGoodnessOfFitTest(Ob, Ex, level = 0.5, summarize = true)**, but I can't figure out its equivalence in Sage.
There's a function **sage.stats.r.ttest(x, y)**, but when I run it on my sets, it says the p-value is 1 (it's supposed to be 0.00001778, as in Maple).
The sets for reference are *expected=[47.04, 25.48, 31.36, 39.2, 25.48, 27.44]*, *observed=[42, 35, 9, 41, 41, 28]*.Mon, 01 May 2017 10:59:12 -0500http://ask.sagemath.org/question/37481/finding-a-p-value-in-goodness-of-fit-test/Answer by kcrisman for <p>I'm trying to find the p-value in a goodness of fit test comparing a set of observed values to a set of expected values. In Maple I can do it with <strong>ChiSquareGoodnessOfFitTest(Ob, Ex, level = 0.5, summarize = true)</strong>, but I can't figure out its equivalence in Sage.</p>
<p>There's a function <strong>sage.stats.r.ttest(x, y)</strong>, but when I run it on my sets, it says the p-value is 1 (it's supposed to be 0.00001778, as in Maple).</p>
<p>The sets for reference are <em>expected=[47.04, 25.48, 31.36, 39.2, 25.48, 27.44]</em>, <em>observed=[42, 35, 9, 41, 41, 28]</em>.</p>
http://ask.sagemath.org/question/37481/finding-a-p-value-in-goodness-of-fit-test/?answer=37482#post-id-37482This is the same result as in R proper. See [this example](http://sagecell.sagemath.org/?z=eJwr0StJLS7RSNYwMdczMNFRMDLVM7HQUTA21DM2A1KWekZwMSNzPRMTTR2gUqCYsamOgqWOgokhBBtZaGoCAHg2D0A=&lang=r).
However, as [this post points out](http://www.statmethods.net/stats/ttest.html),
> Unlike most statistical packages, the default assumes unequal variance and applies the Welsh df modification.
I don't know much about t tests, and nothing about Maple and stats, so you will have to find out what is up, but my guess is that this has something to do with it.
On another note, if you are only doing statistics, you may wish to use R more directly, as Sage's interface is somewhat cumbersome. (It is quite useful for going back and forth with stuff, though, as I've profited from it myself.)Mon, 01 May 2017 11:13:48 -0500http://ask.sagemath.org/question/37481/finding-a-p-value-in-goodness-of-fit-test/?answer=37482#post-id-37482