4. Bivariate data analysis

4.1 Scatterplot (download)

Plot a scatterplot of two quantitative variables.

Variables to customize:

- varlistindex <- c(5,6) # index of the two GTD frame quantitative variables
- titleGRAPH <- "Diagrama de dispersão" # title of the plot
- titleUNITS <- c("ppm","ppm") # units of the variables to add to axis legends
4.2 Scatterplot matrix (download)

Plot a matrix of scatterplots of several quantitative variables. Histograms are plotted in the diagonal of the matrix.

Variables to customize:

- varlistindex <- c(5:11) # indexes of the several GTD frame quantitative variables
- nclassesHIST <- 10 # number of classes for the histograms in the diagonal
- sizePOINTS <- 0.8 # size of the points in the plots
- smooth=FALSE # option (TRUE or FALSE) to interpolate density of points in each plot
- titleGRAPH <- "Matriz de diagramas de dispersão" # title of the graphic

4.3 Contingency table and 3D histogram of two quantitative variables (download)

Compute a contingency table for equal size intervals of two quantitative variables (absolute frequencies) and plot a 3D histogram.

Variables to customize

- varlistindex <- c(5,6) # index of the two GTD frame quantitative variables
- nclasses <- c(10,12) # number of classses of the two selected variables
- titleUNITS <- c("ppm","ppm") # units of the variables to add to axis legends
- spaceBARS <- 0.5 # space between 3D bars
- angles <- c(45,45) # azimuth and dip angle of the graphic, change point of view
- titleGRAPH <- "Histograma 3D" # title of the graphic

4.4 QQ plot (download)

Plot a QQ plot of two quantitative variables.

Variables to customize

- varlistindex <- c(8,10) # index of the two GTD frame quantitative variables
- p_spacing <- 0.01 # spacing of the percentiles to build thew QQ plot
- titleUNITS <- c("ppm","ppm") # units of the variables to add to axis legends
- plotlineminmax <- FALSE # add a reference line between the first and the last point  
- titleGRAPH <- "Gráfico QQ" # title of the graphic

4.5 Matrix of QQ plots (download)

Plot a matrix of QQ plots of several quantitative variables.

Variables to customize:

- varlistindex <- c(5:11) # indexes of the GTD frame quantitative variables
- ndecimals <- 3 # number of decimal places 

4.6 Matrices of covariance, Pearson and Spearman correlation and diferences (download)

For a set of quantitative variables, compute and display a matrix of covariance, a matrix of correlations (Pearson in the lower part and Spearman in the upper part) and a matrix of differences between Pearson and Spearman correlation coeficients.

Variables to customize:

- varlistindex <- c(5:11) # indexes of the GTD frame quantitative variables
- ndecimals <- 3 # number of decimal places

4.7 Simple linear regression (download)

Fit a linear regression (Y=aX+b) between two quantitative variables (left graphic) and display equation and R2, plot residuals vs the primary variable of the regression (central graphic) and plot residuals vs a normal distribution law (informal test for residuals normality).

Variables to customize:

- varlistindex <- c(9,11) # index of the two GTD frame quantitative variables
- titleUNITS <- c("ppm","ppm") # units of the variables to add to axis legends

4.8 Contingency table and 3D histogram of two qualitative variables  (download)

Compute a contingency table for two qualitative variables (relative frequencies) and plot a 3D histogram.

Variables to customize

- varlistindex <- c(5,6) # index of the two GTD frame qualitative variables
- ndecimals <- 3 # number of decimal places
- spaceBARS <- 0.25 # space between 3D bars
- angles <- c(225,45) # azimuth and dip angle of the graphic, change point of view
- titleGRAPH <- "Histograma 3D" # title of the graphic

4.9 Mosaic diagram (download)

Plot a mosaic diagram of two qualitative variables.

Variables to customize

- varlistindex <- c(3,4) # index of the two GTD frame quantitative variables. Different order of the qualitative variables generate different graphics.
- ndecimals=5 # number of decimals
- titleGRAPH <- "Gráfico Mosaico" # title of the graphic

4.10 Conditional cumulative histograms (download)

Plot cumulative histograms of several quantitative variables conditional to the modalities of a qualitative variable.

Variables to customize:

- varsepindex <- 4 # index of the qualitative GTD frame variable
- varlistindex <- c(5:11) # indexes of the several GTD frame quantitative variables
- titleGRAPH <- "Função de distribuição cumulativa condicional" # title of the plot
- par(mfrow=c(3,3),mar=c(3.5, 3.5, 2, 1), oma=c(0,0,2,0), mgp=c(2.25, 0.8, 0)) # options to subdivide the graphical window, the numbers 3,3 represents rows and columns of the matrix of graphics

4.11 Conditional box-plots (download)

Plot box-plots of several quantitative variables conditional to the modalities of a qualitative variable.

Variables to customize:

- varsepindex <- 4 # index of the qualitative GTD frame variable
- varlistindex <- c(5:11) # indexes of the several GTD frame quantitative variables
- plotlog=FALSE # (TRUE or FALSE) use or not log scale
- titleGRAPH <- "Box-plots condicionais" # title of the plot- par(mfrow=c(3,3),mar=c(3.5, 3.5, 2, 1), oma=c(0,0,2,0), mgp=c(2.25, 0.8, 0)) # options to subdivide the graphical window, the numbers 3,3 represents rows and columns of the matrix of graphics

4.12 Conditional basic statistics (download)

Compute conditional basic statistics (mean, standard deviation and skewness) of a quantitative variable conditional to the modalities of a qualitative variable.

Variables to customize

- varsepvarindex <- 4 # index of the qualitative GTD frame variable
- varlistindex <- 5 # index of the quantitative GTD frame variable
- ndecimals <- 5 # number of decimal places