R has more than one way to create logistic regressions to predict binary outcomes. Here's the code that I'm using that is giving strange answers.
library(ElemStatLearn) data(SAheart) set.seed(8484) train <- sample(1:dim(SAheart),size=dim(SAheart)/2,replace=F) trainSA <- SAheart[train,] testSA <- SAheart[-train,]
Now, I can use two different packages to generate the logistic regression. Here's the first.
modFit4 <- glm(chd ~ age + alcohol + obesity + tobacco + typea + ldl, family = "binomial", data = trainSA)
and here's the second.
modFit4.1 <- train( form = as.factor(chd) ~ age + alcohol + obesity + tobacco + typea + ldl, method = "glm", data = trainSA )
When I run a "predict" function on each I find that the first gives many different numerical values. These range from -3.44 to +2.88. The second gives only 0 and 1 values (which, assuming I understand correctly, is the best sort of output for a binomial classification).
1.a.) Why are they different? 1.b.) Are there default parameters that are different in one than in the other? 2.) Is there a generally preferred package for use in real-world regression applications?