Skip to content
Prev 178385 / 398506 Next

Stochastic Gradient Ascent for logistic regression

Hi Tim,

There are two main problems with your implementation of Stochastic gradient algorithm:

1.  You are only implementing one cycle of the algorithm, i.e. it cycles over each data point only once.  You need to do this several time, until convergence of parameters is obtained.
2.  Stochastic gradient algorithm has very slow convergence.  It can be really slow if the predictors are not scaled properly.  

I am attaching a code that takes care of (1) and (2).  It gives results that are in good agreement with glm() results.  Beware that it is still very slow.  

This seems like your homework assignment.  If so, you should acknowledge that you got help from the R group.  

Ravi.
____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Tim LIU <timothy.sliu10 at gmail.com>
Date: Sunday, April 26, 2009 7:41 am
Subject: [R]  Stochastic Gradient Ascent for logistic regression
To: r-help at r-project.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stochGradLogistReg.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090426/2ef49cb3/attachment-0002.txt>