Today I did an illustration of discrete Bayes for a proportion. I’m interested in the proportion p of graduate students who answer “McDonalds” when asked the question “McDonalds, Wendys, or Burger King?”
I believe p can be one of the five values 0.1, 0.2, 0.3, 0.4, 0.5 and I assign the respective prior weights 1, 2, 5, 10, 5. I define this prior in R:
I collected data from my class. Of the 25 students, 11 responded with “McDonalds”.
I update my probabilities using the function discrete.bayes. You can read in the function and associated plot and print methods by typing in
The updating is done by discrete.bayes. The arguments are the sampling density dbinom, the prior probabilities defined in prior, the number of yes’s (11) and the sample size (25).
I compare the prior and posterior probabilities using two bar graphs.
Note that the posterior probs are more precise than the prior probabilities. I am more confident that the proportion of McDonalds fans is equal to 0.4.