Question

This question is about convenient way of plotting simultaneous null band based on pointwise quantile estimates in R. Suppose I obtain a vector of p-values, and I want to see, by using uniform QQ plot, if its distribution is close to a uniform distribution (...and if not, which points "stand out", i.e. fall outside the band). Here is an example (where u_obs denotes p-values not necessarily from a uniform distribution -- for illustration purpose only):

library(gap)
u_obs = qqrunif(1000)
qqunif(u_obs,pch=21,bg="blue",bty="n")

According to the nonparametric approach discussed on page 5, Figure 1 (bottom left panel) of this paper: http://stat.wharton.upenn.edu/~buja/PAPERS/paper-sim.pdf, we can do 10,000 simulations and get the lower and upper 5% quantiles if a 90% simultaneous bound is desired.

My questions are:

  1. Is there an R package/code snippets that are able to perform this task efficiently? I think this belongs to the "functional data analysis" realm, but I am not quite sure.

  2. What inference can we make from the simultaneous null bound of a uniform QQ plot? Examining those points that fall outside the bands? How many points do I expect to be reasonably outside the band if the true distribution of the p-values is uniform (i.e. coming from the null)?

Was it helpful?

Solution

Take a look at the ?qqPlot function in the car package. This will plot a confidence band for you (you just have to tell it which distribution you are interested in).

library(car)
set.seed(9)
u_obs <- runif(100)
windows()
  qqPlot(u_obs, distribution="unif")

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top