Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 185

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Correlation and Regression Analysis - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Statistics.html#Statistics" title="Statistics">
<link rel="prev" href="Statistical-Plots.html#Statistical-Plots" title="Statistical Plots">
<link rel="next" href="Distributions.html#Distributions" title="Distributions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Correlation-and-Regression-Analysis"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Distributions.html#Distributions">Distributions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Statistical-Plots.html#Statistical-Plots">Statistical Plots</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Statistics.html#Statistics">Statistics</a>
<hr>
</div>

<h3 class="section">26.4 Correlation and Regression Analysis</h3>

<!-- FIXME: Need Intro Here -->
<!-- cov scripts/statistics/base/cov.m -->
<p><a name="doc_002dcov"></a>

<div class="defun">
&mdash; Function File:  <b>cov</b> (<var>x</var>)<var><a name="index-cov-2470"></a></var><br>
&mdash; Function File:  <b>cov</b> (<var>x, opt</var>)<var><a name="index-cov-2471"></a></var><br>
&mdash; Function File:  <b>cov</b> (<var>x, y</var>)<var><a name="index-cov-2472"></a></var><br>
&mdash; Function File:  <b>cov</b> (<var>x, y, opt</var>)<var><a name="index-cov-2473"></a></var><br>
<blockquote><p>Compute the covariance matrix.

        <p>If each row of <var>x</var> and <var>y</var> is an observation, and each column is
a variable, then the (<var>i</var>,&nbsp;<var>j</var>)-th<!-- /@w --> entry of
<code>cov (</code><var>x</var><code>, </code><var>y</var><code>)</code> is the covariance between the <var>i</var>-th
variable in <var>x</var> and the <var>j</var>-th variable in <var>y</var>.

     <pre class="example">          cov (x) = 1/N-1 * SUM_i (x(i) - mean(x)) * (y(i) - mean(y))
</pre>
        <p>If called with one argument, compute <code>cov (</code><var>x</var><code>, </code><var>x</var><code>)</code>, the
covariance between the columns of <var>x</var>.

        <p>The argument <var>opt</var> determines the type of normalization to use. 
Valid values are

          <dl>
<dt>0:<dd>  normalize with N-1, provides the best unbiased estimator of the
covariance [default]

          <br><dt>1:<dd>  normalize with N, this provides the second moment around the mean
</dl>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dcorr.html#doc_002dcorr">corr</a>. 
</p></blockquote></div>

<!-- corr scripts/statistics/base/corr.m -->
   <p><a name="doc_002dcorr"></a>

<div class="defun">
&mdash; Function File:  <b>corr</b> (<var>x</var>)<var><a name="index-corr-2474"></a></var><br>
&mdash; Function File:  <b>corr</b> (<var>x, y</var>)<var><a name="index-corr-2475"></a></var><br>
<blockquote><p>Compute matrix of correlation coefficients.

        <p>If each row of <var>x</var> and <var>y</var> is an observation and each column is
a variable, then the (<var>i</var>,&nbsp;<var>j</var>)-th<!-- /@w --> entry of
<code>corr (</code><var>x</var><code>, </code><var>y</var><code>)</code> is the correlation between the
<var>i</var>-th variable in <var>x</var> and the <var>j</var>-th variable in <var>y</var>.

     <pre class="example">          corr (x,y) = cov (x,y) / (std (x) * std (y))
</pre>
        <p>If called with one argument, compute <code>corr (</code><var>x</var><code>, </code><var>x</var><code>)</code>,
the correlation between the columns of <var>x</var>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dcov.html#doc_002dcov">cov</a>. 
</p></blockquote></div>

<!-- spearman scripts/statistics/base/spearman.m -->
   <p><a name="doc_002dspearman"></a>

<div class="defun">
&mdash; Function File:  <b>spearman</b> (<var>x</var>)<var><a name="index-spearman-2476"></a></var><br>
&mdash; Function File:  <b>spearman</b> (<var>x, y</var>)<var><a name="index-spearman-2477"></a></var><br>
<blockquote><p><a name="index-Spearman_0027s-Rho-2478"></a>Compute Spearman's rank correlation coefficient <var>rho</var>.

        <p>For two data vectors <var>x</var> and <var>y</var>, Spearman's <var>rho</var> is the
correlation coefficient of the ranks of <var>x</var> and <var>y</var>.

        <p>If <var>x</var> and <var>y</var> are drawn from independent distributions,
