[R] Testing for normality of residuals in a regression model
jfox at mcmaster.ca
Fri Oct 15 19:48:49 CEST 2004
I don't believe that these are BLUS residuals, but since the last n - r
"effects" are projections onto an orthogonal basis for the residual
subspace, they should do just fine (as long as the basis vectors have the
same length, which I think is the case, but perhaps someone can confirm).
The general idea is to transform the LS residuals into an uncorrelated,
Department of Sociology
Canada L8S 4M4
> -----Original Message-----
> From: Kjetil Brinchmann Halvorsen [mailto:kjetil at acelerate.com]
> Sent: Friday, October 15, 2004 9:12 AM
> To: John Fox
> Cc: 'Federico Gherardini'; R-help at stat.math.ethz.ch
> Subject: Re: [R] Testing for normality of residuals in a
> regression model
> John Fox wrote:
> >Dear Federico,
> >A problem with applying a standard test of normality to LS
> residuals is
> >that the residuals are correlated and heterskedastic even if the
> >standard assumptions of the model hold. In a large sample, this is
> >unlikely to be problematic (unless there's an unusual data
> >configuration), but in a small sample the effect could be nontrivial.
> >One approach is to use BLUS residuals, which transform the
> LS residuals
> >to a smaller set of uncorrelated, homoskedastic residuals
> (assuming the
> >correctness of the model).
> I'm not sure if this are BLUE residuals, but the following
> function transform to a smaller set of independent,
> homoscedastic residuals and the calls
> I've proposed to make this a method for shapiro.test for "lm"
> objects, but it is not accepted.
> function (obj)
> eff <- effects(obj)
> rank <- obj$rank
> df.r <- obj$df.residual
> if (df.r < 3)
> stop("To few degrees of freedom for residual for the test.")
> data.name <- deparse(substitute(obj))
> x <- eff[-(1:rank)]
> res <- shapiro.test(x)
> res$data.name <- data.name
> res$method <- paste(res$method, " for residuals of linear model")
> > A search of R resources didn't turn up anything for BLUS, but they
> >shouldn't be hard to compute. This is a standard topic
> covered in many
> >econometrics texts.
> >You might consider the alternative of generating a bootstrapped
> >confidence envelope for the QQ plot; the qq.plot() function
> in the car
> >package will do this for a linear model.
> >I hope this helps,
> > John
> >John Fox
> >Department of Sociology
> >McMaster University
> >Hamilton, Ontario
> >Canada L8S 4M4
> >>-----Original Message-----
> >>From: r-help-bounces at stat.math.ethz.ch
> >>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Federico
> >>Sent: Friday, October 15, 2004 7:44 AM
> >>To: R-help at stat.math.ethz.ch
> >>Subject: [R] Testing for normality of residuals in a
> regression model
> >>Hi all,
> >>Is it possible to have a test value for assessing the normality of
> >>residuals from a linear regression model, instead of simply
> relying on
> >>I've tried to use fitdistr to try and fit the residuals
> with a normal
> >>distribution, but fitdsitr only returns the parameters of the
> >>distribution and the standard errors, not the p-value. Am I missing
> >>R-help at stat.math.ethz.ch mailing list
> >>PLEASE do read the posting guide!
> >R-help at stat.math.ethz.ch mailing list
> >PLEASE do read the posting guide!
> Kjetil Halvorsen.
> Peace is the most effective weapon of mass construction.
> -- Mahdi Elmandjra
More information about the R-help