[R] Residual plotting
Simon Blomberg
Simon.Blomberg at anu.edu.au
Thu Jun 26 07:38:00 CEST 2003
> -----Original Message-----
> From: wildscop [mailto:appstat at hotpop.com]
> Sent: Thursday, 26 June 2003 2:11 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Residual plotting
>
[snip]
> Or, in the formal way (using s-plus functions), in the
> following way, but i
> get stuck in the Resisual plot stage, don't know how to draw the
> "Standardized Resisual plot" in this way :
>
> ---------------------
> >x <- c(104.1, 106.6, 105.5, 107.5, 109.6, 113.3, 115.5,
> 117.7, 119.9,
> 122.1, 124.3, 126.5, 128.2)
> >y <- c(53732, 52912, 57005, 61354, 67682, 71602, 71961,
> 75309, 82931,
> 93310, 102161, 103068, 108927)
> > cripop<-rbind(x,y)
> > dimnames(cripop)<-NULL
> > columns <- c("1987", "1988", "1989", "1990", "1991",
> "1992", "1993",
> "1994", "1995", "1996", "1997", "1998", "1999" )
> > rows<-c("Population","Crimes")
> > dimnames(cripop)<-list(rows,columns)
> > bd<-t(cripop)
> > bd.frame<-data.frame(bd)
> > attach(bd.frame)
> > regressions<-lm(Crimes~Population,data=bd.frame)
> > plot(Population,resid(regressions))
> > ...?...
> ---------------------
> Can any one help me by telling me how can i draw
> "Standardized Resisual
> plot" from here ?
try plot(regressions). One of the plots produced is the standardized residuals v quantiles. Another is the sqrt(standardized residuals) v fitted values. If you just want to calculate the standardized residuals yourself, use stdres() in package MASS.
>
> Also, is there any way i can construct 95% Confidence interval or
> Prediction interval for any value in R ?
see ?predict, or more specifically ?predict.lm for linear models.
Cheers,
Simon.
Simon Blomberg, PhD
Depression & Anxiety Consumer Research Unit
Centre for Mental Health Research
Australian National University
http://www.anu.edu.au/cmhr/
Simon.Blomberg at anu.edu.au +61 (2) 6125 3379
More information about the R-help
mailing list