<var>rho</var> has zero mean and variance <code>1 / (n - 1)</code>, and is
asymptotically normally distributed.

        <p><code>spearman (</code><var>x</var><code>)</code> is equivalent to <code>spearman (</code><var>x</var><code>,
</code><var>x</var><code>)</code>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dranks.html#doc_002dranks">ranks</a>, <a href="doc_002dkendall.html#doc_002dkendall">kendall</a>. 
</p></blockquote></div>

<!-- kendall scripts/statistics/base/kendall.m -->
   <p><a name="doc_002dkendall"></a>

<div class="defun">
&mdash; Function File:  <b>kendall</b> (<var>x</var>)<var><a name="index-kendall-2479"></a></var><br>
&mdash; Function File:  <b>kendall</b> (<var>x, y</var>)<var><a name="index-kendall-2480"></a></var><br>
<blockquote><p><a name="index-Kendall_0027s-Tau-2481"></a>Compute Kendall's <var>tau</var>.

        <p>For two data vectors <var>x</var>, <var>y</var> of common length <var>n</var>,
Kendall's <var>tau</var> is the correlation of the signs of all rank
differences of <var>x</var> and <var>y</var>; i.e., if both <var>x</var> and
<var>y</var> have distinct entries, then

     <pre class="example">                   1
          tau = -------   SUM sign (q(i) - q(j)) * sign (r(i) - r(j))
                n (n-1)   i,j
</pre>
        <p class="noindent">in which the
<var>q</var>(<var>i</var>) and <var>r</var>(<var>i</var>)
are the ranks of <var>x</var> and <var>y</var>, respectively.

        <p>If <var>x</var> and <var>y</var> are drawn from independent distributions,
Kendall's <var>tau</var> is asymptotically normal with mean 0 and variance
<code>(2 * (2</code><var>n</var><code>+5)) / (9 * </code><var>n</var><code> * (</code><var>n</var><code>-1))</code>.

        <p><code>kendall (</code><var>x</var><code>)</code> is equivalent to <code>kendall (</code><var>x</var><code>,
</code><var>x</var><code>)</code>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dranks.html#doc_002dranks">ranks</a>, <a href="doc_002dspearman.html#doc_002dspearman">spearman</a>. 
</p></blockquote></div>

<!-- FIXME: Need discussion of ols & gls and references to them in optim.txi -->
<!-- logistic_regression scripts/statistics/models/logistic_regression.m -->
   <p><a name="doc_002dlogistic_005fregression"></a>

<div class="defun">
&mdash; Function File: [<var>theta</var>, <var>beta</var>, <var>dev</var>, <var>dl</var>, <var>d2l</var>, <var>p</var>] = <b>logistic_regression</b> (<var>y, x, print, theta, beta</var>)<var><a name="index-logistic_005fregression-2482"></a></var><br>
<blockquote><p>Perform ordinal logistic regression.

        <p>Suppose <var>y</var> takes values in <var>k</var> ordered categories, and let
<code>gamma_i (</code><var>x</var><code>)</code> be the cumulative probability that <var>y</var>
falls in one of the first <var>i</var> categories given the covariate
<var>x</var>.  Then

     <pre class="example">          [theta, beta] = logistic_regression (y, x)
</pre>
        <p class="noindent">fits the model

     <pre class="example">          logit (gamma_i (x)) = theta_i - beta' * x,   i = 1 ... k-1
</pre>
        <p>The number of ordinal categories, <var>k</var>, is taken to be the number
of distinct values of <code>round (</code><var>y</var><code>)</code>.  If <var>k</var> equals 2,
<var>y</var> is binary and the model is ordinary logistic regression.  The
matrix <var>x</var> is assumed to have full column rank.

        <p>Given <var>y</var> only, <code>theta = logistic_regression (y)</code>
fits the model with baseline logit odds only.

        <p>The full form is

     <pre class="example">          [theta, beta, dev, dl, d2l, gamma]
             = logistic_regression (y, x, print, theta, beta)
</pre>
        <p class="noindent">in which all output arguments and all input arguments except <var>y</var>
are optional.

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

        <p>The returned value <var>dev</var> holds minus twice the log-likelihood.

        <p>The returned values <var>dl</var> and <var>d2l</var> are the vector of first
and the matrix of second derivatives of the log-likelihood with
respect to <var>theta</var> and <var>beta</var>.

        <p><var>p</var> holds estimates for the conditional distribution of <var>y</var>
given <var>x</var>. 
</p></blockquote></div>

   </body></html>