Last active
October 9, 2022 16:26
-
-
Save galenseilis/3ecc54807a7fd949d8701ceac6021566 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Easier method: regress y−2x against x and read the t-test results directly off the summary, making sure to halve any reported p-values to account for the one-sided alternative. | |
- whuber | |
''' | |
import numpy as np | |
import statsmodels.api as sm | |
x = np.array([1,2,3,3,4,5,5]) | |
y = np.array([3,7,5,8,11,14,12]) | |
Y = y - 2 * x | |
X = sm.add_constant(x) | |
model = sm.OLS(Y, X) | |
results = model.fit() | |
print(results.summary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment