R - multivariate normal distribution in R

你离开我真会死。 提交于 2019-12-08 05:45:58

问题


I would like to simulate a multivariate normal distribution in R. I've seen I need the values of mu and sigma. Unfortunately, I don't know how obtain them.

In the following link you will find my data in a csv file "Input.csv". Thanks https://www.dropbox.com/sh/blnr3jvius8f3eh/AACOhqyzZGiDHAOPmyE__873a?dl=0

Please, could you show me an example? Raúl


回答1:


Your link is broken, but I understand that you want to generate random samples from empirical multivariate normal distribution. You can do it like that, assuming df is your data.frame with data:

library('MASS')
Sigma <- var(df)
Means <- colMeans(df)
simulation <- mvrnorm(n = 1000, Means, Sigma)


来源:https://stackoverflow.com/questions/30931828/r-multivariate-normal-distribution-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!