I would like to generate a sample of size 20 from the multinomial distribution with three values such as 1,2 and 3
. For example, the sample can be like this sam=(1,2,2,2,2,3,1,1,1,3,3,3,2,1,2,3,...1)
the following code is working but not getting the expected result
> rmultinom(20,3,c(0.4,0.3,0.3))+1
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
[1,] 1 1 3 2 2 1 1 2 3 2 3 2 1 2 2 3 1 2 2 2
[2,] 2 1 2 1 3 2 4 2 1 2 2 1 1 2 1 2 3 2 3 3
[3,] 3 4 1 3 1 3 1 2 2 2 1 3 4 2 3 1 2 2 1 1
I am not expecting this matrix. Any help is appreciated?