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 https://stats.stackexchange.com/questions/226834/sampling-from-a-mixture-of-two-gamma-distributions. For example, I can use the following, although the distributions are not really skewed (instead they seems normal).
library(bmixture)
set.seed(345)
nn <- 10000
wt <- c(0.85,0.20) #weight2
mu <- c(20,70)
sd <- c(1,1.2)
x <- rmixgamma(n=nn,weight=wt,alpha=mu,beta=sd)
hist(x, breaks = 40, freq=FALSE)
Output:
How can one possibly incorporate the skewness parameter? Any help is highly appreciated!
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), andbeta
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 issqrt(alpha/beta^2)
. To get your target mean and standard deviations, you would need shape parameters ofc(400, 3402)
and rate parameters ofc(20, 48.61)
. 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:Created on 2022-12-14 with reprex v2.0.2