1.2.3-SNAPSHOT Arrow_down_16x16

simple-regression

incanter.stats

  • (simple-regression y x & options)
A stripped version of linear-model that returns a map containing only
the coefficients.

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/stats.clj:2641 top

(defn simple-regression
"A stripped version of linear-model that returns a map containing only
the coefficients."
 ([y x & options]
   (let [opts (when options (apply assoc {} options))
         intercept? (if (false? (:intercept opts)) false true)
         _x (if intercept? (bind-columns (replicate (nrow x) 1) x) x)
         xtx (mmult (trans _x) _x)
         xtxi (if (number? xtx) (/ 1 xtx) (solve xtx))
         xty (mmult (trans _x) y)
         coefs (if (and (number? xtxi) (number? xty))
                 (* xtxi xty)
                 (to-list (if (or (number? xtxi) (number? xty))
                   (mult xtxi xty)
                   (mmult xtxi xty))))]
     {:coefs coefs})))
Vars in incanter.stats/simple-regression: defn let
Used in 0 other vars

Comments top

No comments for simple-regression. Log in to add a comment.