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

epi.cpresids

Covariate pattern residuals from a logistic regression model


Description

Returns covariate pattern residuals and delta betas from a logistic regression model.

Usage

epi.cpresids(obs, fit, covpattern)

Arguments

obs

a vector of observed values (i.e. counts of ‘successes’) for each covariate pattern).

fit

a vector defining the predicted (i.e. fitted) probability of success for each covariate pattern.

covpattern

a epi.cp object.

Value

A data frame with 13 elements: cpid the covariate pattern identifier, n the number of subjects in this covariate pattern, obs the observed number of successes, pred the predicted number of successes, raw the raw residuals, sraw the standardised raw residuals, pearson the Pearson residuals, spearson the standardised Pearson residuals, deviance the deviance residuals, leverage leverage, deltabeta the delta-betas, sdeltabeta the standardised delta-betas, and deltachi delta chi statistics.

References

Hosmer DW, Lemeshow S (1989). Applied Logistic Regression. John Wiley & Sons, New York, USA, pp. 137 - 138.

See Also

Examples

infert.glm <- glm(case ~ spontaneous + induced, data = infert, 
   family = binomial())
   
infert.mf <- model.frame(infert.glm)
infert.cp <- epi.cp(infert.mf[-1])

infert.obs <- as.vector(by(infert$case, as.factor(infert.cp$id), 
   FUN = sum))
infert.fit <- as.vector(by(fitted(infert.glm), as.factor(infert.cp$id), 
   FUN = min))
infert.res <- epi.cpresids(obs = infert.obs, fit = infert.fit, 
   covpattern = infert.cp)

epiR

Tools for the Analysis of Epidemiological Data

v2.0.19
GPL (>= 2)
Authors
Mark Stevenson <mark.stevenson1@unimelb.edu.au> and Evan Sergeant <evansergeant@gmail.com> with contributions from Telmo Nunes, Cord Heuer, Jonathon Marshall, Javier Sanchez, Ron Thornton, Jeno Reiczigel, Jim Robison-Cox, Paola Sebastiani, Peter Solymos, Kazuki Yoshida, Geoff Jones, Sarah Pirikahu, Simon Firestone, Ryan Kyle, Johann Popp, Mathew Jay and Charles Reynard.
Initial release
2021-01-12

We don't support your browser anymore

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