HH (version 2.2-17)

lm.case: case statistics for regression analysis

Description

Case statistics for regression analysis. lm.case calculates the statistics. plot.case plots the cases, one statistic per panel, and illustrates and itemizes all observations for which the standard thresholds are exceeded. plot.case returns a "trellis" object containing the plot and also places the row.names of the flagged observations in the variable .lm.case.large. panel.case is a panel function for plot.case.

Usage

lm.case(fit, lms = summary.lm(fit), lmi = lm.influence(fit))

plot.case(x, fit,
          which=c("stu.res","si","h","cook","dffits",
            dimnames(x)[[2]][-(1:8)]),  ##DFBETAS
          between.in=list(y=4, x=9),
          oma=c(0,0,0,4), cex.threshold=if.R(r=1.2, s=1.6),
          main.in=list(
            paste(deparse(fit$call), collapse=""),
            cex=main.cex),
          sigma.in=summary.lm(fit)$sigma,
          p.in=summary.lm(fit)$df[1]-1,
          obs.large=".lm.case.large",
          obs.large.env=if.R(r=globalenv(), s=0),
          main.cex=NULL,
          ...)

panel.case(x, y, subscripts, rownames, group.names,
           nn, pp, ss, cex.threshold,
           par.settings, ## R only. S-Plus ignores this argument
           obs.large, obs.large.env,
           ...)

Arguments

Value

lm.case returns a matrix, with one row for each observation in the original dataset. The columns contain the diagnostic statistics: e (residuals), h* (hat diagonals), si* (deleted standard deviation), sta.res (standardized residuals), stu.res* (Studentized deleted resididuals), dffit (difference in fits, change in predicted y when observation i is deleted), dffits* (standardized difference in fits, standardized change in predicted y when observation i is deleted), cook* (Cook's distance), and DFBETAs* (standardized difference in regression coefficients when observation i is deleted, one for each column of the x-matrix, including the intercept). plot.case returns a "trellis" object containing the plot (including the starred columns by default) and also places the row.names of the flagged observations in the variable .lm.case.large. The variable .lm.case.large is placed by default into frame 0 in S-Plus and into globalenv() in R. panel.case is a panel function for plot.case. The variable .lm.case.large is created one column at a time inside the panel function.

Details

lm.influence is part of S-Plus and R lm.case and plot.case are based on: Section 4.3.3 "Influence of Individual Obervations in Chambers and Hastie", Statistical Models in S.

References

Heiberger, Richard~M. and Holland, Burt (2004b). Statistical Analysis and Data Display: An Intermediate Course with Examples in S-Plus, R, and SAS. Springer Texts in Statistics. Springer. ISBN 0-387-40270-5.

See Also

#ifndef S-Plus lm.influence. #endif #ifdef S-Plus lm.influence. #endif

Examples

Run this code
kidney <- read.table(hh("datasets/kidney.dat"), header=TRUE)

kidney2.lm <- lm(clearance ~ concent + age + weight + concent*age,
                 data=kidney, x=TRUE)  ## the lm object must be computed with x=TRUE

kidney2.case <- lm.case(kidney2.lm)

## this picture looks much better in portrait, specification is device dependent
## trellis.device(postscript, horizontal=TRUE)  ## postscript
## trellis.device(orientation="portrait")       ## S-Plus graphsheet

plot.case(kidney2.case, kidney2.lm, par.strip.text=list(cex=.9),
          layout=c(2,3))

.lm.case.large ## file placed by default into frame 0 in S-Plus
               ## and into globalenv() in R

Run the code above in your browser using DataLab