1-hold out logistic regression predections. Zero indexed.

xlogistic_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 <- xlogistic_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.167502e+00 #> 1 -0.84085548 TRUE -1.8751975 -1.511600e+308 #> 8 -0.63537131 FALSE -1.6005976 -1.581696e+00 #> 6 -0.60290798 FALSE -1.5572150 -1.394288e+00 #> 7 -0.47216639 FALSE -1.3824977 -1.150064e+00 #> 9 -0.28577363 FALSE -1.1334107 -8.816750e-01 #> 4 0.07014277 FALSE -0.6577798 -4.424278e-01 #> 10 0.13810822 FALSE -0.5669537 -2.757255e-01 #> 2 1.38435934 TRUE 1.0984811 8.595039e-01 #> 5 1.71144087 TRUE 1.5355784 -7.673982e-01