Book Image

Clojure for Data Science

By : Henry Garner
Book Image

Clojure for Data Science

By: Henry Garner

Overview of this book

Table of Contents (18 chapters)
Clojure for Data Science
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

The F-test


As with all of the hypothesis tests we have looked at in this chapter, once we have a statistic and a distribution, we simply need to pick a value of α and see if our data has exceeded the critical value for the test.

Incanter provides an s/f-test function, but this only measures the variance between and within the two groups. To run an F-test on our 20 different groups, we will need to implement our own F-test function. Fortunately, we've already done the hard work in the previous sections by calculating an appropriate F-statistic. We can perform the F-test by looking up the F-statistic in an F-distribution parameterized with the correct degrees of freedom. In the following code, we will write an f-test function, which uses this to perform the test on an arbitrary number of groups:

(defn f-test [groups]
  (let [n (count (apply concat groups))
        m (count groups)
        df1 (- m 1)
        df2 (- n m)
        f-stat (f-stat groups df1 df2)]
    (s/cdf-f f-stat :df1 df1 :df2...