1.2.3-SNAPSHOT permalink Arrow_down_16x16

sample-multinomial-params

incanter.bayes

  • (sample-multinomial-params size counts)
Returns a sample of multinomial proportion parameters.
The counts are assumed to have a multinomial distribution.
A uniform prior distribution is assigned to the multinomial vector
theta, then the posterior distribution of theta is
proportional to a dirichlet distribution with parameters
(plus counts 1).


Examples:
(use '(incanter core stats bayes charts))

(def samp-props (sample-multinomial-params 1000 [727 583 137]))

;; view means, 95% CI, and histograms of the proportion parameters
(mean (sel samp-props :cols 0))
(quantile (sel samp-props :cols 0) :probs [0.0275 0.975])
(view (histogram (sel samp-props :cols 0)))
(mean (sel samp-props :cols 1))
(quantile (sel samp-props :cols 1) :probs [0.0275 0.975])
(view (histogram (sel samp-props :cols 1)))
(mean (sel samp-props :cols 2))
(quantile (sel samp-props :cols 2) :probs [0.0275 0.975])
(view (histogram (sel samp-props :cols 2)))

;; view a histogram of the difference in proportions between the first
;; two candidates
(view (histogram (minus (sel samp-props :cols 0) (sel samp-props :cols 1))))



0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/bayes.clj:99 top

(defn sample-multinomial-params
" Returns a sample of multinomial proportion parameters.
  The counts are assumed to have a multinomial distribution.
  A uniform prior distribution is assigned to the multinomial vector
  theta, then the posterior distribution of theta is
  proportional to a dirichlet distribution with parameters
  (plus counts 1).


  Examples:
    (use '(incanter core stats bayes charts))

    (def  samp-props (sample-multinomial-params 1000 [727 583 137]))

    ;; view means, 95% CI, and histograms of the proportion parameters
    (mean (sel samp-props :cols 0))
    (quantile (sel samp-props :cols 0) :probs [0.0275 0.975])
    (view (histogram (sel samp-props :cols 0)))
    (mean (sel samp-props :cols 1))
    (quantile (sel samp-props :cols 1) :probs [0.0275 0.975])
    (view (histogram (sel samp-props :cols 1)))
    (mean (sel samp-props :cols 2))
    (quantile (sel samp-props :cols 2) :probs [0.0275 0.975])
    (view (histogram (sel samp-props :cols 2)))

    ;; view  a histogram of the difference in proportions between the first
    ;; two candidates
    (view (histogram (minus (sel samp-props :cols 0) (sel samp-props :cols 1))))



"
([^Integer size counts]
    (sample-dirichlet size (plus counts 1))))
Vars in incanter.bayes/sample-multinomial-params: defn
Used in 0 other vars

Comments top

No comments for sample-multinomial-params. Log in to add a comment.