Description Usage Arguments Examples
Gets predictions and confidence intervals on the response scale from a GLM object.
1 2 3 | ## S3 method for class 'glm'
predict_CI(object, newdata = NULL,
ci.level = 0.95, ...)
|
object |
The glm object |
newdata |
A data frame containing the columns necessary to make predictions from your glm object |
ci.level |
Numeric - A value between 0 and 1 that gives the confidence level for the confidence intervals you want created |
... |
Additional parameters to pass to predict |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Generating some fake data
n <- 30
x <- sort(rnorm(n))
link <- .2 - .8*x
p <- 1/(1 + exp(-link))
y <- rbinom(n, 1, p)
dat <- data.frame(x = x, y = y)
# Fit a logistic regression
o <- glm(y ~ x, data = dat, family = binomial)
# Get the predictions and confidence intervals
out <- predict_CI(o)
## Not run:
# Make a plot
plot(x, y)
# true relationship
lines(x, p)
# estimated relationship
lines(x, out$prediction)
# confidence interval
lines(x, out$low.ci, col = "blue", lty = 2)
lines(x, out$up.ci, col = "blue", lty = 2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.