Skip to contents

Computes weighted sample mean, standard deviation, variance, and skewness. See stats::weighted.mean.

Usage

weighted.sd(x, ...)

weighted.var(x, ...)

weighted.skewness(x, ...)

# S3 method for Histogram
weighted.mean(x)

# S3 method for Histogram
weighted.var(x, sheppard = FALSE)

# S3 method for Histogram
weighted.sd(x, sheppard = FALSE)

# S3 method for Histogram
weighted.skewness(x, ...)

# S3 method for default
weighted.sd(x, w)

# S3 method for default
weighted.var(x, w, biased = FALSE)

# S3 method for default
weighted.skewness(x, w, type = c("b", "g"))

Arguments

x

values whose weighted skewness is to be computed

sheppard

Should Sheppard's correction be applied? (subtract h^2/12 from the variance). Should only be applied when bin widths are all the same

w

numerical vector of weight the same length as x

type

'b' for (N - 1) adjustment to variance and 'g' for method of moments estimator.

Sample Skewness

Sample skewness either computes 'b' or 'g' skewness using the notation from 1.

  • b skewness follows MINITAB and uses the unbiased formula for sd with (N - 1) in the denominator

  • g skewness follows SAS format (and that of the R moments::skewness) and uses the biased formula for sd with N in the denominator

"For small samples from a normal distribution b has smaller mean-squared error than g... for small samples from non-normal distributions... g has a smaller mean-squared error."

References

1 Joanes, D. N., & Gill, C. A. (1998). Comparing Measures of Sample Skewness and Kurtosis. Journal of the Royal Statistical Society. Series D (The Statistician), 47(1), 183–189. http://www.jstor.org/stable/2988433

Examples

x <- Histogram(c(1,1,2,2,3,3,4,3,2,1))
weighted.mean(x)
#> [1] 6.409091
weighted.sd(x)
#> [1] 2.388646
weighted.var(x)
#> [1] 5.705628
weighted.skewness(x)
#> [1] -0.2778416