# lm.case

From HH v2.1-12
0th

Percentile

##### case statistics for regression analysis

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.

Keywords
hplot, regression
##### 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 fit "lm" object computed with x=TRUE lms summary.lm(fit) lmi lm.influence(fit) x In plot.case, the matrix output from lm.case containing case diagnostics on each observation in the original dataset. In panel.case, the x variable to be plotted which In plot.case, the names of the columns of x that are to be graphed. between.in between trellis/lattice argument. oma In S-Plus, change par()$oma to make room for the threshold values. A warning is printed when par()\$oma is changed as the delayed printing of trellis objects implies we can't return it to the original value automaticall
cex.threshold
Multiplier for cex for the threshold values.
main.in
main title for xyplot. The default main title displays the linear model formula from fit.
sigma.in
standard error for the fit.
p.in
The number of degrees of freedom associated with the fitted model.
obs.large
Object name where the names of all observations for which the standard thresholds are exceeded will be stored. The default name is .lm.case.large.
obs.large.env
Frame in S-Plus (defaults to 0) and environment in R (defaults to globalenv()) where obs.large will be stored.
main.cex
cex for main title.
...
other arguments to xyplot
y
the y variable to be plotted.
nn
number of rows in original dataset.
pp
The number of degrees of freedom associated with the fitted model.
ss
standard error for the fit.
subscripts
trellis/lattice argument, position in the reshaped dataset constructed by plot.case before calling xyplot.
rownames
row name in the original data.frame.
group.names
names of the individual statistics.
par.settings
Used in R as part of the call to xyplot. Although this argument is not used in the panel function, it is needed as a formal argument in S-Plus to absorb it out of ... and thereby prevent it from being forwarded to
##### 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.

##### 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.

##### 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.

lm.influence in R, lm.influence in S-Plus.

• lm.case
• plot.case
• panel.case
##### Examples
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
Documentation reproduced from package HH, version 2.1-12, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.