[R] Create simulated data's using mvrnorm

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Jul 8 13:28:43 CEST 2011


Not sure if I understand your problem completely.

If so, you could try to run an LDA on the x with y as classlabels 
factor(rep(1:3, each=10)) and see if it can perfectly separate the classes.

Uwe Ligges




On 06.07.2011 17:31, Aparna Sampath wrote:
> Hi All
>
> This might be something very trivial but I seem to miss something in the
> syntax or logic which makes me keep wandering around the problem without
> arriving at a solution.
>
> What I want to do is to simulate a sample data for performing cluster
> analysis. I tried to use
> x1= mvrnorm(10,rep(0.8,3),diag(3))
> x2= mvrnorm(10,rep(0,3),diag(3))
> x3= mvrnorm(10,rep(-0.5,3),diag(3))
>
> x=rbind(x1,x2,x3)
>
> I would like use table() to see if the separation is wide apart such that
> the first 10 rows of x are clustered together. for eg: when I use table()
> and if I get an ouptut like
>
>          1     2      3
> 1      10    0      0
>
> 2      0     10     0
>
> 3      0      0     10
>
>
> Is there any way to get this kind of output?
>
> Thanks a lot! :)
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Create-simulated-data-s-using-mvrnorm-tp3649118p3649118.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list