is it possible to get other values (currently I know only a way to get beta and intercept) from the summary of linear regression in pandas? I need to get R-squared. Here is
try:
print model.r2
for example:
import pandas as pd
from pandas import Panel
from pandas.io.data import DataReader
import scikits.statsmodels.api as sm
symbols = ['MSFT', 'GOOG', 'AAPL']
data = dict((sym, DataReader(sym, "yahoo")) for sym in symbols)
panel = Panel(data).swapaxes('items', 'minor')
close_px = panel['Close']
# convert closing prices to returns
rets = close_px / close_px.shift(1) - 1
model = pd.ols(y=rets['AAPL'], x=rets.ix[:, ['GOOG']])
print model.r2
Docs: http://statsmodels.sourceforge.net/stable/index.html
Docs handling the results of the regression - this will allow you to extract a number of values from your regression results:
# Given
model = ols(y=rets['AAPL'], x=rets.ix[:, ['GOOG']])
In the case of r-squared
use:
# retrieving model's r-squared value
model.rsquared
and in the case of p-values
use:
# return p-values and corresponding coefficients in model
model.pvalues
For more parameters (fvalues
ess
) please refer to the doc