Davide Piffer – 03/08/2015
Q-Q plots are commonly used to detect deviations from the normal distribution. This can be done visually or – more formally – calculating the correlation between the theoretical and the empirical distributions.
Another widely used test of normality is the Shapiro-Wilk test. This produces a coefficient W with a value of 1 corresponding to perfect normality (no deviation from the theoretical distribution) and lower values representing deviations from normality.
My goal was to determine the degree of agreement between the estimates produced by these two methods. In order to achieve this, I computed the correlation between the theoretical (x axis) and the empirical (y axis) for the Q-Q plots and carried out the Shapiro-Wilk test on several continuous variables. Then, I correlated the W value to the Q-Q plot correlation coefficient.
Variables were taken from two files (NineHitsBetaFst_B.csv and Factors.csv) in the data set I used for the population genetics study of intelligence. The vectors represent allele frequencies or factors derived from allele frequencies via factor analysis (Piffer, 2015).
Data files containing the vectors can be downloaded from: https://osf.io/jt73x/
Results of the analysis are reported in this spreadsheet: https://docs.google.com/spreadsheets/d/1fg2evimqFlx2PqxopcfiJy99i4d6NgZw2HnsBeIzgUc/edit?usp=sharing
R was used to carry out the analysis.
R Code is in the appendix.
The correlation between Q-Q xy and Shapiro-Wilk W was r=0.993 (N=19; p<0.001).
Figure 1. Relationship between Q-Q plot xy correlation and Shapiro-Wilk W.
The relationship between the two variables can be approximately described by this formula:
1-W =~ 2(1-Corr Q-Q plot),
e.g. 9SNPsGIDist: Q-Q corr= 0.952 and Shapiro-W= 0.905. This can be seen from table 1.
Table 1. Relationship between the two methods (1-x).
|1-Corr Q-Q||1-W||(1-W)/(1-Corr Q-Q)|
There is indeed a slight tendency for the ratio to fall as departures from normality get bigger (i.e. with strong departures from 1, W is slightly less than twice as big as 1-corr Q-Q, whereas it is slightly more than twice as big when departures from normality are small).
There is a very strong agreement between two commonly used methods to test for normality of data. An advantage of the Shapiro-Wilk test is that it provides a test of the null hypothesis that the population is normally distributed. However, p values have many issues, besides being affected by sample size such that a very large sample size will always result in rejection of the null hypothesis even in the the presence of tiny deviations from normality (Kirkegaard, 2014).
Kirkegaard, E. (2014).W values from the Shapiro-Wilk test visualized with different datasets. http://emilkirkegaard.dk/en/?p=4452
Piffer, D. (2015). A review of intelligence GWAS hits: their relationship to country IQ and the issue of spatial autocorrelation. Figshare, http://dx.doi.org/10.6084/m9.figshare.1393160
qqChr21Fst=qqnorm(newdata3$Chr21.Fst)#creates Q-Q plot and assigns it a name
cor(qqChr21Fst$x,qqChr21Fst$y)#computes correlation between x and y axes of Q-Q plot
shapiro.test(newdata3$Chr21.Fst) # Shapiro-Wilk test
#Scatterplot (Q-Q cor vs Shapiro-Wilk W)
newdatascatterplot=na.omit(qqplots..BetaFst)#load .csv file with results (download from Google Docs link)
scatterplot(newdatascatterplot$SHAPIRO.WILKS.W~newdatascatterplot$CORR.Q.Q.PLOT,main=”Q-Q Plot xy cor vs Shapiro-Wilk W (r=0.99)”, xlab=”Shapiro-Wilk W”,ylab=”Q-Q Plot xy cor”,smoother=FALSE) #creates regression scatterplot with Q-Q plot correlation and Shapiro-Wilk W
cor(newdatascatterplot$SHAPIRO.WILKS.W,newdatascatterplot$CORR.Q.Q.PLOT) #computes correlation between the two methods