image_output_1.png
from statsmodels.graphics.gofplots import ProbPlot

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import statsmodels.api as sm

df = pd.read_csv('../input/multipleChoiceResponses.csv', encoding='ISO-8859-1')

df = df[['CompensationAmount', 'Age']]

df['CompensationAmount'] = df['CompensationAmount'].str.replace('[^\\w\\s]', '')
df['CompensationAmount'].fillna(0, inplace=True)
df['Age'].fillna(0, inplace=True)
df['CompensationAmount'] = pd.to_numeric(df['CompensationAmount'])
df = df[df['CompensationAmount'] > 0]

y = df['CompensationAmount']
x = df['Age']
x = sm.add_constant(x)
model = sm.GLM(y, x, family=sm.families.Poisson()).fit()

QQ = ProbPlot(model.resid_deviance)
fig = QQ.qqplot(alpha=0.5, markersize=5)