Database Reference
In-Depth Information
Modeling non-linear relationships
Non-linear models are similar to linear regression models, except that the lines aren't straight.
Well, that's overly simplistic and a little tongue-in-cheek, but it does have a grain of truth.
We're looking to ind a formula that best its the data, but without the restriction that the
formula should be linear. This introduces a lot of complications and makes the problem
signiicantly more dificult. Unlike linear regressions, itting non-linear models typically involves
a lot more guessing, and trial and error. Also, the interpretation of the model is much trickier.
Interpreting a line is straightforward enough, but trying to igure out relationships when one
involves a curve is much more dificult.
Getting ready
We'll need to declare Incanter as a dependency in the Leiningen project.clj ile:
(defproject statim "0.1.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[incanter "1.5.5"]])
We'll also need to require a number of Incanter's namespaces in our script or REPL:
(require
'[incanter.core :as i]
'incanter.io
'[incanter.optimize :as o]
'[incanter.stats :as s]
'[incanter.charts :as c])
(import [java.lang Math])
For data, we'll visit the website of the National Highway Trafic Safety Administration
( http://www-fars.nhtsa.dot.gov/QueryTool/QuerySection/selectyear.
aspx ) . This organization publishes data on all fatal accidents on US roads. For this recipe,
we'll download data for 2010, including the speed limit. You can also download the data ile
I'm working with directly from http://www.ericrochester.com/clj-data-analysis/
data/accident-fatalities.tsv :
(def data-file "data/accident-fatalities.tsv")
 
Search WWH ::




Custom Search