Last active
August 29, 2015 14:06
-
-
Save v0dro/8cfbd46136b26c95bacd to your computer and use it in GitHub Desktop.
Problem in statsample-glm
This file contains 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
require 'statsample' | |
ds = Statsample::CSV.read('/home/sameer/github_repos/statsample/test/fixtures/test_binomial.csv')" | |
lr = Statsample::Regression::Binomial::Logit.new(ds,'y')" | |
require 'statsample-glm' | |
@glm = Statsample::Regression.glm(Statsample::Dataset.new({'a'=>ds.vector('a'), 'b'=> ds.vector('b'), 'c' => ds.vector('c')}), ds.vector('y'), :binomial) | |
@glm.coefficients | |
# => Vector(type:scale, n:3)[0.4033525715642599,1.6683355279170868,-1.1911705910766943]", | |
lr.coeffs | |
# => {"a"=>0.3270424372821127, "b"=>0.8147074802641313, "c"=>-0.4030572793782994} | |
## As you can see, the co-efficients don't match. | |
This file contains 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
# Note : The GLM results from R match those from statsample but do not match those of statsample-glm. Here is my R code. | |
> csv = read.csv("/home/sameer/github_repos/statsample/test/fixtures/test_binomial.csv") | |
> attach(csv) | |
> glm(y ~ +a+b+c, family = binomial) | |
# => Output | |
Call: glm(formula = y ~ +a + b + c, family = binomial) | |
Coefficients: | |
(Intercept) a b c | |
-5.3658 0.3270 0.8147 -0.4031 | |
Degrees of Freedom: 199 Total (i.e. Null); 196 Residual | |
Null Deviance: 277.1 | |
Residual Deviance: 77.73 AIC: 85.73 | |
# Note: The coeffs reported by statsample::regression as same as above while those from statsample-glm are [0.4033525715642599,1.6683355279170868,-1.1911705910766943], which are incorrect. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment