A matrix of scatterplots can be produced using pairs. Pairs function takes various parameters like formula, data, subset, labels, etc.
The two key parameters required to build a scatterplot matrix are –
- formula- A formula basically like ~a+b+c . Each term gives a separate variable in the pairs plots where the terms should be numerical vectors. It basically represents the series of variables used in pairs.
- data- It basically represents the dataset from which the variables have to be taken for building a scatterplot.
panels [in psych package] can be also used to create a scatter plot of matrices, with bivariate scatter plots below the diagonal, histograms on the diagonal, and the Pearson correlation above the diagonal. If lm = TRUE, linear regression fits are shown for both y by x and x by y. Correlation ellipses are also shown
Scatterplot matrix is a collection of scatterplots being organized into a matrix, and each scatterplot shows the relationship between a pair of variables. This is very useful for having a vague idea about linear correlation between variables.
Plotting Scatterplot matrices in R
Scatterplot matrix is a collection of scatterplots being organized into a matrix, and each scatterplot shows the relationship between a pair of variables. This is very useful for having a vague idea about linear correlation between variables. In creating a model, collinearity is not desired, and by inspecting the scatterplot matrix, we would have an idea of what to include into the model at the beginning. There are various methods to plot a scatterplot matrix, and this plot will introduce 6 different methods of creating the scatterplot matrix, compare their difference, and discuss their pros and cons. The example dataset being used is called Seatbelts, which is a time series data. For convenience, we also created a data frame verison of it.