qqplot of the quantiles of x versus the quantiles/ppf of a distribution.
Can take arguments specifying the parameters for dist or fit them automatically. (See fit under kwargs.)
Parameters: | data : array-like
dist : A scipy.stats or statsmodels distribution
distargs : tuple
loc : float
a : float
scale : float
fit : boolean
line : str {‘45’, ‘s’, ‘r’, q’} or None
ax : Matplotlib AxesSubplot instance, optional
|
---|---|
Returns: | fig : Matplotlib figure instance
|
Notes
Depends on matplotlib. If fit is True then the parameters are fit using the distribution’s fit() method.
Examples
>>> import statsmodels.api as sm
>>> from matplotlib import pyplot as plt
>>> data = sm.datasets.longley.load()
>>> data.exog = sm.add_constant(data.exog)
>>> mod_fit = sm.OLS(data.endog, data.exog).fit()
>>> res = mod_fit.resid
>>> fig = sm.qqplot(res)
>>> plt.show()
qqplot against quantiles of t-distribution with 4 degrees of freedom:
>>> import scipy.stats as stats
>>> fig = sm.qqplot(res, stats.t, distargs=(4,))
>>> plt.show()
qqplot against same as above, but with mean 3 and std 10:
>>> fig = sm.qqplot(res, stats.t, distargs=(4,), loc=3, scale=10)
>>> plt.show()
Automatically determine parameters for t distribution including the loc and scale:
>>> fig = sm.qqplot(res, stats.t, fit=True, line='45')
>>> plt.show()
The following plot displays some options, follow the link to see the code.
(Source code, png, hires.png, pdf)