我使用的数据粘贴在下面。当我对R:
中的数据应用the basic formula进行偏斜时3*(mean(data) - median(data))/sd(data)
结果为-0.07949198。我在Python中获得了非常相似的结果。因此,中位数大于表示左尾长的平均值。
但是,当我应用fitdistrplus package中的descdist函数时,偏斜度为0.3076471,表明右尾更长。 Scipy函数skew再次返回偏差0.303。
我能相信这个让我产生消极偏斜的简单公式吗?这是怎么回事。
谢谢, 奥利弗
data = c(0.18941565600882029, 1.9861271676300578, -5.2022598870056491, 1.6826411075612353, 1.6826411075612353, -2.9502890173410403, -2.923253150057274, -2.9778296382730454, 0.71202396234488663, 0.71202396234488663, -3.1281373844121529, 1.8326831382748159, -5.2961554710604135, 2.7793190416141234, 0.46922759190417185, 7.0730158730158728, 1.1745152354570636, 2.8142292490118579, 2.037940379403794, 7.0607489597780866, 10.460258249641321, 11.894978479196554, 4.8334682860998655, 1.3884016973125886, 4.0940458015267174, 0.12592959841348539, -0.37022332506203476, 1.9713554987212274, -0.83774145616641893, -1.896978417266187, 6.4340675477239362, -6.4774193548387089, -0.31790393013100438, -4.4193265007320646, 5.7454545454545451, 2.5913432835820895, 0.86190724335591451, 0.95753781950965045, 6.8923556942277697, 1.7650659630606862, -2.4558421851289833, -2.390546528803545, 2.6355029585798815, 0.26983655274888557, 1.5032159264931086, 3.9839506172839503, -5.1404511278195484, -2.2477777777777779, 6.0604444444444443, -0.9691172451489477, 1.1383462670591382, -1.5281319661168078, 4.7775667118950702, 1.2223175965665234, 2.0563555555555553, -3.6153201970443352, -0.35731206188058978, -3.6265094676670238, 1.3053804930332262, -4.4604960677555958, -0.8933514246947083, 0.7622542595019659, 1.3892170651664322, 2.5725258493353031, -0.028006088280060883, 0.8933947772657449, 2.4907086614173228, 3.0914196567862717, 4.4222575516693157, 0.64568527918781726, 0.97095158597662778, -3.7409780775716697, -3.3472636815920396, -0.66307448494453247, -7.0384291725105186, -0.14540612516644474, -0.38161535029004906, 5.1076923076923082, 4.0237516869095806, 1.510099573257468, 1.5064083457526081, -0.025879043600562587, 4.5001414427156998, 3.2326264274061991, 1.0185639229422065, 2.66690518783542, 0.53032015065913374, 1.2117829457364342, 0.60861244019138749, -2.5248049921996878, 1.8666666666666669, -0.32978612415232139, 0.29055999999999998, 1.9150729335494328, 2.2988352745424296, 3.779225265235628, 0.093884800811976657, 1.0097869890616005, 1.2220632081097198, 0.21164401128494487)
答案 0 :(得分:3)
我无法访问您刚才提到的软件包,因此我无法检查它们适用的公式,但是,您似乎正在使用Pearson的第二个偏度系数(请参阅wikipedia)。样本偏度的估计量在同一页面上给出,由第三个时刻给出,可以简单地计算:
> S <- mean((data-mean(data))^3)/sd(data)^3
> S
[1] 0.2984792
> n <- length(data)
> S_alt <- S*n^2/((n-1)*(n-2))
> S_alt
[1] 0.3076471
请参阅维基页面上的替代定义,其结果与您的示例相同。
答案 1 :(得分:2)
偏度通常被定义为第三个中心时刻(至少在被统计学家使用时)。维基百科偏斜页面解释了为什么您找到的定义不可靠。 (我从未见过这个定义。)descdist
中的代码很容易查看:
moment <- function(data, k) {
m1 <- mean(data) # so this is a "central moment"
return(sum((data - m1)^k)/length(data))
}
skewness <- function(data) {
sd <- sqrt(moment(data, 2))
return(moment(data, 3)/sd^3)}
skewness(data)
#[1] 0.3030131
您使用的版本显然被称为“中位偏度”&#39;或者&#39;非参数偏度&#39;请参阅:https://stats.stackexchange.com/questions/159098/taming-of-the-skew-why-are-there-so-many-skew-functions