Compare the right-hand display with the one obtained with the chi-square
distance. Are the species groups consistent?
3.4.3 R Mode: Quantitative and Ordinal Data (Other than Species
Abundances)
To compare dimensionally homogeneous quantitative variables, one can use either
the covariance or Pearson’s r correlation coefficient. Note, however, that these
indices are linear, so that they may perform poorly to detect monotonic but nonlinear
relationships among variables. If the variables are not dimensionally homogeneous,
Pearson’s r must be preferred to the covariance, since the correlation r is actually the
covariance computed on standardized variables.
Comparison among ordinal variables, or among quantitative variables that may
be monotonically but not linearly related, can be achieved using rank correlation
coefficients like Spearman’s ρ (rho) or Kendall’s τ (tau).
Here are some examples based on the fish environmental data env. The function
cor() (stats package) computes correlations among the columns of the
untransposed matrix, i.e., the original matrix where the variables are in columns.
First example: Pearson r (Fig. 3.3):
# Pearson r linear correlation among environmental variables
env.pearson <- cor(env) # default method = "pearson"
round(env.pearson, 2)
# Reorder the variables prior to plotting
env.o <- order.single(env.pearson)
# pairs() is a function to plot a matrix of bivariate scatter
# plots. panelutils.R is a set of functions that add useful
# features to pairs().
pairs(env[ ,env.o],
lower.panel = panel.smooth,
upper.panel = panel.cor,
diag.panel = panel.hist,
main = "Pearson Correlation Matrix")
Identify the variables correlated with variable 'dfs' (the distance from the source).
What story does that tell?
3.4 R Mode: Computing Dependence Matrices Among Variables
53
distance. Are the species groups consistent?
3.4.3 R Mode: Quantitative and Ordinal Data (Other than Species
Abundances)
To compare dimensionally homogeneous quantitative variables, one can use either
the covariance or Pearson’s r correlation coefficient. Note, however, that these
indices are linear, so that they may perform poorly to detect monotonic but nonlinear
relationships among variables. If the variables are not dimensionally homogeneous,
Pearson’s r must be preferred to the covariance, since the correlation r is actually the
covariance computed on standardized variables.
Comparison among ordinal variables, or among quantitative variables that may
be monotonically but not linearly related, can be achieved using rank correlation
coefficients like Spearman’s ρ (rho) or Kendall’s τ (tau).
Here are some examples based on the fish environmental data env. The function
cor() (stats package) computes correlations among the columns of the
untransposed matrix, i.e., the original matrix where the variables are in columns.
First example: Pearson r (Fig. 3.3):
# Pearson r linear correlation among environmental variables
env.pearson <- cor(env) # default method = "pearson"
round(env.pearson, 2)
# Reorder the variables prior to plotting
env.o <- order.single(env.pearson)
# pairs() is a function to plot a matrix of bivariate scatter
# plots. panelutils.R is a set of functions that add useful
# features to pairs().
pairs(env[ ,env.o],
lower.panel = panel.smooth,
upper.panel = panel.cor,
diag.panel = panel.hist,
main = "Pearson Correlation Matrix")
Identify the variables correlated with variable 'dfs' (the distance from the source).
What story does that tell?
3.4 R Mode: Computing Dependence Matrices Among Variables
53
