helpingMethods.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:sGLMM 作者: YeWenting 项目源码 文件源码
def tstat(beta, var, sigma, q, N, log=False):

    """
       Calculates a t-statistic and associated p-value given the estimate of beta and its standard error.
       This is actually an F-test, but when only one hypothesis is being performed, it reduces to a t-test.
    """
    ts = beta / np.sqrt(var * sigma)
    print ts
    # ts = beta / np.sqrt(sigma)
    # ps = 2.0*(1.0 - stats.t.cdf(np.abs(ts), self.N-q))
    # sf == survival function - this is more accurate -- could also use logsf if the precision is not good enough
    if log:
        ps = 2.0 + (stats.t.logsf(np.abs(ts), N - q))
    else:
        ps = 2.0 * (stats.t.sf(np.abs(ts), N - q))
    print ps
    # if not len(ts) == 1 or not len(ps) == 1:
    #     raise Exception("Something bad happened :(")
        # return ts, ps
    return ts.sum(), ps.sum()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号