다음: , 이전: , 상위 문서: Statistics   [차례][찾아보기]


26.4 Correlation and Regression Analysis

cov (가로)
cov (가로, opt)
cov (가로, 세로)
cov (가로, 세로, opt)

Compute the covariance matrix.

If each row of 가로 and 세로 is an observation, and each column is a variable, then the (ij)-th entry of cov (가로, 세로) is the covariance between the i-th variable in 가로 and the j-th variable in 세로.

cov (가로) = 1/(N-1) * SUM_i (가로(i) - mean(가로)) * (세로(i) - mean(세로))

where N is the length of the 가로 and 세로 vectors.

If called with one argument, compute cov (가로, 가로), the covariance between the columns of 가로.

The argument opt determines the type of normalization to use. Valid values are

0:

normalize with N-1, provides the best unbiased estimator of the covariance [default]

1:

normalize with N, this provides the second moment around the mean

Compatibility Note:: Octave always treats rows of 가로 and 세로 as multivariate random variables. For two inputs, however, 매트랩 treats 가로 and 세로 as two univariate distributions regardless of their shapes, and will calculate cov ([가로(:), 세로(:)]) whenever the number of elements in 가로 and 세로 are equal. This will result in a 2x2 matrix. Code relying on 매트랩’s definition will need to be changed when running in Octave.

같이 보기: corr.

corr (가로)
corr (가로, 세로)

Compute matrix of correlation coefficients.

If each row of 가로 and 세로 is an observation and each column is a variable, then the (ij)-th entry of corr (가로, 세로) is the correlation between the i-th variable in 가로 and the j-th variable in 세로.

corr (가로,세로) = cov (가로,세로) / (std (가로) * std (세로))

If called with one argument, compute corr (가로, 가로), the correlation between the columns of 가로.

같이 보기: cov.

r = corrcoef (가로)
r = corrcoef (가로, 세로)
r = corrcoef (…, param, , …)
[r, p] = corrcoef (…)
[r, p, lci, hci] = corrcoef (…)

Compute a matrix of correlation coefficients.

가로 is an array where each column contains a variable and each row is an observation.

If a second input 세로 (of the same size as 가로) is given then calculate the correlation coefficients between 가로 and 세로.

param, are optional pairs of parameters and values which modify the calculation. Valid options are:

"alpha"

Confidence level used for the bounds of the confidence interval, lci and hci. Default is 0.05, i.e., 95% confidence interval.

"rows"

Determine processing of NaN values. Acceptable values are "all", "complete", and "pairwise". Default is "all". With "complete", only the rows without NaN values are considered. With "pairwise", the selection of NaN-free rows is made for each pair of variables.

Output r is a matrix of Pearson’s product moment correlation coefficients for each pair of variables.

Output p is a matrix of pair-wise p-values testing for the null hypothesis of a correlation coefficient of zero.

Outputs lci and hci are matrices containing, respectively, the lower and higher bounds of the 95% confidence interval of each correlation coefficient.

같이 보기: corr, cov.

spearman (가로)
spearman (가로, 세로)

Compute Spearman’s rank correlation coefficient rho.

For two data vectors 가로 and 세로, Spearman’s rho is the correlation coefficient of the ranks of 가로 and 세로.

If 가로 and 세로 are drawn from independent distributions, rho has zero mean and variance 1 / (N - 1), where N is the length of the 가로 and 세로 vectors, and is asymptotically normally distributed.

spearman (가로) is equivalent to spearman (가로, 가로).

같이 보기: ranks, kendall.

kendall (가로)
kendall (가로, 세로)

Compute Kendall’s tau.

For two data vectors 가로, 세로 of common length N, Kendall’s tau is the correlation of the signs of all rank differences of 가로 and 세로; i.e., if both 가로 and 세로 have distinct entries, then

         1
tau = -------   SUM sign (q(i) - q(j)) * sign (r(i) - r(j))
      N (N-1)   i,j

in which the q(i) and r(i) are the ranks of 가로 and 세로, respectively.

If 가로 and 세로 are drawn from independent distributions, Kendall’s tau is asymptotically normal with mean 0 and variance (2 * (2N+5)) / (9 * N * (N-1)).

kendall (가로) is equivalent to kendall (가로, 가로).

같이 보기: ranks, spearman.


다음: , 이전: , 상위 문서: Statistics   [차례][찾아보기]