Returns a sample of the given size of the the parameters (coefficients and
error variance) of the given linear-model. The sample is generated using
Gibbs sampling.
See also:
incanter.stats/linear-model
Examples:
(use '(incanter core datasets stats charts bayes))
(def ols-data (to-matrix (get-dataset :survey)))
(def x (sel ols-data (range 0 2313) (range 1 10)))
(def y (sel ols-data (range 0 2313) 10))
(def lm (linear-model y x :intercept false))
(def param-samp (sample-model-params 5000 lm))
;; view trace plots
(view (trace-plot (:var param-samp )))
(view (trace-plot (sel (:coefs param-samp) :cols 0)))
;; view histograms
(view (histogram (:var param-samp)))
(view (histogram (sel (:coefs param-samp) :cols 0)))
;; calculate statistics
(map mean (trans (:coefs param-samp)))
(map median (trans (:coefs param-samp)))
(map sd (trans (:coefs param-samp)))
;; show the 95% bayesian confidence interval for the firt coefficient
(quantile (sel (:coefs param-samp) :cols 0) :probs [0.025 0.975])
Comments top
No comments for sample-model-params. Log in to add a comment.