logistic regression predictions. Zero indexed.

logistic_fits(x, y, w, i, j)

Arguments

x

NumericVector, expanatory variable.

y

NumericVector, 0/1 values to fit.

w

NumericVector, weights (required, positive).

i

integer, first index (inclusive).

j

integer, last index (inclusive).

Value

vector of predictions for interval.

Examples


set.seed(5)
d <- data.frame(x = rnorm(10))
d$y <- d$x + rnorm(nrow(d))>0
weights <- runif(nrow(d))
m <- glm(y~x, data = d, family = binomial, weights = weights)
#> Warning: non-integer #successes in a binomial glm!
d$pred1 <- predict(m, newdata = d, type = "link")
d$pred2 <- logistic_fits(d$x, d$y, weights, 0, nrow(d)-1)
d <- d[order(d$x), , drop = FALSE]
print(d)
#>              x     y      pred1      pred2
#> 3  -1.25549186 FALSE -2.4292992 -2.4292992
#> 1  -0.84085548  TRUE -1.8751975 -1.8751975
#> 8  -0.63537131 FALSE -1.6005976 -1.6005976
#> 6  -0.60290798 FALSE -1.5572150 -1.5572150
#> 7  -0.47216639 FALSE -1.3824977 -1.3824977
#> 9  -0.28577363 FALSE -1.1334107 -1.1334107
#> 4   0.07014277 FALSE -0.6577798 -0.6577798
#> 10  0.13810822 FALSE -0.5669537 -0.5669537
#> 2   1.38435934  TRUE  1.0984811  1.0984811
#> 5   1.71144087  TRUE  1.5355784  1.5355784