Python中的伪变量回归

2024-05-20 19:53:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在Python中运行create虚拟变量回归。因此,我有一个从2000年到2020年的利率列表,我想通过以下模型估算非危机(NC)和危机(C)期间的alphas和beta,该模型包含了关于alphas和风险因素系数的虚拟变量:

Model

其中,Dnc,t是一个虚拟变量,非危机期间取1,0 否则,Dc,t是一个虚拟变量,危机期取1,危机期取0 否则现在,我想用python运行这个回归


Tags: 模型列表modelcreatedcbeta因素风险
1条回答
网友
1楼 · 发布于 2024-05-20 19:53:59

假设您正在寻找逻辑回归,并且在数据帧中已经有了X和Y变量

from sklearn.linear_model import LogisticRegression
X, y = Your_Predictor_Variables, Your_Target_Variable
clf = LogisticRegression(random_state=0).fit(X, y)

print(clf.coef_, clf.intercept_)

相关问题 更多 >