Massive univariate linear model.
T tests maxTΒΆ
Credit: E Duchesnay
import numpy as np
import mulm
import pylab as plt
n = 100
px = 5
py_info = 2
py_noize = 100
beta = np.array([1, 0, .5] + [0] * (px - 4) + [2]).reshape((px, 1))
X = np.hstack([np.random.randn(n, px-1), np.ones((n, 1))]) # X with intercept
Y = np.random.randn(n, py_info + py_noize)
# Causal model: add X on the first py_info variable
Y[:, :py_info] += np.dot(X, beta)
# t-test all the regressors (by default mulm and sm do two-tailed tests)
contrasts = np.identity(X.shape[1])
mod = mulm.MUOLS(Y, X)
tvals, rawp, df = mod.fit().t_test(contrasts, pval=True, two_tailed=True)
tvals, maxTpval, df2 = mod.t_test_maxT(contrasts, two_tailed=True)
n, bins, patches = plt.hist([rawp[0,:], maxTpval[0,:]],
color=['blue', 'red'],
label=['rawp','maxTpval'])
plt.legend()
plt.show()
Total running time of the script: ( 0 minutes 0.000 seconds)
Gallery generated by Sphinx-Gallery
Follow us
© 2021,
pylearn-mulm developers
.
Inspired by AZMIND template.
Inspired by AZMIND template.