在R中绘制偏态正态分布

时间:2023-02-09 19:33:52

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

考虑到病例数,平均值,标准差,中位数和MAD,我如何在R中绘制偏态正态分布。

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.

一个例子是我有1'196个案例,平均成本是6'389,标准差是5'158,中位数是4'930和MAD 1'366。我们知道收费的案例总是花费一些钱,所以成本必须始终是积极的。

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 found out how to use it for my concrete use case.

我能找到的这个问题的最佳答案来自https://math.stackexchange.com/a/17995/54064,并建议使用sn包。但是我无法找到如何将它用于我的具体用例。

1 个解决方案

#1


1  

I've had some success with fGarch package.

我在fGarch包中取得了一些成功。

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

#1


1  

I've had some success with fGarch package.

我在fGarch包中取得了一些成功。

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