R/sampleMoments.R

### Functions to calculate the sample skewness and kurtosis
### Taken from the package e1071
skewness <- function (x, na.rm = FALSE) {
  if (na.rm)
    x <- x[!is.na(x)]

  sum((x - mean(x))^3)/(length(x)*sd(x)^3)
}

kurtosis <- function (x, na.rm = FALSE) {
  if (na.rm)
    x <- x[!is.na(x)]

  sum((x - mean(x))^4)/(length(x)*var(x)^2) - 3
}

Try the DistributionUtils package in your browser

Any scripts or data that you put into this service are public.

DistributionUtils documentation built on May 2, 2019, 4:46 p.m.