如何在QQplot中识别数据点 [英] How to identify a datapoint in a QQplot

查看:55
本文介绍了如何在QQplot中识别数据点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在分析残差的QQ图,以评估它们是否可以假定为正态分布,并且我有一些数据点看起来与理论直线相去甚远.我的问题是:有什么方法可以要求R识别那些特定点,以便我可以学习并尝试更好地理解它们?谢谢!

I´m analyzing a residual´s QQplot to assess if they can be assumed to be normally distributed, and I have some datapoints that appear far away from the theoretical straight line. My question is: is there any way I can ask R to identify those specific points, so I can study and try to understand them better? THANKS!

推荐答案

这里有一些神奇可以用来处理情节.首先生成一个QQ情节:

Here is something magical you can do with plots. First generate a QQ plot:

> set.seed(1234)
> x <- rexp(100,100)
> qqpoints <- qqnorm(x)

现在使用 identify ,它将帮助您找出边缘上的点.键入以下行,然后按Enter键:

Now use identify which will help you call out the points on the edges. Type this line and press the enter key:

> identify(qqpoints)

转到图,然后单击离群值之一.然后点击ESCAPE.对您要标注的每个点重复几次.

Go to the plot, and click on one of the outliers. Then hit ESCAPE. Do it a few times for each point you want to call out.

> identify(qqpoints)
[1] 37
> identify(qqpoints)
[1] 60
> identify(qqpoints)
[1] 27
> identify(qqpoints)
[1] 75

弹出的每个数字都是您想进一步了解的点的索引.您可以像这样获取它们的单个坐标:

Each of the numbers that pops out is the index of the point you want to know more about. You can get individual coordinates of them like this:

> qqpoints$x[37]
[1] 2.575829
> qqpoints$y[37]
[1] 0.04324563

分布中点的实际值是这样的:

And the actual value of the point in the distribution like this:

> x[37]
[1] 0.04324563

标签将出现在绘图上

如果您不知道哪些是离群值,则需要首先弄清楚,请使用 car 包中的 qqPlot 然后以图形方式识别超出置信度限制的点:

If you don't know which ones are outliers and you need to figure that out first, use qqPlot from the car package then identify the points that fall outside the confidence limits graphically:

> library(car)
> qqPlot(x)

这篇关于如何在QQplot中识别数据点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