Calculate y ~ sigmoid(a + b x) using iteratively re-weighted least squares. Zero indexed.
logistic_solve1(x, y, w, initial_link, i, j, skip)
NumericVector, expanatory variable.
NumericVector, 0/1 values to fit.
NumericVector, weights (required, positive).
initial link estimates (required, all zeroes is a good start).
integer, first index (inclusive).
integer, last index (inclusive).
integer, index to skip (-1 to not skip).
vector of a and b.
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