import numpy as npimport wooldridge as wooimport statsmodels.formula.api as smfmeap93 = woo.dataWoo('meap93')# estimate the model and save the results as "results":reg = smf.ols(formula='math10 ~ lnchprg', data=meap93)results = reg.fit()# number of obs.:n = results.nobs# SER:u_hat_var = np.var(results.resid, ddof=1)SER = np.sqrt(u_hat_var) * np.sqrt((n - 1) / (n - 2))print(f'SER: {SER}\n')# SE of b0 & b1, respectively:lnchprg_sq_mean = np.mean(meap93['lnchprg'] ** 2)lnchprg_var = np.var(meap93['lnchprg'], ddof=1)b1_se = SER / (np.sqrt(lnchprg_var)* np.sqrt(n - 1)) * np.sqrt(lnchprg_sq_mean)b0_se = SER / (np.sqrt(lnchprg_var) * np.sqrt(n - 1))print(f'b1_se: {b1_se}\n')print(f'b0_se: {b0_se}\n')# automatic calculations:print(f'results.summary(): \n{results.summary()}\n')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。