Description Usage Arguments Value Author(s) See Also Examples
Make a goodness of fit plot (observed vs predicted values) in a logistic regression context. Optionally, a table with numerical results (including a chi-squared test) can be produced.
1 2 3 | gfitLogReg(obs, pred, groups, print.table = FALSE, main = "Goodness of fit",
xlab = "Observations", ylab = "Predictions", xlim = c(0, 1), pch = 16,
ps = 2, cex.lab = 1.2, cex.axis = 1.1, las = 1, ...)
|
obs |
numeric vector with observations (either 0 or 1) |
pred |
numeric vector (same length as obs) with fitted model probabilities |
groups |
Number of groups (bins) to divide the data into. If missing, the default is 10. |
print.table |
Logical (default is FALSE). |
... |
other arguments (e.g. xlim, xlab, main, ...) to be passed to |
A goodness of fit plot. Optionally (if print.table=T
), also a table. See plotCalibration
from package PredictABEL
.
Paco, based on function plotCalibration
from package PredictABEL
.
plotCalibration
from package PredictABEL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Generate some data
x <- seq(1:1000)
yhat <- plogis(0.2 + 0.003*x) # inverse logit
y <- rbinom(1000, 1, yhat)
# Fit model and get predicted probabilities
model <- glm(y~x, family="binomial")
ypred <- predict(model, type="response")
# Check goodness of fit
gfitLogReg(y, ypred)
gfitLogReg(y, ypred, print.table=TRUE)
gfitLogReg(y, ypred, xlim=c(0.5,1))
gfitLogReg(y, ypred, groups=5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.