predProb: Predicted probabilities and confidence intervals from logit...

Description Usage Arguments Value Author(s) Examples

View source: R/predProb.R

Description

Predicted probabilities and confidence intervals from logit or probit model

Usage

1
predProb(model, predData, ci = TRUE, level = 0.95)

Arguments

model

A glm model fit with binomial family and either a logit or probit link function.

predData

A data frame to pass to predict.glm in which to look for variables with which to predict.

ci

Logical value indicating whether to compute confidence intervals.

level

The confidence level to use if ci is TRUE.

Value

A data frame with predData and the associated predicted probabilities. Confidence intervals are included if argument ci is TRUE.

Author(s)

Jonah Gabry <jsg2201@columbia.edu>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
GSS_2010$Y <- with(GSS_2010,
                   cut(realinc,
                   breaks=c(-Inf, median(realinc, na.rm = T), Inf),
                   labels=c("Low", "High")))
logitmodel <- glm(Y ~ age + educ, data = GSS_2010, family = binomial)
probitmodel <- glm(Y ~ age + educ, data = GSS_2010, family = binomial(link = "probit"))
predData <- data.frame(age = 20, educ = 15)
predProb(logitmodel, predData, ci = F)
predProb(probitmodel, predData, ci= F)
predData <- expand.grid(age = c(20, 50, 80), educ = c(5, 10, 15))
predProb(logitmodel, predData, ci = T)
predProb(probitmodel, predData, ci= T)

jgabry/QMSS_package documentation built on May 19, 2019, 7:18 a.m.