Extracting observations with a given range of standardized residuals

#1
Hi everyone,

Long time no post. I am new to R. I have 1460 observations with 2 variables. I have fit a slr model to the data. Now, I want to identify the observations with

|standardized residuals| > 3

Can anyone point me in the direction? Thanks
 

Dason

Ambassador to the humans
#2
Here is an example R session that should hopefully help you out

Code:
> #rstandard is a useful function for what you're looking to do.
> rstandard
function (model, ...) 
UseMethod("rstandard")
<bytecode: 0x0000000028985918>
<environment: namespace:stats>
> ?rstandard
starting httpd help server ... done
> head(mtcars) # I'll use the built-in mtcars data for an example
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1
> o <- lm(mpg ~ wt, data = mtcars) # build the simple linear regression
> o

Call:
lm(formula = mpg ~ wt, data = mtcars)

Coefficients:
(Intercept)           wt  
     37.285       -5.344  

> summary(o)

Call:
lm(formula = mpg ~ wt, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-4.5432 -2.3647 -0.1252  1.4096  6.8727 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  37.2851     1.8776  19.858  < 2e-16 ***
wt           -5.3445     0.5591  -9.559 1.29e-10 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.046 on 30 degrees of freedom
Multiple R-squared:  0.7528,    Adjusted R-squared:  0.7446 
F-statistic: 91.38 on 1 and 30 DF,  p-value: 1.294e-10

> rstandard(o)
          Mazda RX4       Mazda RX4 Wag          Datsun 710      Hornet 4 Drive 
        -0.76616765         -0.30743051         -0.70575249          0.43275114 
  Hornet Sportabout             Valiant          Duster 360           Merc 240D 
        -0.06681879         -0.23148309         -1.30552216          1.38889709 
           Merc 230            Merc 280           Merc 280C          Merc 450SE 
         0.78392687          0.10010803         -0.36728706          0.29288651 
         Merc 450SL         Merc 450SLC  Cadillac Fleetwood Lincoln Continental 
        -0.01683789         -0.63159969          0.42296071          0.76979873 
  Chrysler Imperial            Fiat 128         Honda Civic      Toyota Corolla 
         2.17353314          2.33490215          0.61035691          2.21708271 
      Toyota Corona    Dodge Challenger         AMC Javelin          Camaro Z28 
        -0.87964013         -0.99313634         -1.24418015         -1.16279098 
   Pontiac Firebird           Fiat X1-9       Porsche 914-2        Lotus Europa 
         0.82771968          0.12244407          0.05177187          0.42254270 
     Ford Pantera L        Ferrari Dino       Maserati Bora          Volvo 142E 
        -1.51549710         -0.93086929         -1.07151943         -0.34388215 
> rs <- rstandard(o)
> rs[abs(rs) > 3] # get any with standardized residual > 3.  Looks like there aren't any
named numeric(0)
> rs[abs(rs) > 2]  # so let's get the ones > 2 just for an example
Chrysler Imperial          Fiat 128    Toyota Corolla 
         2.173533          2.334902          2.217083