Label outliers in an scatter plot

10,993

Identify high-leverage points according to your definition:

hlev <- which(hatvalues(tmodel)>0.05)

Add numeric labels to the graph:

text(hatvalues(tmodel)[hlev], residuals(tmodel)[hlev], 
   labels=DSET$NOMBRES[hlev])
Share:
10,993
CreamStat
Author by

CreamStat

Updated on July 08, 2022

Comments

  • CreamStat
    CreamStat almost 2 years

    I've plot this graphic to identify graphically high-leverage points in my linear model. enter image description here

    Given the variable "NOMBRES" of the data set which my model uses, I've tried to plot all the points of my graphic but it gets illegible. Here's the code I ran:

    > plot(hatvalues(tmodel),residuals(tmodel))
    > text(hatvalues(tmodel),residuals(tmodel),labels=DSET$NOMBRES)
    

    So I would like to plot just the points with leverage(hat value) above 0.05 using the label "DSET$NOMBRES".