简体   繁体   English

绘制R中差异的分布

[英]Plotting distribution of differences in R

I have a dataset with numbers indicating daily difference in some measure. 我有一个数据集,其中的数字表示某种程度上的每日差异。

https://dl.dropbox.com/u/22681355/diff.csv https://dl.dropbox.com/u/22681355/diff.csv

I would like to create a plot of the distribution of the differences with special emphasis on the rare large changes. 我想创建一个差异分布图,特别强调稀有的大变化。

I tried plotting each column using the hist() function but it doesn't really provide a detailed picture of the data. 我尝试使用hist()函数绘制每列,但实际上并没有提供数据的详细图片。

For example plotting the first column of the dataset produces the following plot: 例如,绘制数据集的第一列将产生以下图:

https://dl.dropbox.com/u/22681355/Rplot.pdf https://dl.dropbox.com/u/22681355/Rplot.pdf

My problem is that this gives very little detail to the infrequent large deviations. 我的问题是,这很少提供很少的大偏差细节。

What is the easiest way to do this? 最简单的方法是什么?

Also any suggestions on how to summarize this data in a table? 还有关于如何在表中汇总此数据的任何建议? For example besides showing the min, max and mean values, would you look at quantiles? 例如,除了显示最小值,最大值和平均值之外,您还会查看分位数吗? Any other ideas? 还有其他想法吗?

You could use boxplots to visualize the distribution of the data: 您可以使用可视化数据的分布:

sdiff <- read.csv("https://dl.dropbox.com/u/22681355/diff.csv")

boxplot(sdiff[,-1])

Outliers are printed as circles. 离群值打印为圆形。

在此处输入图片说明

I back @Sven's suggestion for identifying outliers, but you can get more refinement in your histograms by specifying a denser set of breakpoints than what hist chooses by default. 我回来@斯文的建议识别异常值,但你可以通过指定一个更密集设置断点比什么让你的直方图更细化hist选择默认。

d <- read.csv('https://dl.dropbox.com/u/22681355/diff.csv', header=TRUE, row.names=1)
with(d, hist(a, breaks=seq(min(a), max(a), length.out=100)))

在此处输入图片说明

Violin plots could be useful: 小提琴图可能会有用:

df <- read.csv('https://dl.dropbox.com/u/22681355/diff.csv')
library(vioplot)
with(df,vioplot(a,b,c,d,e,f,g,h,i,j))

小提琴情节

I would use a boxplot on transformed data, eg: 我将在转换后的数据上使用箱线图,例如:

boxplot(df[,-1]/sqrt(abs(df[,-1])))

箱线图(数据转换)

Obviously a histogram would also look better after transformation. 显然,直方图在转换后也会看起来更好。

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

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