1 | llrwtfrp(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 | ##---- 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]
Z <- y
Z[y < 1] <- Z[y < 1] + 0.5
out2 <- lsfit(x, y = log(Z), wt = Z)
WRES <- out2$res
WFIT <- sqrt(Z) * log(Z) - WRES
MWRES <- sqrt(Z) * (log(Z) - x %*% out$coef[-1] - out$coef[1])
MWFIT <- sqrt(Z) * log(Z) - MWRES
par(mfrow = c(2, 2))
plot(WFIT, sqrt(Z) * log(Z))
abline(0, 1)
title("a) Weighted Forward Response Plot")
plot(WFIT, WRES)
title("b) Weighted Residual Plot")
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.