I am doing a hands on exercise of Poissons Regression of Stats with Python in Fresco Play. Problem statement is like: Load the R dataset Insurance from the MASS package. Capture the data as a pandas dataframe. Build a Poisson regression model with a log of an independent variable Holders, and dependent variable Claims. Fit the model with data, and find the sum of the residuals. I am stuck with the last line i.e. Sum of Residuals I used np.sum(model.resid). But answer is not accepted Here is my code import statsmodels.api as sm import statsmodels.formula.api as smf import numpy as np INS_data = sm.datasets.get_rdataset('Insurance','MASS').data model = smf.poisson('Claims ~ np.log(Holders)', INS_data).fit() print(np.sum(model.resid)) Continue reading...