コード例 #1
0
    def __init__(self,
                 y,
                 x,
                 c1=None,
                 c0=None,
                 match=None,
                 sub=None,
                 ds=None,
                 tail=0):
        ct = Celltable(y, x, match, sub, cat=(c1, c0), ds=ds, coercion=asvar)
        c1, c0 = ct.cat

        n = len(ct.y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.y)
        self._x = dataobj_repr(ct.x)
        self.df = n - 2
        groups = ct.x == c1
        groups.dtype = np.int8
        self.t = stats.t_ind(ct.y.x[:, None], groups)[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
        self._c1 = c1
        self._c0 = c0
コード例 #2
0
    def __init__(self,
                 y,
                 x,
                 c1=None,
                 c0=None,
                 match=None,
                 sub=None,
                 ds=None,
                 tail=0):
        if match is None:
            raise TypeError("The `match` argument needs to be specified for a "
                            "related measures t-test.")
        ct = Celltable(y, x, match, sub, cat=(c1, c0), ds=ds, coercion=asvar)
        c1, c0 = ct.cat
        if not ct.all_within:
            raise ValueError(
                "conditions %r and %r do not have the same values "
                "on %s" % (c1, c0, dataobj_repr(ct.match)))

        n = len(ct.y) // 2
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.y)
        self._x = dataobj_repr(ct.x)
        self.c1_mean = ct.y[:n].mean()
        self.c0_mean = ct.y[n:].mean()
        self.diff = ct.y[:n] - ct.y[n:]
        self.df = n - 1
        self.t = stats.t_1samp(self.diff.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
        self._c1 = c1
        self._c0 = c0
コード例 #3
0
    def __init__(self, y, match=None, sub=None, ds=None, tail=0):
        ct = Celltable(y, None, match, sub, ds=ds, coercion=asvar)
        n = len(ct.Y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.Y)
        self.df = n - 1
        self.t = stats.t_1samp(ct.Y.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
コード例 #4
0
    def __init__(self, y, match=None, sub=None, ds=None, tail=0):
        ct = Celltable(y, None, match, sub, ds=ds, coercion=asvar)
        n = len(ct.y)
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.y)
        self.df = n - 1
        self.t = stats.t_1samp(ct.y.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
コード例 #5
0
ファイル: test_stats.py プロジェクト: LauraGwilliams/Eelbrain
def test_t_ind():
    "Test independent samples t-test"
    ds = datasets.get_uts(True)
    y = ds.eval("utsnd.x")
    n_cases = len(y)
    n = n_cases / 2

    t = stats.t_ind(y, n, n)
    p = stats.ttest_p(t, n_cases - 2)
    t_sp, p_sp = scipy.stats.ttest_ind(y[:n], y[n:])
    assert_equal(t, t_sp)
    assert_equal(p, p_sp)
    assert_allclose(stats.ttest_t(p, n_cases - 2), np.abs(t))

    # permutation
    y_perm = np.empty_like(y)
    for perm in permute_order(n_cases, 2):
        stats.t_ind(y, n, n, out=t, perm=perm)
        y_perm[perm] = y
        t_sp, _ = scipy.stats.ttest_ind(y_perm[:n], y_perm[n:])
        assert_allclose(t, t_sp)
コード例 #6
0
def test_t_ind():
    "Test independent samples t-test"
    ds = datasets.get_uts(True)
    y = ds.eval("utsnd.x")
    n_cases = len(y)
    n = n_cases / 2

    t = stats.t_ind(y, n, n)
    p = stats.ttest_p(t, n_cases - 2)
    t_sp, p_sp = scipy.stats.ttest_ind(y[:n], y[n:])
    assert_equal(t, t_sp)
    assert_equal(p, p_sp)
    assert_allclose(stats.ttest_t(p, n_cases - 2), np.abs(t))

    # permutation
    y_perm = np.empty_like(y)
    for perm in permute_order(n_cases, 2):
        stats.t_ind(y, n, n, out=t, perm=perm)
        y_perm[perm] = y
        t_sp, _ = scipy.stats.ttest_ind(y_perm[:n], y_perm[n:])
        assert_allclose(t, t_sp)
コード例 #7
0
    def __init__(self, y, x, c1=None, c0=None, match=None, sub=None, ds=None,
                 tail=0):
        if match is None:
            raise TypeError("The `match` argument needs to be specified for a "
                            "related measures t-test.")
        ct = Celltable(y, x, match, sub, cat=(c1, c0), ds=ds, coercion=asvar)
        c1, c0 = ct.cat
        if not ct.all_within:
            raise ValueError("conditions %r and %r do not have the same values "
                             "on %s" % (c1, c0, dataobj_repr(ct.match)))

        n = len(ct.Y) // 2
        if n <= 2:
            raise ValueError("Not enough observations for t-test (n=%i)" % n)

        self._y = dataobj_repr(ct.Y)
        self._x = dataobj_repr(ct.X)
        self.diff = ct.Y[:n] - ct.Y[n:]
        self.df = n - 1
        self.t = stats.t_1samp(self.diff.x[:, None])[0]
        self.p = stats.ttest_p(self.t, self.df, tail)
        self.tail = tail
        self._c1 = c1
        self._c0 = c0
コード例 #8
0
ファイル: test.py プロジェクト: mhellb/Eelbrain
 def __init__(self, t, df, tail):
     self.t = t
     self.df = df
     self.p = stats.ttest_p(self.t, self.df, tail)
     self.tail = tail
コード例 #9
0
ファイル: test.py プロジェクト: christianbrodbeck/Eelbrain
 def __init__(self, t, df, tail):
     self.t = t
     self.df = df
     self.p = stats.ttest_p(self.t, self.df, tail)
     self.tail = tail