See the combinat package: combinat::rmultinomial Generate random samples from multinomial distributions
-Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/29/15, 8:23 AM, "R-help on behalf of Christoph Scherber" <r-help-boun...@r-project.org on behalf of csche...@gwdg.de> wrote: >Dear all, > >How do I simulate a dataset where the response variable has 30 classes? > >I tried: > > >## >set.seed(0) >x = sort(runif(1000,1,4)) > >a = 1.2 >b = 1.2 >y_det= a+b*poly(x,3) > ># for a normal distribution, I would use: >ynorm = rnorm(1000,y_det) > ># but how would I do it for a multinomial? > >ymult=rmultinom(.....,) > > >## >Many thanks and best wishes, >Christoph > >[using R 3.1.1 on Windows 7 64-Bit] > > > > > >-- >PD Dr. Christoph Scherber >Senior Lecturer >DNPW, Agroecology >University of Goettingen >Grisebachstrasse 6 >37077 Goettingen >Germany >telephone +49 551 39 8807 >facsimile +49 551 39 8806 >www.gwdg.de/~cscherb1 > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.