Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predprob.glm

Predicted Probabilities for GLM Fits


Description

Obtains predicted probabilities from a fitted generalized linear model object.

Usage

## S3 method for class 'glm'
predprob(obj, newdata = NULL, at = NULL, ...)

Arguments

obj

a fitted object of class inheriting from "glm"

newdata

optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used.

at

an optional numeric vector at which the probabilities are evaluated. By default 0:max(y) where y is the original observed response.

...

arguments passed to or from other methods

Details

This method is only defined for glm objects with family=binomial or family=poisson, or negative binomial count models fit with the glm.nb function in library(MASS).

Value

A matrix of predicted probabilities. Each row in the matrix is a vector of probabilities, assigning predicted probabilities over the range of responses actually observed in the data. For instance, for models with family=binomial, the matrix has two columns for the "zero" (or failure) and "one" (success) outcomes, respectively, and trivially, each row in the matrix sums to 1.0. For counts fit with family=poisson or via glm.nb, the matrix has length(0:max(y)) columns. Each observation used in fitting the model generates a row to the returned matrix; alternatively, if newdata is supplied, the returned matrix will have as many rows as in newdata.

Author(s)

See Also

Examples

data(bioChemists)
glm1 <- glm(art ~ .,
            data=bioChemists,
            family=poisson,
            trace=TRUE)  ## poisson GLM
phat <- predprob(glm1)
apply(phat,1,sum)                    ## almost all 1.0

pscl

Political Science Computational Laboratory

v1.5.5
GPL-2
Authors
Simon Jackman, with contributions from Alex Tahk, Achim Zeileis, Christina Maimone, Jim Fearon and Zoe Meers
Initial release
2020-02-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.