corrplot
Plot variable correlations
Syntax
Description
[
plots Pearson's correlation coefficients between all pairs of variables in the matrix of
time series data R
,PValue
]
= corrplot(X
)X
. The plot is a
numVars
-by-numVars
grid, where
numVars
is the number of time series variables (columns) in
X
, including the following subplots:
Each off diagonal subplot contains a scatterplot of a pair of variables with a least-squares reference line, the slope of which is equal to the displayed correlation coefficient.
Each diagonal subplot contains the distribution of a variable as a histogram.
Also, the function returns the correlation matrix in the plots
R
and a matrix of p-values
PValue
for testing the null hypothesis that each pair of
coefficients is not correlated against the alternative hypothesis of a nonzero
correlation.
[
plots the Pearson's correlation coefficients between all pairs of variables in the table
or timetable R
,PValue
] = corrplot(Tbl
)Tbl
, and also returns tables for the correlation matrix
R
and matrix of p-values
PValue
.
To select a subset of variables in Tbl
, for which to plot the
correlation matrix, use the DataVariables
name-value argument.
[___] = corrplot(___,
specifies options using one or more name-value arguments in
addition to any of the input argument combinations in previous syntaxes.
Name=Value
)corrplot
returns the output argument combination for the
corresponding input arguments. For example,
corrplot(Tbl,Type="Spearman",TestR="on",DataVariables=1:5)
computes
Spearman’s rank correlation coefficient for the first 5 variables of the table
Tbl
and tests for significant correlation coefficients.
corrplot(___)
plots the correlation matrix.
corrplot(
plots on the axes specified by ax
,___)ax
instead
of the current axes (gca
). ax
can precede any of the input
argument combinations in the previous syntaxes.
[___,
plots the diagnostics of the input series and additionally returns handles to plotted
graphics objects H
]
= corrplot(___)H
. Use elements of H
to modify
properties of the plot after you create it.
Examples
Input Arguments
Output Arguments
Tips
The setting
Rows="pairwise"
(the default) can return a correlation matrix that is not positive definite. The settingRows="complete"
returns a positive-definite matrix, but, in general, the estimates are based on fewer observations.
Algorithms
corrplot
computes p-values for Pearson’s correlation by transforming the correlation to create a t-statistic withnumObs
– 2 degrees of freedom. The transformation is exact when the input time series data is normal.corrplot
computes p-values for Kendall’s and Spearman’s rank correlations by using either the exact permutation distributions (for small sample sizes) or large-sample approximations.corrplot
computes p-values for two-tailed tests by doubling the more significant of the two one-tailed p-values.