from urllib2 import urlopen import numpy as np import statsmodels.api as sm import pandas import matplotlib.pyplot as plt from statsmodels.formula.api import ols from statsmodels.graphics.api import interaction_plot, abline_plot from statsmodels.stats.anova import anova_lm url = 'http://stats191.stanford.edu/data/kidney.table' kidney_table = pandas.read_table(url, delimiter=" *") Days = kidney_table['Days'] Duration = kidney_table kidney_lm = ols('np.log(Days+1) ~ C(Duration) * C(Weight)', kidney_table).fit() anova_lm(kidney_lm) #This is the style of the examples in the docs, but data=rehab_table doesn't work #just rehab_table as the second argument does url = 'http://stats191.stanford.edu/data/rehab.csv' rehab_table = pandas.read_table(url, delimiter=",") rehab_lm = ols('Time ~ C(Fitness)', data=rehab_table).fit()