Next: Distributions, Previous: Statistical Plots, Up: Statistics [Contents][Index]

- Function File:
**cov***(*`x`) - Function File:
**cov***(*`x`,`opt`) - Function File:
**cov***(*`x`,`y`) - Function File:
**cov***(*`x`,`y`,`opt`) Compute the covariance matrix.

If each row of

`x`and`y`is an observation, and each column is a variable, then the (`i`,`j`)-th entry of`cov (`

is the covariance between the`x`,`y`)`i`-th variable in`x`and the`j`-th variable in`y`.cov (x) = 1/N-1 * SUM_i (x(i) - mean(x)) * (y(i) - mean(y))

If called with one argument, compute

`cov (`

, the covariance between the columns of`x`,`x`)`x`.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 computes the covariance matrix. For two inputs, however, MATLAB will calculate

`cov (`

whenever the number of elements in`x`(:),`y`(:))`x`and`y`are equal. This will result in a scalar rather than a matrix output. Code relying on this odd definition will need to be changed when running in Octave.**See also:**corr.

- Function File:
**corr***(*`x`) - Function File:
**corr***(*`x`,`y`) Compute matrix of correlation coefficients.

If each row of

`x`and`y`is an observation and each column is a variable, then the (`i`,`j`)-th entry of`corr (`

is the correlation between the`x`,`y`)`i`-th variable in`x`and the`j`-th variable in`y`.corr (x,y) = cov (x,y) / (std (x) * std (y))

If called with one argument, compute

`corr (`

, the correlation between the columns of`x`,`x`)`x`.**See also:**cov.

- Function File:
**spearman***(*`x`) - Function File:
**spearman***(*`x`,`y`) -
Compute Spearman’s rank correlation coefficient

`rho`.For two data vectors

`x`and`y`, Spearman’s`rho`is the correlation coefficient of the ranks of`x`and`y`.If

`x`and`y`are drawn from independent distributions,`rho`has zero mean and variance`1 / (n - 1)`

, and is asymptotically normally distributed.`spearman (`

is equivalent to`x`)`spearman (`

.`x`,`x`)

- Function File:
**kendall***(*`x`) - Function File:
**kendall***(*`x`,`y`) -
Compute Kendall’s

`tau`.For two data vectors

`x`,`y`of common length`n`, Kendall’s`tau`is the correlation of the signs of all rank differences of`x`and`y`; i.e., if both`x`and`y`have distinct entries, then1 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`x`and`y`, respectively.If

`x`and`y`are drawn from independent distributions, Kendall’s`tau`is asymptotically normal with mean 0 and variance`(2 * (2`

.`n`+5)) / (9 *`n`* (`n`-1))`kendall (`

is equivalent to`x`)`kendall (`

.`x`,`x`)

- Function File:
*[*`theta`,`beta`,`dev`,`dl`,`d2l`,`p`] =**logistic_regression***(*`y`,`x`,`print`,`theta`,`beta`) Perform ordinal logistic regression.

Suppose

`y`takes values in`k`ordered categories, and let`gamma_i (`

be the cumulative probability that`x`)`y`falls in one of the first`i`categories given the covariate`x`. Then[theta, beta] = logistic_regression (y, x)

fits the model

logit (gamma_i (x)) = theta_i - beta' * x, i = 1 … k-1

The number of ordinal categories,

`k`, is taken to be the number of distinct values of`round (`

. If`y`)`k`equals 2,`y`is binary and the model is ordinary logistic regression. The matrix`x`is assumed to have full column rank.Given

`y`only,`theta = logistic_regression (y)`

fits the model with baseline logit odds only.The full form is

[theta, beta, dev, dl, d2l, gamma] = logistic_regression (y, x, print, theta, beta)

in which all output arguments and all input arguments except

`y`are optional.Setting

`print`to 1 requests summary information about the fitted model to be displayed. Setting`print`to 2 requests information about convergence at each iteration. Other values request no information to be displayed. The input arguments`theta`and`beta`give initial estimates for`theta`and`beta`.The returned value

`dev`holds minus twice the log-likelihood.The returned values

`dl`and`d2l`are the vector of first and the matrix of second derivatives of the log-likelihood with respect to`theta`and`beta`.`p`holds estimates for the conditional distribution of`y`given`x`.

Next: Distributions, Previous: Statistical Plots, Up: Statistics [Contents][Index]