简体   繁体   中英

Ploting a skewed normal distribution in R

How can I plot a skewed normal distribution in R, given the number of cases, the mean, standard deviation, median and the MAD .

A example would be that I have 1'196 cases, were the mean cost is 6'389, the standard deviation 5'158, the median 4'930 and the MAD 1'366. And we know that the billed case always cost something, so the cost must always be positive.

The best answer to this problem I could find is from https://math.stackexchange.com/a/17995/54064 and recommends the usage of the sn package. However I could not figure out how to use it for my concrete use case.

I've had some success with fGarch package.

require("fGarch")
hist(rsnorm(1000, mean = 0, sd = 1, xi = 15))

mmm <- replicate(300, {
  x <- rsnorm(1196, mean = 6389, sd = 5158, xi = 15)
  c(mean = mean(x), sd = sd(x))
})

> mean(mmm[1, ])
[1] 6404.312
> mean(mmm[2, ])
[1] 5169.572

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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