0

I downloaded this and that file. Then, I created histograms showing the daily cost and annual expenses per country. We observe that the histogram of cost21 is more symmetrical than the histogram of food21.

enter image description here

enter image description here

This is further confirmed by the Pearson skewness coefficients I calculated (pearsonII), which yield values of 0.4683039 and 0.5745134, respectively. However, if I use the moments package, I get exactly the opposite results, with values of 0.9714933 and 0.5786727, respectively.

Why is this happening? Which skewness coefficient values should I accept?

This is my code:

cost2021 <- costHealthyDiet[costHealthyDiet$Year == 2021, ]
cost21 <- cost2021$`Cost of a healthy diet`
food2021 <- foodExpenditureYear[foodExpenditureYear$Year == 2021, ]
food21 <- food2021$`Total food expenditure`
hist(cost21)
hist(food21)
pearsonII <- function(v){
  3*(mean(v)-median(v))/sd(v)
}
pearsonII(cost21)
pearsonII(food21)
install.packages("moments")
library(moments)
skewness(cost21)
skewness(food21
Nick Cox
  • 56,404
  • 8
  • 127
  • 185
  • 2
    Different measures of skewness can give different results. This shouldn't be a surprise. The moment-based measure is a little more sensitive to one slight outlier. (mean $-$ median) / SD is bounded by $[-1, 1]$ and multiplying it by 3 has the effect you would guess. Moment-based skewness is bounded but not so sharply. – Nick Cox Jul 30 '23 at 09:59
  • @NickCox , I'm sorry. I fixed it! – Kώστας Κούδας Jul 30 '23 at 10:05
  • I understand that they have a difference in estimating the skewness intensity. However, is it possible for them to provide opposite results? In any case, I comprehend that the coefficient from moments is not as reliable as the other one. – Kώστας Κούδας Jul 30 '23 at 10:09
  • Like Nick Cox, I can't access your files. You can check the package code here to see how they compute the skewness coefficient (lines 8 and 9): https://github.com/cran/moments/blob/master/R/skewness.R – J-J-J Jul 30 '23 at 10:09
  • @J-J-J , I modified the file permissions. I believe they are accessible now. – Kώστας Κούδας Jul 30 '23 at 10:11
  • 3
    It is absolutely possible to get contradictory results. Try 0, 0, 0, 1, 1, 1, 4 where the mean equals the median and so one measure is zero immediately. – Nick Cox Jul 30 '23 at 10:19
  • @NickCox , I understand! Thank you very much! – Kώστας Κούδας Jul 30 '23 at 10:21
  • 3
    Skewness is not really something that you can capture by a single quantity. There are many different measures of skewness - dozens - which measure distinct, albeit usually broadly similar, things. Generally speaking*, any pair of them can sometimes give opposite indications, one positive, the other negative. $:$ * aside from a few pairs of measures that are strictly proportional (or perhaps strictly monotonically related with the same 0-point). Multiple posts on site discuss this issue of different measures disagreeing. – Glen_b Jul 31 '23 at 01:36
  • 1
    My post at https://stats.stackexchange.com/a/96684/919 describes a powerful way to assess skewness, using techniques of Exploratory Data Analysis (developed by John Tukey). They go well beyond using a single number to characterize skewness. – whuber Aug 05 '23 at 15:55
  • 1
    @whuber , very interesting! Thank you very much for the reference! – Kώστας Κούδας Aug 06 '23 at 11:15

0 Answers0