image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import statsmodels.api as sm

df = pd.read_csv('../input/ehresp_2014.csv', usecols=['erbmi', 'euexfreq', 'euwgt', 'euhgt', 'ertpreat'])

df = df[df['erbmi'] > 0]

x = df[['euexfreq', 'euwgt', 'euhgt', 'ertpreat']]
y = df['erbmi']
x = sm.add_constant(x)
model = sm.OLS(y, x).fit()

sns.residplot(model.fittedvalues, df['erbmi'], lowess=True, line_kws={'color': 'r', 'lw': 1})
plt.title('Residual plot')
plt.xlabel('Predicted values')
plt.ylabel('Residuals')