Reputation: 103
I am trying to generate 1000 sets of 130 random numbers which fit with the skewed normal distribution of the numbers below:
-10.4, -9.3, -6.8, -4.8, -5.7, 5.8, -4.5, -3.4, -2, 0.3, -0.4, -4.1, -6.9, -5.9, -2.5, -2, -2.8, -3.2, -4.4, -2, -1.4, 0.9, -1, -4.1, -11.7, 0.1
The mean of these numbers is -3.99, the standard deviation is 3.17, the skew is -0.71 and the kurtosis is 0.22.
To get my 1000 sets of 130 random numbers, I've tried this:
install.packages("sn")
library(sn)
p <- rmsn(n = 130,
xi = rep(-3.99, 1000),
Omega = diag(1000),
alpha = rep(-0.71, 1000),
tau = -0.71)
I get 1000 vectors of 130 random numbers with mean -3.99. However, they don't have skew -0.71, and I have no idea how to set the standard deviation at 3.17 or the kurtosis at 0.22.
Any help would be much appreciated!
Upvotes: 2
Views: 5745
Reputation: 84659
With the function cp2dp
you can convert from the population mean, the population standard deviation and the population skewness to the parameters xi
, omega
and alpha
of the skew-normal distribution.
library(sn)
params <- cp2dp(c(-3.99, 3.17, -0.71), "SN")
sims <- replicate(1000, rsn(130, dp = params))
The SN family only supports skew between -0.99527 and 0.99527. Outside of this range, the ST family is needed, which requires a fourth variable: kurtosis:
library(sn)
params <- cp2dp(c(-3.99, 3.17, -1.71, 2.37), "ST")
sims <- replicate(1000, rst(130, dp = params))
Note the use of rst instead of rsn in this case.
Upvotes: 5