Я отвечаю на этот конкретный вопрос следующим образом:
def ttest_OLS(res, numberofbeta, X, value=0, alternative='two-sided', level_of_sig = 0.05):
results=np.zeros([2])
# numberofbeta represent the coeffiecent you would like to test 0 standts for interecept
results[0]=res.tvalues[numberofbeta]
results[1]=res.pvalues[numberofbeta]
if isinstance(X, pd.DataFrame):
column=X.columns[numberofbeta]
else:
column=numberofbeta
if alternative == 'two-sided':
if results[1]<level_of_sig:
print("We reject the null hypothesis that the Selected Coefficient: {} is equal to {} with a {} % significance level".format(column, value, level_of_sig*100))
else: print("We accept the null hypothesis that the Selected Coefficient: {} is equal to {} with a {} % significance level".format(column, value, level_of_sig*100))
elif alternative == 'larger':
if (results[0] > 0) & (results[1]/2 < level_of_sig):
print("We reject the null hypothesis that the Selected Coefficient: {} is less than {} with a {} % significance level".format(column, value, level_of_sig*100))
else: print("We accept the null hypothesis that the Selected Coefficient: {} is less than {} with a {} % significance level".format(column, value, level_of_sig*100))
elif alternative == 'smaller':
if (results[0] < 0) & (results[1]/2 < level_of_sig):
print("We reject the null hypothesis that the Selected Coefficient: {} is more than {} with a {} % significance level".format(column, value, level_of_sig*100))
else: print("We accept the null hypothesis that the Selected Coefficient: {} is more than {} with a {} % significance level".format(column, value, level_of_sig*100))
Способ, которым я реализовал следующий вопрос:
import pandas as pd
ttest_OLS(res, 0, X, value=0.5, alternative='two-sided', level_of_sig = 0.02)
Что будетсделать работу. Однако, если у вас есть лучший способ сделать это, пожалуйста, дайте мне знать.