I am trying to compute the regression output using the Python library, but I cannot get the interception value when I use the library:
import statsmodels.api as sm
He prints the entire regression analysis except interception.
but when i use:
from pandas.stats.api import ols
My code for pandas:
Regression = ols(y= Sorted_Data3['net_realization_rate'],x = Sorted_Data3[['Cohort_2','Cohort_3']])
print Regression
I get an interception with a warning that this library will be deprecated in the future, so I am trying to use Statsmodels.
warning i get when using pandas.stats.api:
( ): "C:\Python27\lib\idlelib\run.py", 325 self.locals. FutureWarning: pandas.stats.ols ., , statsmodels, . : http://statsmodels.sourceforge.net/stable/regression.html
Statsmodels:
import pandas as pd
import numpy as np
from pandas.stats.api import ols
import statsmodels.api as sm
Data1 = pd.read_csv('C:\Shank\Regression.csv')
print Data1
sm_model = sm.OLS(Sorted_Data3['net_realization_rate'],Sorted_Data3[['Cohort_2','Cohort_3']])
results = sm_model.fit()
print '\n'
print results.summary()
statsmodels.formula.api: as:
sm_model = sm.OLS(formula ="net_realization_rate ~ Cohort_2 + Cohort_3", data = Sorted_Data3)
results = sm_model.fit()
print '\n'
print result.params
print '\n'
print results.summary()
:
TypeError: init() 2 (1 )
: 1- , 2- .... , : 