Displaying 1 result from an estimated 1 matches for "my_logist".
Did you mean:
my_list
2009 Apr 26
1
Stochastic Gradient Ascent for logistic regression
...attach(lbw)
lbw[1:2,]
low age lwt race smoke ptl ht ui ftv bwt
1 0 19 182 2 0 0 0 1 0 2523
2 0 33 155 3 0 0 0 0 3 2551
#-----R implementation of logistic regression : gradient descent ------
sigmoid<-function(z)
{
1/(1 + exp(-1*z))
}
X<-cbind(age,lwt, smoke, ht, ui)
#y<-low
my_logistic<-function(X,y)
{
alpha <- 0.005
n<-5
m<-189
max_iters <- 189 #number of obs
ll<-0
X<-cbind(1,X)
theta <-rep(0,6) # intercept and 5 regerssors
#theta <- c(1.39, -0.034, -0.01, 0.64, 1.89, 0.88) #glm estimates as
starting values
theta_all<-theta
for (i in 1:max_i...