Calculate y ~ sigmoid(a + b x) using iteratively re-weighted least squares. Zero indexed.

logistic_solve1(x, y, w, initial_link, i, j, skip)

Arguments

x

NumericVector, expanatory variable.

y

NumericVector, 0/1 values to fit.

w

NumericVector, weights (required, positive).

initial_link,

initial link estimates (required, all zeroes is a good start).

i

integer, first index (inclusive).

j

integer, last index (inclusive).

skip

integer, index to skip (-1 to not skip).

Value

vector of a and b.

Examples


set.seed(5)
d <- data.frame(
  x =  rnorm(10),
  y = sample(c(0,1), 10, replace = TRUE)
)
weights <- runif(nrow(d))
m <- glm(y~x, data = d, family = binomial, weights = weights)
#> Warning: non-integer #successes in a binomial glm!
coef(m)
#> (Intercept)           x 
#>   0.8821778   1.9689368 
logistic_solve1(d$x, d$y, weights, rep(0.0, nrow(d)), 0, nrow(d)-1, -1)
#> [1] 0.8821778 1.9689368