[R] Logistic and Linear Regression Libraries

tdm philb at philbrierley.com
Sat Oct 31 11:52:45 CET 2009


Hi Bill,

Thanks for you comments. You may be right in that my ability to use the
software may be the problem. I was using lm to fit a model with 'target'
values of 0 or 1. I then discovered there was a lrm model as well, so just
replaced lm with lrm and expected it to be fine. Then I found that the lrm
model was predicting values greater than 1 for logistic regression - what am
I doing wrong?

Initially I was just looking at AUC, which are similar for both models,
although different enough for me to be concerned. My data is highly
correlated so I want to use a Hessian based algorithm rather then a
non-hessian based algorithm, which is why I asked the initial question as to
what other logistic regression models existed in R. 
 
Anyway, do you know why the lrm predict give me a values of 3.38?

model_lr <- lm(as.formula(paste(mytarget, " ~ . ")) , data=df_train)
model_lrA <- lrm(as.formula(paste(mytarget, " ~ . ")) , data=df_train)

scores_lr_test <- predict(model_lr, df_test)
scores_lr_train <- predict(model_lr, df_train)

scores_lrA_test <- predict(model_lrA, df_test)
scores_lrA_train <- predict(model_lrA, df_train)

print("scores")
print(scores_lr_train[1])
print("scoresA")
print(scores_lrA_train[1])

print(colAUC(scores_lr_train,trainY))
print(colAUC(scores_lrA_train,trainY))
print(colAUC(scores_lr_test,testY))
print(colAUC(scores_lrA_test,testY))



[1] "scores"
        1 
0.9887154 
[1] "scoresA"
       1 
3.389009 
             [,1]
0 vs. 1 0.9448262
             [,1]
0 vs. 1 0.9487878
             [,1]
0 vs. 1 0.9346953
             [,1]
0 vs. 1 0.9357858
1  of  1[1] ""





Bill.Venables wrote:
> 
> glm is not, and never was. part of the MASS package.  It's in the stats
> package.
> 
> Have you sorted out why there is a "big difference" between the results
> you get using glm and lrm?  
> 
> Are you confident it is due to the algorithms used and not your ability to
> use the software?
> 
> To be helpful, if disappointing, I think the answer to your question is
> "no".  You will need to seek out the algorithms from the published
> information on them individually.
> 
> W.
> ________________________________________
> From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On
> Behalf Of tdm [philb at philbrierley.com]
> Sent: 31 October 2009 16:53
> To: r-help at r-project.org
> Subject: [R]  Logistic and Linear Regression Libraries
> 
> Hi all,
> 
> I'm trying to discover the options available to me for logistic and linear
> regression. I'm doing some tests on a dataset and want to see how
> different
> flavours of the algorithms cope.
> 
> So far for logistic regression I've tried glm(MASS) and lrm (Design) and
> found there is a big difference. Is there a list anywhere detailing the
> options available which details the specific algorithms used?
> 
> Thanks in advance,
> 
> Phil
> 
> 
> 
> --
> View this message in context:
> http://old.nabble.com/Logistic-and-Linear-Regression-Libraries-tp26140248p26140248.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://old.nabble.com/Logistic-and-Linear-Regression-Libraries-tp26140248p26141353.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list