numpy - Multiple regression with OLS in python -
i have code multiple ols-regression newey-west procedure.
import pandas pd import numpy np import statsmodels.api sm df = pd.dataframe({'a':[1,3,5,7,4,5,6,4,7,8,9], 'b':[3,5,6,2,4,6,7,8,7,8,9]}) results = sm.ols(df.a, sm.add_constant(df.b)).fit() new = results.get_robustcov_results(cov_type='hac',maxlags=1) print new.summary()
it works, how should change code, if have more variables like....
df = pd.dataframe({'a':[1,3,5,7,4,5,6,4,7,8,9], 'b':[3,5,6,2,4,6,7,8,7,8,9], 'c':[3,5,6,2,4,8,7,8,9,9,9], 'd':[3,5,6,2,5,8,8,9,8,10,9]})
... , wanted analyse influence on variable a, analysis of variable b in original code?
how should code-line results = sm.ols(df.a, sm.add_constant(df.b)).fit()
looks like?
thanks!!
you can supply multiple variables this:
results = sm.ols(df.a, sm.add_constant(df[list('bcd')])).fit()
Comments
Post a Comment