Ploting a skewed normal distribution in R

a 夏天 提交于 2021-01-29 17:57:49

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/26798938/ploting-a-skewed-normal-distribution-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!