How do I evaluate Multinomial probabilities of pooled trial frequencies of locations of peaks which can occur in one of K positions in each trial?
Suppose we have K positions for a set of N trials and nk of these trials have peaks occurring in position k then the probability of the distribution of peaks follows a multinomial distribution with MN(N,n1,...,nK,p1,...,pK) with sum of k frequencies summed over K equal to N. The probability of a peak occurring by chance in position k = pk = 1/K.
The multinomial probabilities can be evaluated using the dmultinom procedure in R as in this example taken from David Howell's page here and reproduced below.
# We really need the multinomial when we have more than two possible outcomes. # Suppose p <- c(.333, .5, .167) # I want prob of getting x = c(4,5,1) in the 3 boxes x <- c(4,5,1) prob <- c(.333, .5, .167) dmultinom(x=x,prob=prob) #0.08085632
A p-value could, in addition, be obtained for a specific set of frequencies by summing up the multinomial probabilities of all sets of frequencies with an equal or lower chance of occurring than the observed set of frequencies with pk = 1/K for all k.
For example if we observed a frequency of 2 in position 1, 1 in position 2 and 0 in position 3 when K=3 there are ten possible combinations of frequencies which sum to 3. These are 3 0 0, 0 3 0, 0 0 3, 2 1 0 (the combination observed), 2 0 1, 1 2 0, 1 0 2, 0 1 2, 0 2 1 and 1 1 1. Of these all but 1 1 1 have an equal or smaller multinomial probability of occurring so P( 2 1 0) = 1 - P(1 1 1) = 1 - (1/3^3 x 3!/1! 1! 1!) = 0.78.