Last active
August 29, 2015 14:26
-
-
Save rleonid/a187ecd5d60ef5acf666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let pred = | |
Array.init 100 (fun r -> | |
let a = n1 () in | |
let b = n1 () in | |
let c = a +. b in (* Makes the third column/predictor redundant and our data collinear! *) | |
[|a;b;c|]) ;; | |
val pred : float array array = | |
[|[|2.1000; 0.9001; 3.0001|]; [|1.7343; 2.9934; 4.7277|]; [|2.7644; 4.0290; 6.7935|]; | |
[|0.7972; 2.6754; 3.4726|]; [|0.6089; 2.7250; 3.3340|]; [|0.7870; 2.7721; 3.5592|]; | |
...|] | |
# let resp = | |
Array.map (fun arr -> | |
Float.( 2.0 * arr.(0) + 3.0 * arr.(1) + 4.0 * arr.(2) + n1 ())) pred ;; | |
val resp : float array = | |
[|19.2339; 33.6270; 45.2538; 1.1948; 33.1565; ... |] | |
# open Regressopn ;; | |
# Multivariate.regress None ~pred ~resp | |
|> Multivariate.coefficients ;; | |
- : float array = [|-80174210710646.3594; -80174210710645.5156; 80174210710652.8594|] | |
(* Doesn't seem right *) | |
# Multivariate.regress (Some { add_constant_column = false; lambda_spec = Some (Spec 0.1)}) ~pred ~resp | |
|> Multivariate.coefficients ;; | |
- : float array = [|1.8613; 2.7559; 4.6172|] (* A little better *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regressopn