Skip to content

Instantly share code, notes, and snippets.

@liebke
Created June 3, 2009 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liebke/122720 to your computer and use it in GitHub Desktop.
Save liebke/122720 to your computer and use it in GitHub Desktop.
;; compare the means of different treatments in the plant-growth data set
(use '(incanter core stats charts datasets))
;; load the plant-growth data
(def plant-growth (to-matrix (get-dataset :plant-growth)))
;; create box-plots of the three treatment groups
(view (box-plot (sel plant-growth :cols 0)
:group-by (sel plant-growth :cols 1)))
(def groups (group-by plant-growth 1 :cols 0))
(map mean groups) ;; returns (5.032 4.661 5.526)
;; run three different t-tests comparing the treatments
(def t-tests [(t-test (second groups) :y (first groups))
(t-test (last groups) :y (first groups))
(t-test (second groups) :y (last groups))])
;; view the p-values of the three-tests
(map :p-value t-tests) ;; returns (0.250 0.048 0.009)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment