I want to evaluate the residuals: (y-hat y).
I know how to do that:
df = pd.read_csv('myFile', delim_whitespace = True, header = None)
df.columns = ['column1', 'column2']
y, X = ps.dmatrices('column1 ~ column2',data = df, return_type = 'dataframe')
model = sm.OLS(y,X)
results = model.fit()
predictedValues = results.predict()
#print predictedValues
yData = df.as_matrix(columns = ['column1'])
res = yData - predictedValues
I wonder if there is a Method to do this (?).
That's stored in the resid
attribute of the Results class
Likewise there's a results.fittedvalues
method, so you don't need the results.predict()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With