1 | lressp(x, y, slices = 10)
|
x |
|
y |
|
slices |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, y, slices = 10)
{
q <- 5
out <- glm(y ~ x[, 1] + x[, 2] + x[, 3] + x[, 4] + x[, 5],
family = binomial)
ESP <- x %*% out$coef[-1] + out$coef[1]
Y <- y
plot(ESP, Y)
abline(mean(y), 0)
fit <- y
fit <- exp(ESP)/(1 + exp(ESP))
indx <- sort.list(ESP)
lines(ESP[indx], fit[indx])
fit2 <- fit
n <- length(y)
val <- as.integer(n/slices)
for (i in 1:(slices - 1)) {
fit2[((i - 1) * val + 1):(i * val)] <- mean(y[indx[((i -
1) * val + 1):(i * val)]])
}
fit2[((slices - 1) * val + 1):n] <- mean(y[indx[((slices -
1) * val + 1):n]])
lines(ESP[indx], fit2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.