-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample-6-3.py
More file actions
32 lines (26 loc) · 964 Bytes
/
Copy pathExample-6-3.py
File metadata and controls
32 lines (26 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import wooldridge as woo
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
attend = woo.dataWoo('attend')
n = attend.shape[0]
reg = smf.ols(formula='stndfnl ~ atndrte*priGPA + ACT + I(priGPA**2) + I(ACT**2)',
data=attend)
results = reg.fit()
# print regression table:
table = pd.DataFrame({'b': round(results.params, 4),
'se': round(results.bse, 4),
't': round(results.tvalues, 4),
'pval': round(results.pvalues, 4)})
print(f'table: \n{table}\n')
# estimate for partial effect at priGPA=2.59:
b = results.params
partial_effect = b['atndrte'] + 2.59 * b['atndrte:priGPA']
print(f'partial_effect: {partial_effect}\n')
# F test for partial effect at priGPA=2.59:
hypotheses = 'atndrte + 2.59 * atndrte:priGPA = 0'
ftest = results.f_test(hypotheses)
fstat = ftest.statistic[0][0]
fpval = ftest.pvalue
print(f'fstat: {fstat}\n')
print(f'fpval: {fpval}\n')