简体   繁体   English

R中的多元偏态正态

[英]multivariate skew normal in R

I'm trying to generate random numbers with a multivariate skew normal distribution using the rmsn command from the sn package in R. I would like, ideally, to be able to get three columns of numbers with a specified variances and covariances, while having one column strongly skewed. 我正在尝试使用来自R中的sn包的rmsn命令生成具有多元偏斜正态分布的随机数。我希望,理想情况下,能够获得具有指定方差和协方差的三列数字,同时具有一个专栏强烈倾斜。 But I'm struggling to achieve both goals simultaneously. 但我正在努力同时实现这两个目标。

The post at skew normal distribution was related and useful (and the source of some of the code below), but hasn't completely clarified the issue for me. 偏斜正态分布的帖子是相关的和有用的(以及下面的一些代码的来源),但还没有完全澄清我的问题。

I've been trying: 我一直在努力:

a <- c(5, 0, 0) # set shape parameter
s <- diag(3) # create variance-covariance matrix
w <- sqrt(1/(1-((2*(a^2)/(1 + a^2))/pi))) # determine scale parameter to get sd of 1
xi <- w*a/sqrt(1 + a^2)*sqrt(2/pi) # determine location parameter to get mean of 0

apply(rmsn(n=1000, xi=c(xi), Omega=s, alpha=a), 2, sd)
colMeans(rmsn(n=1000, xi=c(xi), Omega=s, alpha=a))

The columns means and SDs are correct for the second and third columns (which have no skew) but not the first (which does). 列意味着SD对于第二列和第三列(没有偏斜)而不是第一列(确实如此)是正确的。 Can anyone clarify where my code above, or my thinking, has gone wrong? 任何人都可以澄清我上面的代码或我的想法出错了吗? I may be misunderstanding how to use rmsn , or the output. 我可能误解了如何使用rmsn或输出。 Any assistance would be appreciated. 任何援助将不胜感激。

The location is not the mean (except when there is no skew). 位置不是平均值(除非没有歪斜)。 From the documentation: 从文档:

Notice that the location vector 'xi' does not represent the mean vector of the distribution (which in fact may not even exist if 'df <= 1'), and similarly 'Omega' is not the covariance matrix of the distribution 请注意,位置向量'xi'不代表分布的平均向量(如果'df <= 1',实际上甚至可能不存在),类似地,'Omega'不是分布协方差矩阵

And you may want to replace Omega=s with Omega=w . 你可能想用Omega=w代替Omega=s And this is supposed to be a variance matrix: there should be no square root. 这应该是一个方差矩阵:应该没有平方根。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM