My intention was to generate samples from two mixed and heavily right-skewed Gamma distributions using the package called bmixture
. Some examples are provided at
How can one possibly incorporate the skewness parameter? Any help is highly appreciated!
CodePudding user response:
You aren't using the parameters properly. alpha
is the shape parameter, where lower values increase the skew (a shape of 1 gives the exponential distribution, and higher numbers tend towards a normal distribution), and beta
is the rate parameter, where higher values lower the mean. (see Characterization using shape α and rate β here.)
The mean of a gamma distribution is alpha/beta
, and the standard deviation is alpha/beta^2
. To get your target mean and standard deviations, you would need shape parameters of c(400, 4083)
and rate parameters of c(20, 58.3)
. These shape parameters would lead to distributions that would be impossible to distinguish from normal distributions at reasonable sample sizes.
To get positively skewed distributions, you need considerably lower shape
parameters:
library(bmixture)
set.seed(345)
nn <- 10000
wt <- c(0.80,0.20)
shape <- c(3, 30)
rate <- shape / c(20, 70)
x <- rmixgamma(n = nn, weight = wt, alpha = shape, beta = rate)
hist(x, breaks = 40, freq = FALSE)
Created on 2022-12-14 with reprex v2.0.2