1 | llrplot(x, y)
|
x |
|
y |
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 30 31 32 33 34 | ##---- 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)
{
q <- 5
out <- glm(y ~ x[, 1] + x[, 2] + x[, 3] + x[, 4] + x[, 5],
family = poisson)
ESP <- x %*% out$coef[-1] + out$coef[1]
Y <- y
par(mfrow = c(2, 2))
plot(ESP, Y)
abline(mean(y), 0)
Ehat <- exp(ESP)
indx <- sort.list(ESP)
lines(ESP[indx], Ehat[indx])
lines(lowess(ESP, y), type = "s")
title("a) ESSP")
Vhat <- (y - Ehat)^2
plot(Ehat, Vhat)
abline(0, 1)
title("b)")
Z <- y
Z[y < 1] <- Z[y < 1] + 0.5
MWRES <- sqrt(Z) * (log(Z) - x %*% out$coef[-1] - out$coef[1])
MWFIT <- sqrt(Z) * log(Z) - MWRES
plot(MWFIT, sqrt(Z) * log(Z))
abline(0, 1)
title("c) WFRP Based on MLE")
plot(MWFIT, MWRES)
title("d) WRP Based on MLE")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.