import wooldridge as wooimport numpy as npimport statsmodels.formula.api as smfgpa1 = woo.dataWoo('gpa1')# full estimation results including automatic SE:reg = smf.ols(formula='colGPA ~ hsGPA + ACT', data=gpa1)results = reg.fit()# extract SER (instead of calculation via residuals):SER = np.sqrt(results.mse_resid)# regressing hsGPA on ACT for calculation of R2 & VIF:reg_hsGPA = smf.ols(formula='hsGPA ~ ACT', data=gpa1)results_hsGPA = reg_hsGPA.fit()R2_hsGPA = results_hsGPA.rsquaredVIF_hsGPA = 1 / (1 - R2_hsGPA)print(f'VIF_hsGPA: {VIF_hsGPA}\n')# manual calculation of SE of hsGPA coefficient:n = results.nobssdx = np.std(gpa1['hsGPA'], ddof=1) * np.sqrt((n - 1) / n)SE_hsGPA = 1 / np.sqrt(n) * SER / sdx * np.sqrt(VIF_hsGPA)print(f'SE_hsGPA: {SE_hsGPA}\n')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。