Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotplot_diag for cooks distance (lmer model) - subject value instead of index

I'm using the tools in the HLMdiag package to look at diagnostics for a model fitted by lmer. I have a question about the dotplot_diag function for plotting cooks distances.

Here's an example of what I'm doing.

mod <- lmer(distance~age+Sex+(1|Subject), data=Orthodont)

cooksd <- cooks.distance(mod, group = "Subject")

dotplot_diag(x = cooksd, cutoff = "internal", name = "cooks.distance") + ylab("Cook's distance") + xlab("ID")

I get the following plot: enter image description here

Question: Is there a way to have influential points labelled with their Subject value instead of their index? i.e., it would show something like M13 or F10 (values in the Subject variable, see below).

head(unique(Orthodont$Subject))
[1] M01 M02 M03 M04 M05 M06

Thank you in advance for your help.

like image 942
msoftrain Avatar asked Jan 24 '26 01:01

msoftrain


1 Answers

I think the index argument will work:

dotplot_diag(x = cooksd, index=levels(Subject), 
 data=Orthodont, cutoff = "internal", name = "cooks.distance") + 
 ylab("Cook's distance") + xlab("ID")
like image 87
Ben Bolker Avatar answered Jan 26 '26 16:01

Ben Bolker