Christoph,
If I may expand on Bert's suggestion...
Try this sequence of uses of rmultinom().
rmultinom(5, 1, c(.1, .2, .7))
rmultinom(5, 10, c(.1, .2, .7))
rmultinom(5, 100, c(.1, .2, .7))
Hopefully the output will help explain how rmultinom() works.
For your application, I assume you would replace the first argument, 5,
with 1000.
For the second argument you probably want 1, based on your rnorm()
example.
For the third argument, you need the probabilities of however many classes
your multinomial has (three classes in the above examples, but I don't
know how many classes you want).
How you get those probabilities from your
y_det= a+b*poly(x,3)
is not obvious.
You said "... class memberships are defined in response to an underlying
variable ...". How are they defined? That should lead you to how to
calculate the class probabilities, I would think.
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 6/29/15, 9:14 AM, "Bert Gunter" <bgunter.4567 at gmail.com>
wrote:
>... and presumably the probabilities for class memberships are given
>by your function of the explanatory variable. So you just plug in your
>(30?) values of x, no?
>
>-- Bert
>
>
>Bert Gunter
>
>"Data is not information. Information is not knowledge. And knowledge
>is certainly not wisdom."
> -- Clifford Stoll
>
>
>On Mon, Jun 29, 2015 at 8:50 AM, Christoph Scherber <cscherb1 at
gwdg.de>
>wrote:
>> 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
>>
>> ______________________________________________
>> R-help at 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.