statsmodels.graphics.gofplots.qqplot(data, dist=<scipy.stats._continuous_distns.norm_gen object>, distargs=(), a=0, loc=0, scale=1, fit=False, line=None, ax=None, **plotkwargs)
[source]
Q-Q plot 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 Parameters.)
Parameters: |
|
---|---|
Returns: |
fig – If |
Return type: |
Matplotlib figure instance |
See also
scipy.stats.probplot
>>> 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 # residuals >>> fig = sm.qqplot(res) >>> plt.show()
qqplot of the residuals 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.
Depends on matplotlib. If fit
is True then the parameters are fit using the distribution’s fit() method.
© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3-clause BSD License.
http://www.statsmodels.org/stable/generated/statsmodels.graphics.gofplots.qqplot.html