[R] studentized deleted residuals and NA's

About this list Date view Thread view Subject view Author view Attachment view

From: John Miyamoto (jmiyamot@u.washington.edu)
Date: Tue 06 Apr 2004 - 05:24:50 EST


Message-id: <Pine.A41.4.58.0404051219110.1052698@mead11.u.washington.edu>

Dear R-Help,
   I am using the studres function from the MASS package to compute
studentized deleted residuals in a oneway anova. I'm having trouble
interpreting the results in situations where a factor level has only one
observation. Sometimes studres yields an NaN and sometimes it produces a
numeric value for cases where a factor level has only one observation. I
would think it should always produce NaN for this case. The following
example illustrates this point.

library(MASS)
Data <- c(3,6,3,4,1,5,6,2)
Group <- factor(c(1,1,2,3,3,4,5,5))
lm.out <- lm(Data ~ Group)

data.frame(Data, Group,
        hat=lm.influence(lm.out)$hat,
        std.res=stdres(lm.out),
        stu.del.res=studres(lm.out))

OUTPUT:
  Data Group hat std.res stu.del.res
1 3 1 0.5 -8.9113279e-01 -8.4852814e-01
2 6 1 0.5 8.9113279e-01 8.4852814e-01
3 3 2 1.0 Inf NaN
4 4 3 0.5 8.9113279e-01 8.4852814e-01
5 1 3 0.5 -8.9113279e-01 -8.4852814e-01
6 5 4 1.0 -1.5208938e-08 -1.2418046e-08
7 6 5 0.5 1.1881771e+00 1.3333333e+00
8 2 5 0.5 -1.1881771e+00 -1.3333333e+00
Warning messages:
1: NaNs produced in: sqrt((n - p - sr^2)/(n - p - 1))
2: NaNs produced in: sqrt((n - p - sr^2)/(n - p - 1))

Groups 2 and 4 both have only one observation. Both the standardized
residual (std.res) and studentized deleted residual (stu.del.res) are NaN
for Group = 2 but both have a value for Group = 4. I would think that
std.res and stu.del.res should be NaN for Group 2 and for Group 4 because
1 - h_ii = 0 for the corresponding cases. Can someone tell me why the
std.res and stu.del.res are different for Group = 2 and Group = 4?
   I am running R 1.8.1 on a Windows XP machine.

John

--------------------------------------------------------------------
John Miyamoto, Dept. of Psychology, Box 351525
University of Washington, Seattle, WA 98195-1525
Phone 206-543-0805, Fax 206-685-3157, Email jmiyamot@u.washington.edu
Homepage http://faculty.washington.edu/jmiyamot/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 03 May 2004 - 18:41:18 EST