The R Project SVN R

Rev

Rev 61160 | Rev 64657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61160 Rev 61168
Line 6... Line 6...
6
\name{plot.lm}
6
\name{plot.lm}
7
\alias{plot.lm}
7
\alias{plot.lm}
8
\alias{plot.mlm}%which is .NotYetImplemented()
8
\alias{plot.mlm}%which is .NotYetImplemented()
9
\title{Plot Diagnostics for an lm Object}
9
\title{Plot Diagnostics for an lm Object}
10
\usage{
10
\usage{
11
\method{plot}{lm}(x, which = c(1:3,5), %% was which = 1:4
11
\method{plot}{lm}(x, which = c(1:3, 5), %% was which = 1:4
12
     caption = list("Residuals vs Fitted", "Normal Q-Q",
12
     caption = list("Residuals vs Fitted", "Normal Q-Q",
13
       "Scale-Location", "Cook's distance",
13
       "Scale-Location", "Cook's distance",
14
       "Residuals vs Leverage",
14
       "Residuals vs Leverage",
15
       expression("Cook's dist vs Leverage  " * h[ii] / (1 - h[ii]))),
15
       expression("Cook's dist vs Leverage  " * h[ii] / (1 - h[ii]))),
16
     panel = if(add.smooth) panel.smooth else points,
16
     panel = if(add.smooth) panel.smooth else points,
Line 133... Line 133...
133
 
133
 
134
## 4 plots on 1 page;
134
## 4 plots on 1 page;
135
## allow room for printing model formula in outer margin:
135
## allow room for printing model formula in outer margin:
136
par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
136
par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
137
plot(lm.SR)
137
plot(lm.SR)
138
plot(lm.SR, id.n = NULL)               # no id's
138
plot(lm.SR, id.n = NULL)                 # no id's
139
plot(lm.SR, id.n = 5, labels.id = NULL)# 5 id numbers
139
plot(lm.SR, id.n = 5, labels.id = NULL)  # 5 id numbers
140
 
140
 
141
## Was default in R <= 2.1.x:
141
## Was default in R <= 2.1.x:
142
## Cook's distances instead of Residual-Leverage plot
142
## Cook's distances instead of Residual-Leverage plot
143
plot(lm.SR, which = 1:4)
143
plot(lm.SR, which = 1:4)
144
 
144
 
145
## Fit a smooth curve, where applicable:
145
## Fit a smooth curve, where applicable:
146
plot(lm.SR, panel = panel.smooth)
146
plot(lm.SR, panel = panel.smooth)
147
## Gives a smoother curve
147
## Gives a smoother curve
148
plot(lm.SR, panel = function(x,y) panel.smooth(x, y, span = 1))
148
plot(lm.SR, panel = function(x, y) panel.smooth(x, y, span = 1))
149
 
149
 
150
par(mfrow = c(2,1))# same oma as above
150
par(mfrow = c(2,1))  # same oma as above
151
plot(lm.SR, which = 1:2, sub.caption = "Saving Rates, n=50, p=5")
151
plot(lm.SR, which = 1:2, sub.caption = "Saving Rates, n=50, p=5")
152
 
152
 
153
\dontshow{
153
\dontshow{
154
## An example with *long* formula that needs abbreviation:
154
## An example with *long* formula that needs abbreviation:
155
for(i in 1:5) assign(paste("long.var.name", i, sep = "."), runif(10))
155
for(i in 1:5) assign(paste("long.var.name", i, sep = "."), runif(10))