Hi:

       I think I found an error in plot.lm with the option which=5, of course I can be wrong , as usually happen,  but I had work on it for a while and show it to some other people that work with R, and so far I don't see what I can be interpreting wrong. I also worked over the plot.lm's code and change some lines to get what I call "the right plot",  if any body is interested I can send the modified code to see what is the problem I think I found and what could be a solution.

 

I´m working with R 2.4.0 on windows XP, and here is a reproducible example, (this example is just to show the problems in the plot and it doesn't make any sense the way I analyzed).

 

set.seed(3)

datos <-data.frame(fac.A=rep(c("bla","Ur2","pel","arb"),each=3),

                       y= c(rnorm(3,sd=0.5),rnorm(9,sd=2)))

model1 <- lm(y~fac.A,data=datos)

plot(model1,which=5)   # plot1 

 

# this plot1 show that level "arb" has less dispersion than the other levels, 

# But if  I do the plot by myself, look:

 

hii <- lm.influence(model1, do.coef = FALSE)$hat

s1 <- sqrt(deviance(model1)/df.residual(model1))

rs <- residuals(model1)/(s1 * sqrt(1 - hii))

 

plot(rs~datos$fac.A)   # plot2

 

# this plot2 show me that level "bla"  is less variable.

# also per and Url have some problems but this give you the idea of what I think Is wrong.

 

What I have found in the code, is that for this option (which=5),  the labels of the x axis are ordered in a way that the predicted value for the levels are increasing, but when it actually do the plot it doesn't keep that order.

 

Thanks for your time (and sorry for my English) .

                                     Gabriela

	[[alternative HTML version deleted]]

