Learn R Programming

RcppDynProg (version 0.2.1)

xlogistic_fits: Out of sample logistic predictions (in link space).

Description

1-hold out logistic regression predections. Zero indexed.

Usage

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

Value

vector of predictions for interval.

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).

Examples

Run this code

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)
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)

Run the code above in your browser using DataLab