ScatterPlot.RdScatterPlot produces a scatterplot including legend of valid values, pearson correlation coefficient with confidence interval, outlier detection including option to exclude outlier, principal axis and_or regression lines Y~X and X~Y shown, subgroup (SPLIT) shown by colour and_or point type together with optional partial correlation coefficient given the subgroup information.
ScatterPlot(X, Y, SCALE_X = "ID", SCALE_Y = "ID", SPLIT = NULL, COL = 4, PCH = 19, LINECOL = 4, CONF.LEVEL = 0.95, XLAB = NULL, YLAB = NULL, MAIN = NULL, OUTLIER = 4, NO_OUTLIERS = F, SHOW_COR = T, DIGITS = 3, LINE_THRESHOLD = 0.3, XY_LINE = T, Y_ON_X = F, X_ON_Y = F, SUBLINES = F, MEANPOINT = F, PARCOR = T, ...)
| X | metric variable for x-axis |
|---|---|
| Y | metric variable for y-axis |
| SCALE_X | ="ID" chooses a ScaleTransformation ID, POWER_Z, LOG10, LOGIT for X: use optional parameter ZX to specify the power to use with POWER_Z. use optional parameter PERCENT_X = T for percent instead of proportions on LOGIT scale. |
| SCALE_Y | ="ID" chooses a ScaleTransformation ID, POWER_Z, LOG10, LOGIT for X: use optional parameter ZY to specify the power to use with POWER_Z. use optional parameter PERCENT_Y = T for percent instead of proportions on LOGIT scale. |
| SPLIT | =NULL split analysis by subgrouping factor |
| COL | =4 colour of points. For subgroups, specifiy COL as vector with length=nlevel(SPLIT), else 1:nlevel(SPLIT) |
| PCH | =19 point type(s). For subgroups, specifiy PCH as vector with length=nlevel(SPLIT), else 1:nlevel(SPLIT) |
| LINECOL | =4 colour of SymLine or plotted line if only one line is plotted |
| CONF.LEVEL | =0.95 confidence level for CI of correlation coefficient |
| XLAB | =NULL optional label for X, otherwise derived from call X |
| YLAB | =NULL optional label for Y, otherwise derived from call Y |
| MAIN | =NULL specifiy title, if MAIN = NULL no title |
| OUTLIER | =4 outlier are identified using lmRob from package robust a points with |residue| > OUTLIER * robustSd. set OUTLIER=Inf if no outliers should be highlighted. |
| NO_OUTLIERS | =F set to TRUE to eliminate outliers from the plot and the analysis |
| SHOW_COR | =T show legend with correlation corefficient and its CI |
| DIGITS | =3 Number of digits for correlation coefficients |
| LINE_THRESHOLD | =.3 only show lines iff |cor| >= LINE_THRESHOLD |
| XY_LINE | =T As a default the SymLine, i.e. the principal componant axis (symmetrical in X and Y!) is plotted. This line minimises the sum of the squares of the Euclidian distances between points and line. |
| Y_ON_X | =F Plot the usual but asymmetric regression line Y~X. This line minimises the sum of the squares of the Euclidian distances between points and line parallel to the Y-axis. |
| X_ON_Y | =F Plot the regression line X~Y. This line minimises the sum of the squares of the Euclidian distances between points and line parallel to the X-axis. |
| SUBLINES | =F If TRUE SymLines for subgroups defined by SPLIT are plotted instead of any overall line. |
| MEANPOINT | =F Option to plot the overall mean within the plot. |
| PARCOR | =T As a default, the partial correlation pcor(x,y |SPLIT) is given in the legend reporting correlation. |
| ... | further parameters for scale transformations can be provided via ... ZX, ZY specifies the power to use with POWER_Z when using POWER_Z PERCENT =F Use percent instead of proportions in LOGIT when using LOGIT |
data.frame with the index and the X,Y values of the identified outliers if SPLIT=NULL or SUBLINES=F. If SUBLINES=T and more than one subgroup a data.frame is returned with all pairwise comparisons of subgroup correlation coefficients.
SymLine for adding a symetric line, CorDiffCI for confidence intervals for difference of correlation coefficients.
if (FALSE) { x <- rnorm(100, 10, 2) y <- rnorm(100, 100, 4) + 1.7 * x ScatterPlot(x, y, PCH = 2) x <- c(x, 10 + 0.2 * rnorm(20)) y <- c(y, 170 + rnorm(20)) x[1] <- NA # check Outlier detection and listing ScatterPlot(x, y, NO_OUTLIERS = F) ScatterPlot(x, y, NO_OUTLIERS = F, OUTLIER = 2) ScatterPlot(x, y, NO_OUTLIERS = T, MAIN = "Example with outliers removed") # Check SPLIT x <- c(rnorm(50), rnorm(50)+5) y <- c(rnorm(50), rnorm(50)+5) Split <- factor(paste("Group", rep(LETTERS[1:2], each = 50), sep = "-")) ScatterPlot(x, y, SPLIT = Split) ScatterPlot(x, y, SPLIT = Split, SUBLINES=T) x <- c(rnorm(50), rnorm(50, 3)) y <- c(rnorm(50), rnorm(50, 3) + 5 * x[51:100]) * 2 Split <- factor(rep(LETTERS[1:2], each = 50)) ScatterPlot(x, y, SPLIT = Split, CONF.LEVEL = 0.99) ScatterPlot(x, y, SPLIT = Split, CONF.LEVEL = 0.99, SUBLINES=T, COL=c(4,6), PCH=c(19,21)) }