rstatistics

numbers in car package Q-Q plot in r


I plotted couple Q-Q plots with car package qqPlot {car} Looks nice but I don't get, what are those 2 numbers inside plot. For example I plotted 72 values and there is two numbers: 59 and 38. What these numbers are trying to tell me? Fivenum summary of data is 21.20 26.55 30.50 35.35 47.60 so those numbers are not any of these. See attached print screen. Thank you in advance!

enter image description here


Solution

  • Those 2 numbers inside the plot are the indices of the extreme values of the data.

    The definition of "extreme" is somewhat arbitrary, and for this function, there are a few choices, the default is to show the two (n=2) most extreme values based on abs(y - mean(y)) where x is your data and y is a vector of theoretical values (quantiles) from a comparison distribution, the default is "Gaussian" (see the "distribution" argument). Other options, including the number of extreme values to show (n), can be found in the help page of "showLabels" (see the "method" argument).

    The function is fairly extensive, but here's a very simplified version that you can run to replicate the indices identified by qqPlot using the default arguments.

    library(car)
    set.seed(123)
    x <- rnorm(72)
    qqPlot(x)
    

    enter image description here

    P <- ppoints(72)
    y <- qnorm(P)
    id.var <- abs(x - mean(y))
    ind <- order(id.var, decreasing = TRUE)[1:2]
    seq_along(x)[ind]
    #[1] 72 44