Skip to main content

Diagnostic Plots for Lineare Regression Models. Similar to plot.lm in R.

Project description

Python Library providing Diagnostic Plots for Lineare Regression Models. (Like plot.lm in R.)

I built this, because I missed the diagnostics plots of R for a university project. There are some substitutions in Python for individual charts, but they are spread over different libraries and sometimes don’t show the exact same. My implementation tries to copycat the R-plots, but I didn’t reimplement the R-code: The charts are just based on available documentation.


Available in PyPi:

  • Using pip: pip install lmdiag
  • Using pipenv: pipenv install lmdiag


The plots need a fitted Linear Regression Model created by statsmodels as input.

Fitted Model from Linearmodels <> should also work, however, that’s not tested very well.


(See also the more extensive Example Notebook)

import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
import lmdiag

%matplotlib inline  # In Jupyter

# Generate sample model
predictor = np.random.normal(size=30, loc=20, scale=3)
response = 5 + 5 * predictor + np.random.normal(size=30)
X = sm.add_constant(predictor)
lm = sm.OLS(response, X).fit()

# Plot chart matrix (and enlarge figure)


  • Draw matrix of all plots:


  • Draw individual plots:





  • Print useful descriptions for interpretations: (for all plots)'<method name>') (for individual plot)



This is my very first public python library. Don’t expect everything to work smoothly. I’m happy to receive useful feedback or pull requests.
‘Programming Language :: Python :: 3.6’,


Packaging and Upload to PyPi

  • pipenv run rstcheck README.rst (check syntax)
  • rm -rf ./dist (delete old builds)
  • python sdist
  • python bdist_wheel
  • twine upload dist/*
  • Then new release on github…

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmdiag-0.3.7.tar.gz (6.8 kB view hashes)

Uploaded source

Built Distribution

lmdiag-0.3.7-py3-none-any.whl (7.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page