-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PS2_Q2] Linear regression in Python #8
Comments
@zhuyuming96 . Python has three primary packages for running linear regressions, other than doing the linear algebra approach of
import statsmodels.api as sm
# Create object that sets up the regression
reg1 = sm.OLS(endog=df1['logpgp95'], exog=df1[['const', 'avexpr']], missing='drop')
# Actually estimate the coefficients
results = reg1.fit()
# Print STATA-like regression output
print(results.summary())
from linearmodels.iv import IV2SLS
iv = IV2SLS(dependent=df4['logpgp95'],
exog=df4['const'],
endog=df4['avexpr'],
instruments=df4['logem4']).fit(cov_type='unadjusted')
print(iv.summary)
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LogisticRegression
LinReg = LinearRegression()
LinReg.fit(X_train, y_train)
y_LinReg_pred = LinReg.predict(X_test)
LogReg = LogisticRegression()
LogReg.fit(X_train, y_train)
y__LogReg_pred = LogReg.predict(X_test) |
Thank you so much, especially all the resources you provide! These really help. |
I am pretty interested in adapting regression method into the initial guesses. Is sklean a good package? Thanks.
The text was updated successfully, but these errors were encountered: