第 5 章 QQ图

5.1 绘制QQ图

5.1.1 R包绘制

  • 基础包qqnorm和qqline函数
  • R包car

5.1.2 手工绘制

  • 基础工具plot绘制
par(mfrow=c(1,2))
plot(seq(-3,3,0.01), dnorm(seq(-3,3,0.01)), 
     xlab = 'x', ylab = 'f(x)',
     ylim = c(0,0.5),
     xaxs = 'i', yaxs = 'i', type = 'l')

plot(qnorm(seq(0,1,0.001)), seq(0,1,0.001), 
     xlab = 'x', ylab = 'F(x)',
     xaxs = 'i', yaxs = 'i', type = 'l')

x = seq(-3,3,0.01)
par(mfrow=c(1,1))
plot(x,x, main = 'Q-Q figure',
     xlim = c(-3,3), ylim = c(-3,3), 
     xlab = 'Theoretical quantile', ylab = 'Sample quantile',
     xaxs = 'i', yaxs = 'i',
     type = 'l')

n = 200
x = seq(-3,3,0.01)
par(mfrow=c(1,1))
plot(x,x, 
     xlim = c(-3,3), ylim = c(-3,3), 
     xaxs = 'i', yaxs = 'i',
     yaxt = 'n',
     ann = F, type = 'l')
axis(2, las = 1)
title(main = paste0('Normal n = ',n), 
      xlab= 'Normal quantile', ylab = 'EL quantile', 
      line = 2)

5.1.3 函数绘制正态qq图

  1. 基础包函数qqnorm和qqline,横坐标是标准正态分布的分位数,纵坐标是输入数据的分位数,也就是检验数据是否符合正态分布
qqnorm(qn$nk)
qqline(qn$nk, col=2)  

  1. R包car来绘制
library(car)
qqPlot(qn$nk)

## [1]  1 15

5.2 参考资料

  1. 网站:简书。QQ图的理解和绘制
  2. 网站:CNSD。qq图
  3. Lane, D.M. eBook。Introduction to Statistics