data life

QQ Plot 본문

Data-Analysis/시각화

QQ Plot

주술회전목마 2022. 5. 26. 11:53

QQPlot 해석

https://stats.stackexchange.com/questions/101274/how-to-interpret-a-qq-plot

 

How to interpret a QQ plot

I am working with a small dataset (21 observations) and have the following normal QQ plot in R: Seeing that the plot does not support normality, what could I infer about the underlying distributi...

stats.stackexchange.com

 

핵심은 정규화를 검토하기 위한 그래프이다. 대략적으로 아래와 같이 생겼다.

 

https://en.wikipedia.org/wiki/Q%E2%80%93Q_plot#/media/File:Normal_exponential_qq.svg

위에서 점들 직선을 볼 수 있다.

  • 직선 : 정규분포의 값
  • 점선 : 우리가 가진 실제 데이터 값

분석하는 방법은 다음과 같다.

점선과 직선이 일치할수록, 데이터는 정규분포를 따른다.
위의 그림처럼 점선과 직선이 일치하지 않으면 데이터는 정규분포를 따르지 않는다.

 

 

python을 이용한 qq-plot 그리는 방법

qqplot()

 

statsmodels.graphics.gofplots.qqplot — statsmodels

If fit is false, loc, scale, and distargs are passed to the distribution. If fit is True then the parameters for dist are fit automatically using dist.fit. The quantiles are formed from the standardized data, after subtracting the fitted loc and dividing b

www.statsmodels.org

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

sm.qqplot(raw_data, fit=True, line='45')

line { None, "45", "s", "r", "q"}

  • "45" - 45도 선
  • "s" - 표준화된 선, 예상 주문 통계는 주어진 샘플의 표준 편차에 따라 조정되고 평균이 추가됩니다.
  • "r" - 회귀선이 적합합니다.
  • "q" - 선이 사분위수에 맞습니다.
  • 없음 - 기본적으로 플롯에 참조선이 추가되지 않습니다.