Displaying 1 result from an estimated 1 matches for "regerssor".
Did you mean:
regerssors
2009 Apr 26
1
Stochastic Gradient Ascent for 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_iters)
{
dim(X)
length(theta)
hx <- sigmoid(X %*% theta) # matrix
product
ix<-i
for (j in 1:6)
{
theta[j] <- theta[j] + alpha * ((y-hx)[ix]) * X[ix,j]
#stocha...