【问题标题】:Identify points in QQ plot of ggplot2?识别ggplot2的QQ图中的点?
【发布时间】:2014-12-27 22:48:18
【问题描述】:

我正在处理残差向量,试图验证正态分布是否是误差项的适当假设。

stres<-c(-1.8901289914,0.4204280426,-0.0145373478,-0.9589928480,0.2979275041,-0.0739727698,-0.2855008329, 0.7230079969, -0.2914220542, -1.4806560234,  0.1745061707, -1.0128947866, 0.2164536856, -1.1546273403, -0.1542422829,  0.4053103868, -0.5823112019,  0.4563220212, -0.2041307378, -0.6045740758, -0.3423926064,  0.5056780975, -0.3331478887, -0.7572435490,-0.2779393059, -0.6849294132,  0.1311372820, -0.3030318977,  1.2808663783,  0.1563968894,0.6010948547, -0.3774192022,  1.0438147373,  1.6050759999, -0.9890854956, -0.1287947910, 0.7271980085, -0.9227865867,  0.4821372580,  0.3399080091, -0.2351548189,  0.6355239393, 2.1741928350, -0.2974405677, -1.0528047470, -0.2669435284,  5.0818621788, -0.0088001872, 0.3437940065, -0.4497556191,  0.3016467357, -0.5614212196, -0.8108463584,  0.8338203257, -0.0004854171,  0.8685702440, -1.4909115265, -1.0530867343,  0.9150175493,  1.0730349160, 0.8118376993,  0.1817804928, -1.9965218063,  0.2532144991, -1.1466778177, -0.0578508361, 0.3446155055, -0.5806560664, -0.1169654345, -0.5275995111, -1.0649636054, -0.3887896268, -0.4160932861, -0.0934359868,  0.3515817484, -1.5149224114,  0.5314789991, -0.2125920264, -0.7261382754, -0.2765816110,  1.5836098693, -0.5722100502, -1.7568426345, -0.5378891714, -0.1135252088, -0.2024199659, -0.8113893763,  0.1124588319, -0.4545775998,  0.6401511326, 0.4593905713,  0.6382493988,  1.3572090694, -1.2216154767,  0.0863635754, -0.1183901577, -0.4117695427,  1.3132905003, -0.1426298933, -0.6680755381,  1.1076746801,  0.6213041292, -0.8735205521,  0.9021532905, -0.1517989978,  1.0997109361,  0.0038767275, 0.0967747416, 0.5100796248, -0.2174347692, -1.7604201415,  4.2759584670,  0.3281834312)
qplot(sample=stres)+labs(title="QQ Plot/Studentized Residuals")+theme_bw()

如您所见,大多数残差都落在这条线上或附近。右上角的那两个例外。我想识别它们,以便能够更好地研究这些特定的观察结果。你能告诉我我该怎么做吗?

谢谢。

【问题讨论】:

  • 使用library(car)qqPlot应该更容易。或者,如果您与ggplot2 结婚,您可能会发现这很有用stackoverflow.com/questions/10526005/…
  • stackoverflow.com/questions/4357031/… 看看这里。我将数字添加到置信区间之外的那些观察结果
  • @RStudent 这会产生值。有什么方法可以识别 qqplot 上的观察结果?
  • 你看过我的解决方案了吗...有什么问题?

标签: r ggplot2 statistics


【解决方案1】:
> order(stres, decreasing = TRUE)[1:2]
[1]  47 112

> stres[order(stres, decreasing = TRUE)[1:2]]
[1] 5.081862 4.275958

如果您想访问 qplot 使用的值,您可以执行以下操作:

plt <- print(qplot(sample=stres)+labs(title="QQ Plot/Studentized Residuals")+theme_bw())
plt[["data"]][[1]]

你得到同样的结果:

> sort(plt[["data"]][[1]]$sample, decreasing = TRUE)[1:2]
[1] 5.081862 4.275958

【讨论】:

    猜你喜欢
    • 2019-02-04
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    • 1970-01-01
    • 2021-08-08
    • 2016-03-28
    • 2016-03-22
    • 2022-01-04
    相关资源
    最近更新 更多