简体   繁体   中英

Dummy Variable Regression in Python

I would like to run create a dummy variable regression in Python. So, I have a list of rates from 2000 to 2020 and I want to estimate the non-crisis (NC) and crisis (C) period alphas and betas from the following model incorporating dummy variables with respect to alphas and the coefficients of the risk factors:

Model

where Dnc,t is a dummy variable that takes a value of 1 for non-crisis periods and 0 otherwise and Dc,t is a dummy variable that takes a value of 1 for crisis periods and 0 otherwise. Now, I would like to run this regression in python.

Assuming that you're looking for Logistic Regression and you already have your X and Y variables in Pandas dataframes

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_)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM