diff --git a/_pkgdown.yml b/_pkgdown.yml index 097eb71..480887b 100755 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -5,7 +5,7 @@ figures: dev.args: [] fig.ext: png fig.width: 4 - fig.height: 4 + fig.height: ~ fig.retina: 2 fig.asp: 1.618 bg: NA diff --git a/docs/articles/RLine.html b/docs/articles/RLine.html index 85ba7f9..1f27675 100755 --- a/docs/articles/RLine.html +++ b/docs/articles/RLine.html @@ -42,6 +42,7 @@ @@ -76,7 +77,7 @@

Manuel Gimond

-

2023-05-24

+

2023-06-05

Source: vignettes/RLine.Rmd
RLine.Rmd
@@ -350,8 +351,8 @@

Resampling the model residuals= quantile(bt[,2], p=c(0.05,0.95) ))) conf #> 5% 95% -#> Intercept -77.223468 9.110963 -#> Slope 1.695724 3.585426 +#> Intercept -74.674859 9.343323 +#> Slope 1.705581 3.516039

Resampling the x-y paired values @@ -378,8 +379,8 @@

Resampling the x-y paired values Slope = quantile(bt[,2], p=c(0.05,0.95) ))) conf #> 5% 95% -#> Intercept -108.668421 12.041885 -#> Slope 1.644885 4.157895

+#> Intercept -109.024692 14.867426 +#> Slope 1.643678 4.184233
diff --git a/docs/articles/RLine_files/figure-html/r-1.png b/docs/articles/RLine_files/figure-html/r-1.png index b0832e0..668df88 100755 Binary files a/docs/articles/RLine_files/figure-html/r-1.png and b/docs/articles/RLine_files/figure-html/r-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-10-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-10-1.png index be7675e..0490c7a 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-10-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-11-1.png index 32b7d40..24afbcf 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-11-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-12-1.png index b5a66c1..491a8ad 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-14-1.png index e5ea13e..6bd9fed 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-15-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-15-1.png index c074153..ddf04a2 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-15-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-15-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-16-1.png index 7ccbc23..45d05ad 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-17-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-17-1.png index 2429409..8bba0e6 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-17-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-17-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-18-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-18-1.png index 51cc06e..d57ec49 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-18-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-18-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-19-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-19-1.png index dfec74b..09c713d 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-19-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-19-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-2-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-2-1.png index b22e250..2007fa0 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-2-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-20-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-20-1.png index b525941..a37cc6f 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-20-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-20-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-22-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-22-1.png index 31eb9fc..d0ced81 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-22-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-22-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-25-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-25-1.png index 151233e..fc05170 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-25-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-25-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-3-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-3-1.png index 96348b6..70b8de6 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-3-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-4-1.png index c55f984..8357824 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-5-1.png index 729e795..ac22f69 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-6-1.png index 0eff3c8..c1a7ac6 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/RLine_files/figure-html/unnamed-chunk-7-1.png b/docs/articles/RLine_files/figure-html/unnamed-chunk-7-1.png index 10dc5c2..0b527b4 100755 Binary files a/docs/articles/RLine_files/figure-html/unnamed-chunk-7-1.png and b/docs/articles/RLine_files/figure-html/unnamed-chunk-7-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 812bf1b..d95ce5c 100755 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -25,6 +25,7 @@ @@ -55,6 +56,8 @@

All vignettes

Median polish
+
+
The QQ plot
Resistant Line
diff --git a/docs/articles/polish.html b/docs/articles/polish.html index 2d1ad32..f5b59a8 100755 --- a/docs/articles/polish.html +++ b/docs/articles/polish.html @@ -42,6 +42,7 @@ @@ -76,7 +77,7 @@

Manuel Gimond

-

2023-05-24

+

2023-06-05

Source: vignettes/polish.Rmd
polish.Rmd
diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-10-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-10-1.png index 19092d7..4b48190 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-10-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-12-1.png index 0e302cf..da3bda3 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-14-1.png index 11a912c..f291740 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-16-1.png index c4fb545..106c8d6 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-18-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-18-1.png index 7430a78..1a058d6 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-18-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-18-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-2-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-2-1.png index 8446bee..abc03ec 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-2-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-20-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-20-1.png index 5fa60ff..55ec12a 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-20-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-20-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-22-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-22-1.png index 5fa60ff..55ec12a 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-22-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-22-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-25-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-25-1.png index 6ea7ee9..b11ea01 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-25-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-25-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-27-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-27-1.png index 854a832..c5aa45a 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-27-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-27-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-29-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-29-1.png index 4e6ccae..3473eaf 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-29-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-29-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-31-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-31-1.png index d00900a..45922dd 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-31-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-31-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-33-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-33-1.png index e66b1e8..1a7786e 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-33-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-33-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-34-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-34-1.png index c276e79..6512ad1 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-34-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-34-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-35-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-35-1.png index d85d0f0..a2c0947 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-35-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-35-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-37-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-37-1.png index 9aca630..d291a0f 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-37-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-37-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-38-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-38-1.png index 8debc07..b5699f3 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-38-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-38-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-39-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-39-1.png index 9adc35f..f5b22d2 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-39-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-39-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-40-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-40-1.png index 9563ecb..fcc4c9a 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-40-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-40-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-42-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-42-1.png index 3872875..2cfa3c6 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-42-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-42-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-44-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-44-1.png index 22c95a1..f03f37c 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-44-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-44-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-45-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-45-1.png index cf1fe98..c97083c 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-45-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-45-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-46-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-46-1.png index 360d54a..ef127c2 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-46-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-46-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-48-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-48-1.png index 780d672..a3dae8e 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-48-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-48-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-49-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-49-1.png index 839edac..3359ad9 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-49-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-49-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-5-1.png index 7430a78..1a058d6 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-50-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-50-1.png index c4977c6..b790d34 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-50-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-50-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-51-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-51-1.png index f5729ba..083c121 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-51-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-51-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-52-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-52-1.png index 8b0e776..c222a30 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-52-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-52-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-54-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-54-1.png index 7b7d88a..4a4b372 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-54-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-54-1.png differ diff --git a/docs/articles/polish_files/figure-html/unnamed-chunk-55-1.png b/docs/articles/polish_files/figure-html/unnamed-chunk-55-1.png index 5b6cb3c..d718f68 100755 Binary files a/docs/articles/polish_files/figure-html/unnamed-chunk-55-1.png and b/docs/articles/polish_files/figure-html/unnamed-chunk-55-1.png differ diff --git a/docs/articles/qq.html b/docs/articles/qq.html new file mode 100755 index 0000000..f95f395 --- /dev/null +++ b/docs/articles/qq.html @@ -0,0 +1,413 @@ + + + + + + + + +The QQ plot • tukeyedar + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +
+

Introduction +

+

The empirical quantile-quantile plot (QQ plot) is probably +one of the most underused and least appreciated plots in univariate +analysis. It is used to compare two distributions across their +full range of values. It is a generalization of the boxplot in +that it does not limit the comparison to just the median and upper and +lower quartiles. In fact, it compares all values by matching +each value in one batch to its corresponding quantile in the other +batch. The sizes of each batch need not be the same. If they differ, the +larger batch is interpolated down to the smaller batch’s set of +quantiles.

+

A QQ plot can not only help visualize the differences in +distributions, but it can also model the relationship between both +batches. Note that this is not to be confused with modeling the +relationship between a bivariate dataset where the latter pairs up the +points by observational units whereas a QQ plot pairs up the +values by their “matching quantiles”.

+
+
+

Anatomy of the eda_qq plot +

+

+
#>  [1] "Suggested offsets:y = x * 1.4574 + (0.9914)"
+
    +
  • Each “dot” represents matching quantiles from each batch.
  • +
  • The shaded boxes represent each batch’s interquartile +ranges (mid 50% of values).
  • +
  • The Solid dashed lines inside the shaded boxes represent +each batch’s medians.
  • +
  • The lightly shaded dashed dots represent each batch’s +12.5th and 87.5th quantiles (i.e. they show the +ends of the mid 80% of values).
  • +
  • The upper right-hand text indicates the power +transformation applied to the both batches (default is a power of +1 which is original measurement scale). If a formula is +applied to one or both batches, it too will appear in the upper +right-hand text.
  • +
  • The eda_qq will also output the suggested +relationship between the y variable and the x variable. It bases +this on each batch’s interquartile values.
  • +
+
+
+

An overview of some of the function arguments +

+
+

Data type +

+

The function will accept a dataframe with a values column +and a group column, or it will accept two separate vector +objects. For example, to pass two separate vector object, +x and y, type:

+
+library(tukeyedar)
+set.seed(207)
+x <- rnorm(30)
+y <- rnorm(30) + 0.5
+eda_qq(x, y)
+

+

If the data are in a dataframe, type:

+
+dat <- data.frame(val = c(x, y), cat = rep(c("x", "y"), each = 30))
+eda_qq(dat, val, cat)
+

+
+
+

Suppressing plot +

+

You can suppress the plot and have the x and y values outputted to a +list. If the batches did not match in size, the output will show their +interpolated values such that the output batches match in size.

+

The output will also include the power parameter applied to both +batches as well as any formula applied to one or both batches +(fx is the formula applied to the x variable and +fy is the formula applied to the y variable).

+
+out <- eda_qq(x,y, plot = FALSE)
+#>  [1] "Suggested offsets:y = x * 1.1201 + (0.5618)"
+out
+#>  $x
+#>   [1] -2.0207122 -1.6048333 -1.5620907 -1.5128732 -1.3126378 -1.1770882
+#>   [7] -1.0871906 -0.9258832 -0.8896555 -0.6152073 -0.3140113 -0.2996734
+#>  [13] -0.2954234 -0.2199849 -0.2108781  0.1202060  0.2608893  0.2680445
+#>  [19]  0.2910663  0.4239690  0.4262605  0.4301416  0.5176361  0.6085180
+#>  [25]  0.6880919  0.6929772  0.7640838  0.9037644  1.0124869  1.0503544
+#>  
+#>  $y
+#>   [1] -2.10710669 -1.30465821 -1.17618932 -1.17253191 -0.86423268 -0.40162859
+#>   [7] -0.37002087 -0.19629536 -0.07210822 -0.01829722  0.05826287  0.09105884
+#>  [13]  0.09371398  0.13698992  0.22318119  0.43006689  0.52597363  0.72665767
+#>  [19]  0.81351407  1.00612388  1.01831440  1.06713353  1.23708449  1.24360530
+#>  [25]  1.33232007  1.43973056  1.59125312  1.64852115  1.77464625  1.93823390
+#>  
+#>  $p
+#>  [1] 1
+#>  
+#>  $fx
+#>  NULL
+#>  
+#>  $fy
+#>  NULL
+
+
+

Setting the grey box and dashed line parameters +

+

The grey box highlights the interquartile ranges for both batches. +Its boundary can be modified via the b.val argument. +Likewise, the lightly shaded dashed dots that highlight the mid 80% of +values can be modified via the l.val argument.

+

For example, to highlight the mid 68% of values using the grey boxes +and the mid 95% of values using the lightly shaded dashed dots, +type:

+
+eda_qq(x, y, b.val = c(0.16, 0.84), l.val = c(0.025, 0.975))
+

+

You can suppress the plotting of the grey box and the lightly shaded +dashed dots by setting q = FALSE. This does not affect the +median dashed lines.

+
+
+

Applying a formula to one of the batches +

+

You can apply a formula to a batch via the fx argument +for the x-variable and the fy argument for the y-variable. +The formula is passed as a text string. For example, to add +0.5 to the x values, type:

+
+eda_qq(x, y, fx = "x + 0.5")
+

+
+
+

Quantile type +

+

There are many different quantile algorithms available in R. To see +the full list of quantile types, refer to the quantile help page: +?quantile. By default, eda_qq() adopts +q.type = 5. In general, the choice of quantiles will not +really matter, especially for large datasets. If you want to adopt R’s +default type, set q.type = 7.

+
+
+

Point symbols +

+

The point symbol type, color and size can be modified via the +pch, p.col (and/or p-fill) and +size arguments. The color can be either a built-in color +name (you can see the full list by typing colors()) or the +rgb() function. If you define the color using one of the +built-in color names, you can adjust its transparency via the +alpha argument. A value of 0 renders the point +completely transparent and a value of 1 renders the point +completely opaque. The point symbol can take on two color parameters +depending on point type. If pch is any number between 21 +and 25, p.fill will define its fill color and +p.col will define its border color. For any other point +symbol type, the p.fill argument is ignored.

+

Here are a few examples:

+
+eda_qq(x, y, p.fill = "bisque", p.col = "red", size = 1.2)
+

+
+eda_qq(x, y, pch = 16, p.col = "tomato2", size = 1.5, alpha = 0.5)
+

+
+eda_qq(x, y, pch = 3, p.col = "tomato2", size = 1.5)
+

+
+
+
+

Interpreting a QQ plot +

+

To help interpret the following QQ plots, we’ll compare each plot to +matching kernel density plots. We’ll start with a simple example

+
+library(tukeyedar)
+set.seed(543)
+x <- rnorm(100)
+y <- x + 2
+eda_qq(x, y)
+eda_dens(x,y)
+

+
+y <- x * 0.5
+eda_qq(x,y)
+eda_dens(x,y)
+

+
+y <- x * 0.5 + 2
+eda_qq(x,y)
+eda_dens(x,y)
+

+
+set.seed(540)
+x2 <- rbeta(100, 1,8)
+y2 <- x2 + 0.2 
+eda_qq(x2,y2)
+eda_dens(x2,y2)
+

+
+
+

Power transformation +

+
+s1 <- subset(Indometh, Subject == 1, select = conc, drop = TRUE)
+s2 <- subset(Indometh, Subject == 2, select = conc, drop = TRUE)
+
+eda_qq(s1, s2, p = 1)
+

+
+eda_qq(s1, s2, p = 0)
+

+
+eda_qq(s1,s2,p=0,fx="x * 0.8501 + 0.3902")
+

+
+eda_dens(s1, s2)
+

+
+

The Tukey mean-difference plot +

+

This is simply an extension of the QQ plot whereby the plot is +rotated such that the 45° line (the 1:1 slope) becomes horizontal. This +can be useful in helping identify subtle differences between batches. +The plot is rotated 45° by mapping the difference between both batches +to the y-axis, and mapping the mean between both batches to the x-axis. +For example, the following figure on the left (the QQ plot) shows the +additive offset between both batches but it fails to show the +multiplicative offset. The latter can be clearly seen in the Tukey +mean-difference plot (on the right) which can be invoked by setting the +argument md = TRUE.

+
+y <- x * 0.97 + 0.3
+eda_qq(x,y)
+eda_qq(x,y, md = TRUE)
+

+
+
+

A working example +

+
+old <- wat95$avg # legacy temperature normals
+new <- wat05$avg # current temperature normals
+out <- eda_qq(old, new)
+

+
+old <- wat95$avg # legacy temperature normals
+new <- wat05$avg # current temperature normals
+out <- eda_qq(old, new, md = TRUE)
+

+
+labs <- c("low", "mid", "high")
+out$avg <- (out$x + out$y) / 2
+out <- as.data.frame(out[c(1:2,6)])
+out2 <- split(out, cut(out$avg, c(min(out$avg), 35, 50, max(out$avg)), 
+                       labels = labs, include.lowest = TRUE))
+sapply(labs, FUN = \(x) {eda_qq(out2[[x]]$x, out2[[x]]$y ,
+                                xlab = "old", ylab = "new", md = T)
+                         title(x, line = 3, col.main = "orange")} )
+

+
#>  [1] "Suggested offsets:y = x * 0.9506 + (1.661)"
+#>  [1] "Suggested offsets:y = x * 1.0469 + (-1.6469)"
+#>  [1] "Suggested offsets:y = x * 0.9938 + (0.9268)"
+

What not to do:

+
+labs <- c("low", "mid", "high")
+old.split <- split(old, cut(old, c(min(old), 35, 50, max(old)), 
+                            labels = labs, include.lowest = TRUE))
+new.split <- split(new, cut(new, c(min(new), 35, 50, max(new)), 
+                            labels = labs, include.lowest = TRUE))
+sapply(labs, FUN = \(x) {eda_qq(old.split[[x]], new.split[[x]] ,
+                                xlab = "old", ylab = "new", md = T)
+                         title(x, line = 3, col.main = "orange")} )
+

+
+xform <- c("x * 0.9636 + 1.4411", 
+           "x * 0.9838 + 0.7478",
+           "x * 1.0365 - 2.0333")
+names(xform) <- labs
+sapply(labs, FUN = \(x) {eda_qq(old.split[[x]], new.split[[x]] , 
+                                fx = xform[x],
+                                xlab = "old", ylab = "new", md = T); 
+                         title(x, line = 3, col.main = "orange")} )
+

+

The characterization of the differences in normal temperatures +between the old and new set of normals can be formalized as follows:

+

\[ +new = \begin{cases} +old * 0.9636 + 1.4411, & T_{avg} < 35 \\ +old * 0.9838 + 0.7478, & 35 \le T_{avg} < 50 \\ +old * 1.0365 - 2.0333, & T_{avg} \ge 50 +\end{cases} +\]

+

The key takeaways from this analysis can be summarized as +follows:

+
    +
  • +
+
+
+
+
+ + + + +
+ + + + + + + diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-10-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-10-1.png new file mode 100755 index 0000000..f81ffb6 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-11-1.png new file mode 100755 index 0000000..de34730 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-12-1.png new file mode 100755 index 0000000..1692f59 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-13-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-13-1.png new file mode 100755 index 0000000..7a2aab7 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-13-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-14-1.png new file mode 100755 index 0000000..fb8a2c8 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-15-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-15-1.png new file mode 100755 index 0000000..2b53d33 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-15-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-15-2.png b/docs/articles/qq_files/figure-html/unnamed-chunk-15-2.png new file mode 100755 index 0000000..6d0eebd Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-15-2.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-15-3.png b/docs/articles/qq_files/figure-html/unnamed-chunk-15-3.png new file mode 100755 index 0000000..661f9c8 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-15-3.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-16-1.png new file mode 100755 index 0000000..2b53d33 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-16-2.png b/docs/articles/qq_files/figure-html/unnamed-chunk-16-2.png new file mode 100755 index 0000000..6d0eebd Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-16-2.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-16-3.png b/docs/articles/qq_files/figure-html/unnamed-chunk-16-3.png new file mode 100755 index 0000000..661f9c8 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-16-3.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-17-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-17-1.png new file mode 100755 index 0000000..6caa66f Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-17-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-18-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-18-1.png new file mode 100755 index 0000000..b8f1215 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-18-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-19-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-19-1.png new file mode 100755 index 0000000..d6c7515 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-19-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-2-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-2-1.png new file mode 100755 index 0000000..909a717 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-20-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-20-1.png new file mode 100755 index 0000000..4a10347 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-20-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-21-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-21-1.png new file mode 100755 index 0000000..787e109 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-21-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-22-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-22-1.png new file mode 100755 index 0000000..787e109 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-22-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-23-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-23-1.png new file mode 100755 index 0000000..21d971c Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-23-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-24-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-24-1.png new file mode 100755 index 0000000..dbf6159 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-24-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-3-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-3-1.png new file mode 100755 index 0000000..dd09079 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-4-1.png new file mode 100755 index 0000000..2a77226 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-6-1.png new file mode 100755 index 0000000..52cf968 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-7-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-7-1.png new file mode 100755 index 0000000..468887d Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-7-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-8-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-8-1.png new file mode 100755 index 0000000..d2366b0 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-8-1.png differ diff --git a/docs/articles/qq_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/qq_files/figure-html/unnamed-chunk-9-1.png new file mode 100755 index 0000000..77281c4 Binary files /dev/null and b/docs/articles/qq_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/man/eda_dens.Rd b/man/eda_dens.Rd index 96d4581..0ddc69c 100755 --- a/man/eda_dens.Rd +++ b/man/eda_dens.Rd @@ -7,6 +7,7 @@ eda_dens( x, y, + fac = NULL, p = 1L, tukey = FALSE, fx = NULL, @@ -22,9 +23,12 @@ eda_dens( ) } \arguments{ -\item{x}{Vector for first variable.} +\item{x}{Vector for first variable or a dataframe.} -\item{y}{Vector for second variable.} +\item{y}{Vector for second variable or column defining the continuous +variable if \code{x} is a dataframe.} + +\item{fac}{Column defining the grouping variable if \code{x} is a dataframe.} \item{p}{Power transformation to apply to both sets of values.} @@ -46,9 +50,9 @@ transformation is applied to the y variable.} \item{alpha}{Fill transparency (0 = transparent, 1 = opaque). Only applicable if \code{rgb()} is not used to define fill colors.} -\item{xlab}{X label for output plot.} +\item{xlab}{X variable label. Ignored if \code{x} is a dataframe.} -\item{ylab}{Y label for output plot.} +\item{ylab}{Y variable label. Ignored if \code{x} is a dataframe.} \item{legend}{Boolean determining if a legend should be added to the plot.} @@ -68,9 +72,14 @@ This function will generate overlapping density plots with the first } \examples{ - # Accepting data as two separate vector objects + # Passing data as two separate vector objects set.seed(207) x <- rbeta(1000,2,8) y <- x * 1.5 + 0.1 eda_dens(x, y) + + # Passing data as a dataframe + dat <- data.frame(val = c(x, y), + grp = c(rep("x", length(x)), rep("y", length(y)))) + eda_dens(dat, val, grp) } diff --git a/man/eda_qq.Rd b/man/eda_qq.Rd index b28c47b..a99c2cc 100755 --- a/man/eda_qq.Rd +++ b/man/eda_qq.Rd @@ -7,13 +7,15 @@ eda_qq( x, y, + fac = NULL, p = 1L, - q.type = 5, tukey = FALSE, md = FALSE, + q.type = 5, fx = NULL, fy = NULL, plot = TRUE, + show.par = TRUE, grey = 0.6, pch = 21, p.col = "grey50", @@ -29,14 +31,14 @@ eda_qq( ) } \arguments{ -\item{x}{Column assigned to the x axis.} +\item{x}{Vector for first variable or a dataframe.} -\item{y}{Column assigned to the y axis.} +\item{y}{Vector for second variable or column defining the continuous +variable if \code{x} is a dataframe.} -\item{p}{Power transformation to apply to both sets of values.} +\item{fac}{Column defining the grouping variable if \code{x} is a dataframe.} -\item{q.type}{An integer between 1 and 9 selecting one of the nine quantile -algorithms. (See \code{quantile}tile function).} +\item{p}{Power transformation to apply to both sets of values.} \item{tukey}{Boolean determining if a Tukey transformation should be adopted (FALSE adopts a Box-Cox transformation).} @@ -44,6 +46,9 @@ algorithms. (See \code{quantile}tile function).} \item{md}{Boolean determining if Tukey mean-difference plot should be generated.} +\item{q.type}{An integer between 1 and 9 selecting one of the nine quantile +algorithms. (See \code{quantile}tile function).} + \item{fx}{Formula to apply to x variable. This is computed after any transformation is applied to the x variable.} @@ -52,6 +57,9 @@ transformation is applied to the y variable.} \item{plot}{Boolean determining if plot should be generated.} +\item{show.par}{Boolean determining if parameters such as power +transformation or formula should be displayed.} + \item{grey}{Grey level to apply to plot elements (0 to 1 with 1 = black).} \item{pch}{Point symbol type.} @@ -74,9 +82,9 @@ IQR. Two values are needed.} \item{l.val}{Quantiles to define the quantile line parameters. Defaults to the mid 75\% of values. Two values are needed.} -\item{xlab}{X label for output plot} +\item{xlab}{X label for output plot. Ignored if \code{x} is a dataframe.} -\item{ylab}{Y label for output plot} +\item{ylab}{Y label for output plot. Ignored if \code{x} is a dataframe.} \item{...}{Not used} } @@ -98,16 +106,20 @@ Returns a list with the following components: } \details{ The QQ plot will displays the IQR via grey boxes for both x and y -values. The box widths can be changed via the \code{b.val} argument. The plot -will also display the mid 75\% of values via light colored dashed lines. The -line positions can be changed via the \code{l.val} argument. The middle -dashed line represents each batch's median value. -Console output prints the suggested multiplicative and additive offsets. + values. The box widths can be changed via the \code{b.val} argument. The + plot will also display the mid 75\% of values via light colored dashed + lines. The line positions can be changed via the \code{l.val} argument. The + middle dashed line represents each batch's median value. Console output + prints the suggested multiplicative and additive offsets. } \examples{ -# Example 1: Comparing "Tenor 1" and "Bass 2" singer height values +# Passing data as a dataframe singer <- lattice::singer + dat <- singer[singer$voice.part \%in\% c("Bass 2", "Tenor 1"), ] + eda_qq(dat, height, voice.part) + +# Passing data as two separate vector objects bass2 <- subset(singer, voice.part == "Bass 2", select = height, drop = TRUE ) tenor1 <- subset(singer, voice.part == "Tenor 1", select = height, drop = TRUE ) diff --git a/vignettes/qq.Rmd b/vignettes/qq.Rmd index d1bd31a..02bceff 100755 --- a/vignettes/qq.Rmd +++ b/vignettes/qq.Rmd @@ -27,21 +27,116 @@ knitr::opts_chunk$set( ``` ```{r include=FALSE} -knitr::opts_chunk$set(echo = TRUE) +knitr::opts_chunk$set(echo = TRUE, dev.args=list(pointsize=10)) ``` -## Introduction +# Introduction -The *empirical quantile-quantile plot* (QQ plot) is probably one of the most underused and least appreciated plots in univariate analysis. +The *empirical quantile-quantile plot* (QQ plot) is probably one of the most underused and least appreciated plots in univariate analysis. It is used to compare two distributions across their *full* range of values. It is a generalization of the boxplot in that it does not limit the comparison to just the median and upper and lower quartiles. In fact, it compares *all* values by matching each value in one batch to its corresponding quantile in the other batch. The sizes of each batch need not be the same. If they differ, the larger batch is interpolated down to the smaller batch's set of quantiles. -## Interpreting a QQ plot +A QQ plot can not only help visualize the differences in distributions, but it can also model the relationship between both batches. Note that this is not to be confused with modeling the relationship between a bivariate dataset where the latter pairs up the points by *observational units* whereas a QQ plot pairs up the values by their "matching quantiles". + + +# Anatomy of the `eda_qq` plot + +```{r fig.width=3, fig.height=3, echo = FALSE} +library(tukeyedar) +set.seed(897) +x <- rnorm(30) +y <- x * 1.5 + 1 + rnorm(30, 0, 0.1 ) +eda_qq(x,y) +``` + +* Each "dot" represents matching quantiles from each batch. +* The *shaded boxes* represent each batch's interquartile ranges (mid 50% of values). +* The *Solid dashed lines* inside the shaded boxes represent each batch's medians. +* The *lightly shaded dashed dots* represent each batch's 12.5^th^ and 87.5^th^ quantiles (i.e. they show the ends of the mid 80% of values). +* The *upper right-hand text* indicates the power transformation applied to the both batches (default is a power of `1` which is original measurement scale). If a formula is applied to one or both batches, it too will appear in the upper right-hand text. +* The `eda_qq` will also output the *suggested relationship* between the y variable and the x variable. It bases this on each batch's interquartile values. + +# An overview of some of the function arguments + +## Data type +The function will accept a *dataframe* with a values column and a group column, or it will accept *two separate vector objects*. For example, to pass two separate vector object, `x` and `y`, type: + +```{r fig.height = 3, fig.width = 3, results='hide'} +library(tukeyedar) +set.seed(207) +x <- rnorm(30) +y <- rnorm(30) + 0.5 +eda_qq(x, y) +``` + +If the data are in a dataframe, type: + +```{r fig.height=3, fig.width = 3, results='hide'} +dat <- data.frame(val = c(x, y), cat = rep(c("x", "y"), each = 30)) +eda_qq(dat, val, cat) +``` + +## Suppressing plot + +You can suppress the plot and have the x and y values outputted to a list. If the batches did not match in size, the output will show their interpolated values such that the output batches match in size. + +The output will also include the power parameter applied to both batches as well as any formula applied to one or both batches (`fx` is the formula applied to the x variable and `fy` is the formula applied to the y variable). + +```{r} +out <- eda_qq(x,y, plot = FALSE) +out +``` + +## Setting the grey box and dashed line parameters + +The grey box highlights the interquartile ranges for both batches. Its boundary can be modified via the `b.val` argument. Likewise, the lightly shaded dashed dots that highlight the mid 80% of values can be modified via the `l.val` argument. + +For example, to highlight the mid 68% of values using the grey boxes and the mid 95% of values using the lightly shaded dashed dots, type: + +```{r fig.width=3, fig.height=3, results='hide'} +eda_qq(x, y, b.val = c(0.16, 0.84), l.val = c(0.025, 0.975)) +``` + +You can suppress the plotting of the grey box and the lightly shaded dashed dots by setting `q = FALSE`. This does not affect the median dashed lines. + +## Applying a formula to one of the batches + +You can apply a formula to a batch via the `fx` argument for the x-variable and the `fy` argument for the y-variable. The formula is passed as a text string. For example, to add `0.5` to the x values, type: + +```{r fig.width=3, fig.height=3, results='hide'} +eda_qq(x, y, fx = "x + 0.5") +``` + +## Quantile type + +There are many different quantile algorithms available in R. To see the full list of quantile types, refer to the quantile help page: `?quantile`. By default, `eda_qq()` adopts `q.type = 5`. In general, the choice of quantiles will not really matter, especially for large datasets. If you want to adopt R's default type, set `q.type = 7`. + +## Point symbols + +The point symbol type, color and size can be modified via the `pch`, `p.col` (and/or `p-fill`) and `size` arguments. The color can be either a built-in color name (you can see the full list by typing `colors()`) or the `rgb()` function. If you define the color using one of the built-in color names, you can adjust its transparency via the `alpha` argument. A value of `0` renders the point completely transparent and a value of `1` renders the point completely opaque. The point symbol can take on two color parameters depending on point type. If `pch` is any number between 21 and 25, `p.fill` will define its fill color and `p.col` will define its border color. For any other point symbol type, the `p.fill` argument is ignored. + +Here are a few examples: + +```{r fig.width=3, fig.height=3, results='hide'} +eda_qq(x, y, p.fill = "bisque", p.col = "red", size = 1.2) +``` + +```{r fig.width=3, fig.height=3, results='hide'} +eda_qq(x, y, pch = 16, p.col = "tomato2", size = 1.5, alpha = 0.5) +``` + +```{r fig.width=3, fig.height=3, results='hide'} +eda_qq(x, y, pch = 3, p.col = "tomato2", size = 1.5) +``` + +# Interpreting a QQ plot + +To help interpret the following QQ plots, we'll compare each plot to matching kernel density plots. We'll start with a simple example ```{r fig.height=3, fig.width = 6, echo=2:7, results='hide'} OP <- par(mfrow=c(1,2)) library(tukeyedar) set.seed(543) -x <- rnorm(100); dx <- density(x) -y <- x + 2; dy <- density(y) +x <- rnorm(100) +y <- x + 2 eda_qq(x, y) eda_dens(x,y) par(OP) @@ -49,7 +144,7 @@ par(OP) ```{r fig.height=3, fig.width = 6, echo=2:4, results='hide'} OP <- par(mfrow=c(1,2)) -y <- x * 0.5; dy <- density(y) +y <- x * 0.5 eda_qq(x,y) eda_dens(x,y) par(OP) @@ -57,7 +152,7 @@ par(OP) ```{r fig.height=3, fig.width = 6, echo=2:4, results='hide'} OP <- par(mfrow=c(1,2)) -y <- x * 0.5 + 2; dy <- density(y) +y <- x * 0.5 + 2 eda_qq(x,y) eda_dens(x,y) par(OP) @@ -67,8 +162,8 @@ par(OP) ```{r fig.height=3, fig.width = 6, echo=2:6, results='hide'} OP <- par(mfrow=c(1,2)) set.seed(540) -x2 <- rbeta(100, 1,8); dx2 <- density(x2) -y2 <- x2 + 0.2 ; dy2 <- density(y2) +x2 <- rbeta(100, 1,8) +y2 <- x2 + 0.2 eda_qq(x2,y2) eda_dens(x2,y2) par(OP) @@ -77,11 +172,11 @@ par(OP) # Power transformation ```{r} -s1 <- subset(Indometh, Subject==1 , select=conc, drop = TRUE) -s2 <- subset(Indometh, Subject == 2, select=conc, drop = TRUE) +s1 <- subset(Indometh, Subject == 1, select = conc, drop = TRUE) +s2 <- subset(Indometh, Subject == 2, select = conc, drop = TRUE) ``` -```{r fig.width = 3, results='hide'} +```{r fig.width=3, fig.height=3, results='hide'} eda_qq(s1, s2, p = 1) eda_qq(s1, s2, p = 0) eda_qq(s1,s2,p=0,fx="x * 0.8501 + 0.3902") @@ -93,100 +188,97 @@ eda_dens(s1, s2) ## The Tukey mean-difference plot -This is simply an extension of the QQ plot whereby the plot is rotated such that the 45° line (the 1:1 slope) becomes horizontal. This can be useful in helping identify subtle differences between batches. The plot is rotated 45° by mapping the difference between both bacthes to the y-axis, and mapping the mean between both batches to the x-axis. For example, the following figure on the left (the QQ plot) shows the additive offset between both batches but it fails to show the multiplicative offset. The latter can be clearly seen in the Tukey mean-difference plot (on the right) which can be invoked by setting the argument `md = TRUE`. +This is simply an extension of the QQ plot whereby the plot is rotated such that the 45° line (the 1:1 slope) becomes horizontal. This can be useful in helping identify subtle differences between batches. The plot is rotated 45° by mapping the difference between both batches to the y-axis, and mapping the mean between both batches to the x-axis. For example, the following figure on the left (the QQ plot) shows the additive offset between both batches but it fails to show the multiplicative offset. The latter can be clearly seen in the Tukey mean-difference plot (on the right) which can be invoked by setting the argument `md = TRUE`. -```{r fig.wdith = 6, fig.height=2.5, echo=3:4} +```{r fig.height=3, fig.width = 6, echo=2:4, results='hide'} OP <- par(mfrow=c(1,2)) -y <- x * 0.97 + 0.3; dy <- density(y) +y <- x * 0.97 + 0.3 eda_qq(x,y) eda_qq(x,y, md = TRUE) par(OP) ``` -## Anatomy of the `eda_qq` plot - -* Solid dashed lines represent the medians of each batch of values. -* The shaded boxes represent the interquartile ranges (mid 50% of values) for each batch. -* The lightly shaded dashed dots represent the 12.5^th^ and 87.5^th^ quantiles of each batch (i.e. they show the ends of the mid 80% of values). -* Upper left hand text indicates the power parameter applied to the both batches (default is a power of `1`--original measurement scale). -* If an offset is applied to one of the axes, this will also be shown in the upper right-hand text. +## A working example +```{r fig.height=3, fig.width=3, results='hide'} +old <- wat95$avg # legacy temperature normals +new <- wat05$avg # current temperature normals +out <- eda_qq(old, new) +``` -## A working example - -```{r} +```{r fig.height=3, fig.width=3, results='hide'} old <- wat95$avg # legacy temperature normals new <- wat05$avg # current temperature normals out <- eda_qq(old, new, md = TRUE) ``` -```{r} + +```{r fig.height=3, fig.width = 9, eval=FALSE} labs <- c("low", "mid", "high") out$avg <- (out$x + out$y) / 2 out <- as.data.frame(out[c(1:2,6)]) -out2 <- split(out, cut(out$avg, c(min(out$avg), 35, 50, max(out$avg)), labels = labs, include.lowest = TRUE)) -# eda_qq(out2$mid$x, out2$mid$y, md = T) +out2 <- split(out, cut(out$avg, c(min(out$avg), 35, 50, max(out$avg)), + labels = labs, include.lowest = TRUE)) +sapply(labs, FUN = \(x) {eda_qq(out2[[x]]$x, out2[[x]]$y , + xlab = "old", ylab = "new", md = T) + title(x, line = 3, col.main = "orange")} ) +``` +```{r fig.height=3, fig.width = 9, echo=FALSE, results='hold', dev.args=list(pointsize=14)} OP <- par(mfrow = c(1,3)) -sapply(labs, FUN = \(x) {eda_qq(out2[[x]]$x, out2[[x]]$y , - xlab = "old", ylab = "new", md = T); title(x, line = 3, col.main = "orange")} ) +labs <- c("low", "mid", "high") +out$avg <- (out$x + out$y) / 2 +out <- as.data.frame(out[c(1:2,6)]) +out2 <- split(out, cut(out$avg, c(min(out$avg), 35, 50, max(out$avg)), labels = labs, include.lowest = TRUE)) +tmp <- sapply(labs, FUN = \(x) {eda_qq(out2[[x]]$x, out2[[x]]$y , + xlab = "old", ylab = "new", md = T) + title(x, line = 3, col.main = "orange")} ) par(OP) - ``` What not to do: -```{r} -labs <- c("low", "mid", "high") -old.split <- split(old, cut(old, c(min(old), 35, 50, max(old)), labels = labs, include.lowest = TRUE)) -new.split <- split(new, cut(new, c(min(new), 35, 50, max(new)), labels = labs, include.lowest = TRUE)) - - +```{r fig.height=3, fig.width = 9, echo=2:5, results='hide', dev.args=list(pointsize=14)} OP <- par(mfrow = c(1,3)) +labs <- c("low", "mid", "high") +old.split <- split(old, cut(old, c(min(old), 35, 50, max(old)), + labels = labs, include.lowest = TRUE)) +new.split <- split(new, cut(new, c(min(new), 35, 50, max(new)), + labels = labs, include.lowest = TRUE)) sapply(labs, FUN = \(x) {eda_qq(old.split[[x]], new.split[[x]] , - xlab = "old", ylab = "new", md = T); title(x, line = 3, col.main = "orange")} ) + xlab = "old", ylab = "new", md = T) + title(x, line = 3, col.main = "orange")} ) par(OP) ``` -```{r} +```{r fig.height=3, fig.width = 9, echo=2:4, results='hide', dev.args=list(pointsize=14)} +OP <- par(mfrow = c(1,3)) xform <- c("x * 0.9636 + 1.4411", "x * 0.9838 + 0.7478", "x * 1.0365 - 2.0333") names(xform) <- labs - -OP <- par(mfrow = c(1,3)) sapply(labs, FUN = \(x) {eda_qq(old.split[[x]], new.split[[x]] , fx = xform[x], - xlab = "old", ylab = "new", md = T); title(x)} ) + xlab = "old", ylab = "new", md = T); + title(x, line = 3, col.main = "orange")} ) par(OP) ``` -```{r} -xform <- c("x * 0.96 + 1.5", - "x * 0.98 + 0.75", - "x * 1.04 - 2") -names(xform) <- labs - -OP <- par(mfrow = c(1,3)) -sapply(labs, FUN = \(x) {eda_qq(old.split[[x]], new.split[[x]] , - fx = xform[x], - xlab = "old", ylab = "new", md = T); title(x, line = 2, col.main = "bisque")} ) -par(OP) -``` The characterization of the differences in normal temperatures between the old and new set of normals can be formalized as follows: $$ new = \begin{cases} -old * 0.96 + 1.4411, & T_{avg} < 35 \\ -old * 0.98 + 0.7478 & 35 \le T_{avg} < 50 \\ -old - 2, & T_{avg} \ge 50 +old * 0.9636 + 1.4411, & T_{avg} < 35 \\ +old * 0.9838 + 0.7478, & 35 \le T_{avg} < 50 \\ +old * 1.0365 - 2.0333, & T_{avg} \ge 50 \end{cases} $$ -The key takeways from this analysis can be summarized as follows: +The key takeaways from this analysis can be summarized as follows: + *