Linear Correlation in MATLAB

Материал готовится, пожалуйста, возвращайтесь позднее

Introduction

Correlation quantifies the strength of a linear relationship between two variables. When there is no correlation between two variables, then there is no tendency for the values of the variables to increase or decrease in tandem. Two variables that are uncorrelated are not necessarily independent, however, because they might have a nonlinear relationship.

You can use linear correlation to investigate whether a linear relationship exists between variables without having to assume or fit a specific model to your data. Two variables that have a small or no linear correlation might have a strong nonlinear relationship. However, calculating linear correlation before fitting a model is a useful way to identify variables that have a simple relationship. Another way to explore how variables are related is to make scatter plots of your data.

Covariance quantifies the strength of a linear relationship between two variables in units relative to their variances. Correlations are standardized covariances, giving a dimensionless quantity that measures the degree of a linear relationship, separate from the scale of either variable.

The following three MATLAB® functions compute sample correlation coefficients and covariance. These sample coefficients are estimates of the true covariance and correlation coefficients of the population from which the data sample is drawn.

Here, s2ij is the sample covariance between column i and column j of the data. Because the count matrix contains three columns, the covariance matrix is 3-by-3. Note: In the special case when a vector is the argument of cov, the function returns the variance.

Correlation Coefficients

The MATLAB function corrcoef produces a matrix of sample correlation coefficients for a data matrix (where each column represents a separate quantity). The correlation coefficients range from -1 to 1, where •

Values close to 1 indicate that there is a positive linear relationship between the data columns. •

Values close to -1 indicate that one column of data has a negative linear relationship to another column of data (anticorrelation). •