[R] Simulate multinomial data

Christoph Scherber cscherb1 at gwdg.de
Mon Jun 29 17:50:54 CEST 2015


Dear Don,

True, but what I need is a sample  *for a given explanatory variable*, where class memberships are
defined in response to an underlying variable x (and known regression parameters a, b).

Have you had a look at the code and do you see a way to modify it for rmultinom?

Thanks a lot and best wishes
Christoph

##

##
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(.....)







Am 29/06/2015 um 17:36 schrieb MacQueen, Don:
> See the combinat package:
>
> combinat::rmultinomial
>      Generate random samples from multinomial distributions
>
>
> -Don
>


-- 
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



More information about the R-help mailing list