简体   繁体   English

使用“statsmodels”的正常 QQ 图中的置信区间

[英]Confidence interval in normal Q-Q plot using `statsmodels`

I would like to do draw 95% confidence interval in python using statsmodels , but qqplot() doesn't have this option.我想使用statsmodelspython中绘制 95% 的置信区间,但是qqplot()没有这个选项。

If it's not possible, math equation is also acceptable so that I can simply add it to the plot on my own.如果不可能,数学方程式也是可以接受的,这样我就可以自己简单地将它添加到绘图中。

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

data = np.random.normal(5, 10, 100)
fig = sm.ProbPlot(data, fit=True).qqplot()
plt.show()

There is an implementation in R that I found on the internet, but I am not familiar with R ...我在网上找到了R中的一个实现,但我不熟悉R ...

在此处输入图像描述

Thepingouin package has a function to create a qqplot with confidence interval lines. pingouin包具有创建带有置信区间线的 qqplot 的功能。 This would do the trick:这可以解决问题:

import numpy as np
import pingouin as pg

data = np.random.normal(5, 10, 100)
ax = pg.qqplot(data, dist='norm', confidence=.95)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM