python做面板回归_Python中的面板回归

请尝试下面的操作-我已经从上面的链接复制了股票数据,并为x列添加了随机数据。对于面板回归,您需要注释中提到的“多索引”。df = pd.DataFrame(df.set_index('dates').stack())

df.columns = ['y']

df['x'] = np.random.random(size=len(df.index))

df.info()

MultiIndex: 100 entries, (2015-04-03 00:00:00, AB INBEV) to (2015-05-01 00:00:00, ZC.PA)

Data columns (total 2 columns):

y 100 non-null float64

x 100 non-null float64

dtypes: float64(2)

memory usage: 2.3+ KB

regression = PanelOLS(y=df['y'], x=df[['x']])

regression

-------------------------Summary of Regression Analysis-------------------------

Formula: Y ~ +

Number of Observations: 100

Number of Degrees of Freedom: 2

R-squared: 0.0042

Adj R-squared: -0.0060

Rmse: 0.2259

F-stat (1, 98): 0.4086, p-value: 0.5242

Degrees of Freedom: model 1, resid 98

-----------------------Summary of Estimated Coefficients------------------------

Variable Coef Std Err t-stat p-value CI 2.5% CI 97.5%

--------------------------------------------------------------------------------

x -0.0507 0.0794 -0.64 0.5242 -0.2063 0.1048

intercept 2.1952 0.0448 49.05 0.0000 2.1075 2.2829

---------------------------------End of Summary---------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值