1 Star 0 Fork 0

yanbridge/Python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Example-2-3.py 428 Bytes
一键复制 编辑 原始数据 按行查看 历史
yanbridge 提交于 2020-10-07 19:43 +08:00 . Add files via upload
import wooldridge as woo
import numpy as np
ceosal1 = woo.dataWoo('ceosal1')
x = ceosal1['roe']
y = ceosal1['salary']
# ingredients to the OLS formulas:
cov_xy = np.cov(x, y)[1, 0] # access 2. row and 1. column of covariance matrix
var_x = np.var(x, ddof=1)
x_bar = np.mean(x)
y_bar = np.mean(y)
# manual calculation of OLS coefficients:
b1 = cov_xy / var_x
b0 = y_bar - b1 * x_bar
print(f'b1: {b1}\n')
print(f'b0: {b0}\n')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yanbridge/Python.git
git@gitee.com:yanbridge/Python.git
yanbridge
Python
Python
main

搜索帮助