forked from pygeode/pygeode.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.html
422 lines (407 loc) · 22.5 KB
/
stats.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Stats module — PyGeode 1.0 alpha documentation</title>
<link rel="stylesheet" href="_static/pygtheme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0 alpha',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="PyGeode 1.0 alpha documentation" href="index.html" />
<link rel="up" title="Reference" href="reference.html" />
<link rel="next" title="EOF Analysis" href="eof.html" />
<link rel="prev" title="Climat module" href="climat.html" />
<link href="http://fonts.googleapis.com/css?family=Ubuntu:300,300italic,regular,italic,500,500italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="eof.html" title="EOF Analysis"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="climat.html" title="Climat module"
accesskey="P">previous</a> |</li>
<li><a href="index.html">PyGeode 1.0 alpha documentation</a> »</li>
<li><a href="reference.html" accesskey="U">Reference</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="stats-module">
<h1>Stats module<a class="headerlink" href="#stats-module" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="pygeode.correlate">
<tt class="descclassname">pygeode.</tt><tt class="descname">correlate</tt><big>(</big><em>X</em>, <em>Y</em>, <em>axes=None</em>, <em>pbar=None</em><big>)</big><a class="headerlink" href="#pygeode.correlate" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes correlation between variables X and Y.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X, Y</strong> : <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<blockquote>
<div><p>Variables to correlate. Must have at least one axis in common.</p>
</div></blockquote>
<p><strong>axes</strong> : list, optional</p>
<blockquote>
<div><p>Axes over which to compute correlation; if nothing is specified, the correlation
is computed over all axes common to shared by X and Y.</p>
</div></blockquote>
<p><strong>pbar</strong> : progress bar, optional</p>
<blockquote>
<div><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>rho, p</strong> : <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<blockquote class="last">
<div><p>The correlation coefficient <span class="math">\(\rho_{XY}\)</span> and p-value, respectively.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>The coefficient <span class="math">\(\rho_{XY}\)</span> is computed following von Storch and Zwiers
1999, section 8.2.2. The p-value is the probability of finding the given
result under the hypothesis that the true correlation coefficient between X
and Y is zero. It is computed from the t-statistic given in eq (8.7), in
section 8.2.3, and assumes normally distributed quantities.</p>
</dd></dl>
<dl class="function">
<dt id="pygeode.regress">
<tt class="descclassname">pygeode.</tt><tt class="descname">regress</tt><big>(</big><em>X</em>, <em>Y</em>, <em>axes=None</em>, <em>pbar=None</em>, <em>N_fac=None</em>, <em>output='m</em>, <em>b</em>, <em>p'</em><big>)</big><a class="headerlink" href="#pygeode.regress" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes least-squares linear regression of Y against X.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X, Y</strong> : <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<blockquote>
<div><p>Variables to regress. Must have at least one axis in common.</p>
</div></blockquote>
<p><strong>axes</strong> : list, optional</p>
<blockquote>
<div><p>Axes over which to compute correlation; if nothing is specified, the correlation
is computed over all axes common to X and Y.</p>
</div></blockquote>
<p><strong>pbar</strong> : progress bar, optional</p>
<blockquote>
<div><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</div></blockquote>
<p><strong>N_fac</strong> : integer</p>
<blockquote>
<div><p>A factor by which to rescale the estimated number of degrees of freedom; the effective
number will be given by the number estimated from the dataset divided by <tt class="docutils literal"><span class="pre">N_fac</span></tt>.</p>
</div></blockquote>
<p><strong>output</strong> : string, optional</p>
<blockquote>
<div><p>A string determining which parameters are returned; see list of possible outputs
in the Returns section. The specifications must be separated by a comma. Defaults
to ‘m,b,p’.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>results</strong> : list of <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> instances.</p>
<blockquote class="last">
<div><p>The return values are specified by the <tt class="docutils literal"><span class="pre">output</span></tt> argument. A fit of the form
<span class="math">\(Y = m X + b + \epsilon\)</span> is assumed, and the following parameters
can be returned:</p>
<ul class="simple">
<li>‘m’: Linear coefficient of the regression</li>
<li>‘b’: Constant coefficient of the regression</li>
<li>‘r’: Fraction of the variance in Y explained by X (<span class="math">\(R^2\)</span>)</li>
<li>‘p’: Probability of this fit if the true linear coefficient was zero</li>
<li>‘sm’: Variance in linear coefficient</li>
<li>‘se’: Variance of residuals</li>
</ul>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>The statistics described are computed following von Storch and Zwiers 1999,
section 8.3. The p-value ‘p’ is computed using the t-statistic given in
section 8.3.8, and confidence intervals for the slope and intercept can be
computed from ‘se’ and ‘se’ (<span class="math">\(\hat{\sigma}_E\)</span> and
<span class="math">\(\hat{\sigma}_E/\sqrt{S_{XX}}\)</span> in von Storch and Zwiers, respectively).
The data is assumed to be normally distributed.</p>
</dd></dl>
<dl class="function">
<dt id="pygeode.multiple_regress">
<tt class="descclassname">pygeode.</tt><tt class="descname">multiple_regress</tt><big>(</big><em>Xs</em>, <em>Y</em>, <em>axes=None</em>, <em>pbar=None</em>, <em>N_fac=None</em>, <em>output='B</em>, <em>p'</em><big>)</big><a class="headerlink" href="#pygeode.multiple_regress" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes least-squares multiple regression of Y against variables Xs.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>Xs</strong> : list of <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> instances</p>
<blockquote>
<div><p>Variables to treat as independent regressors. Must have at least one axis
in common with each other and with Y.</p>
</div></blockquote>
<p><strong>Y</strong> : <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<blockquote>
<div><p>The dependent variable. Must have at least one axis in common with the Xs.</p>
</div></blockquote>
<p><strong>axes</strong> : list, optional</p>
<blockquote>
<div><p>Axes over which to compute correlation; if nothing is specified, the correlation
is computed over all axes common to the Xs and Y.</p>
</div></blockquote>
<p><strong>pbar</strong> : progress bar, optional</p>
<blockquote>
<div><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</div></blockquote>
<p><strong>N_fac</strong> : integer</p>
<blockquote>
<div><p>A factor by which to rescale the estimated number of degrees of freedom; the effective
number will be given by the number estimated from the dataset divided by <tt class="docutils literal"><span class="pre">N_fac</span></tt>.</p>
</div></blockquote>
<p><strong>output</strong> : string, optional</p>
<blockquote>
<div><p>A string determining which parameters are returned; see list of possible outputs
in the Returns section. The specifications must be separated by a comma. Defaults
to ‘B,p’.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>results</strong> : tuple of floats or <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> instances.</p>
<blockquote class="last">
<div><p>The return values are specified by the <tt class="docutils literal"><span class="pre">output</span></tt> argument. A fit of the form
<span class="math">\(Y = \sum_i \beta_i X_i + \epsilon\)</span> is assumed. Note that a constant term
is not included by default. The following parameters can be returned:</p>
<ul class="simple">
<li>‘B’: Linear coefficients <span class="math">\(\beta_i\)</span> of each regressor</li>
<li>‘r’: Fraction of the variance in Y explained by all Xs (<span class="math">\(R^2\)</span>)</li>
<li>‘p’: Probability of this fit if the true linear coefficient was zero for each regressor</li>
<li>‘sb’: Standard deviation of each linear coefficient</li>
<li>‘se’: Standard deviation of residuals</li>
</ul>
<p>If the regression is computed over all axes so that the result is a scalar,
the above are returned as a tuple of floats in the order specified by
<tt class="docutils literal"><span class="pre">output</span></tt>. Otherwise they are returned as <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> instances. The outputs
‘B’, ‘p’, and ‘sb’ will produce as many outputs as there are regressors.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>The statistics described are computed following von Storch and Zwiers 1999,
section 8.4. The p-value ‘p’ is computed using the t-statistic appropriate
for the multi-variate normal estimator <span class="math">\(\hat{\vec{a}}\)</span> given in section
8.4.2; note this may not be the best way to determine if a given parameter is
contributing a significant fraction to the explained variance of Y. The
variances ‘se’ and ‘sb’ are <span class="math">\(\hat{\sigma}_E\)</span> and the square root of the
diagonal elements of <span class="math">\(\hat{\sigma}^2_E (\chi^T\chi)\)</span> in von Storch and
Zwiers, respectively. The data is assumed to be normally distributed.</p>
</dd></dl>
<dl class="function">
<dt id="pygeode.difference">
<tt class="descclassname">pygeode.</tt><tt class="descname">difference</tt><big>(</big><em>X</em>, <em>Y</em>, <em>axes</em>, <em>alpha=0.05</em>, <em>Nx_fac=None</em>, <em>Ny_fac=None</em>, <em>pbar=None</em><big>)</big><a class="headerlink" href="#pygeode.difference" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the mean value and statistics of X - Y.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X, Y</strong> : <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<blockquote>
<div><p>Variables to difference. Must have at least one axis in common.</p>
</div></blockquote>
<p><strong>axes</strong> : list, optional</p>
<blockquote>
<div><p>Axes over which to compute means; if nothing is specified, the mean
is computed over all axes common to X and Y.</p>
</div></blockquote>
<p><strong>alpha</strong> : float</p>
<blockquote>
<div><p>Confidence level for which to compute confidence interval.</p>
</div></blockquote>
<p><strong>Nx_fac</strong> : integer</p>
<blockquote>
<div><p>A factor by which to rescale the estimated number of degrees of freedom of
X; the effective number will be given by the number estimated from the
dataset divided by <tt class="docutils literal"><span class="pre">Nx_fac</span></tt>.</p>
</div></blockquote>
<p><strong>Ny_fac</strong> : integer</p>
<blockquote>
<div><p>A factor by which to rescale the estimated number of degrees of freedom of
Y; the effective number will be given by the number estimated from the
dataset divided by <tt class="docutils literal"><span class="pre">Ny_fac</span></tt>.</p>
</div></blockquote>
<p><strong>pbar</strong> : progress bar, optional</p>
<blockquote>
<div><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>results</strong> : tuple or <a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><tt class="xref py py-class docutils literal"><span class="pre">Dataset</span></tt></a> instance.</p>
<blockquote class="last">
<div><p>Four quantities are computed:</p>
<ul class="simple">
<li>The difference in the means, X - Y</li>
<li>The effective number of degrees of freedom, <span class="math">\(df\)</span></li>
<li>The probability of the computed difference if the population difference was zero</li>
<li>The confidence interval of the difference at the level specified by alpha</li>
</ul>
<p>If the average is taken over all axes of X and Y resulting in a scalar,
the above values are returned as a tuple in the order given. If not, the
results are provided as <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> objects in a dataset.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#pygeode.isnonzero" title="pygeode.isnonzero"><tt class="xref py py-obj docutils literal"><span class="pre">isnonzero</span></tt></a></p>
</div>
<p class="rubric">Notes</p>
<p>The effective number of degrees of freedom is estimated using eq (6.20) of
von Storch and Zwiers 1999, in which <span class="math">\(n_X\)</span> and <span class="math">\(n_Y\)</span> are scaled by
Nx_fac and Ny_fac, respectively. This provides a means of taking into account
serial correlation in the data (see sections 6.6.7-9), but the number of effective
degrees of freedom are not calculated explicitly by this routine. The p-value and
confidence interval are computed based on the t-statistic in eq (6.19).</p>
</dd></dl>
<dl class="function">
<dt id="pygeode.isnonzero">
<tt class="descclassname">pygeode.</tt><tt class="descname">isnonzero</tt><big>(</big><em>X</em>, <em>axes</em>, <em>alpha=0.05</em>, <em>N_fac=None</em>, <em>pbar=None</em><big>)</big><a class="headerlink" href="#pygeode.isnonzero" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the mean value and statistics of X, against the hypothesis that it is 0.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>X</strong> : <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a></p>
<blockquote>
<div><p>Variable to average.</p>
</div></blockquote>
<p><strong>axes</strong> : list, optional</p>
<blockquote>
<div><p>Axes over which to compute the mean; if nothing is specified, the mean is
computed over all axes.</p>
</div></blockquote>
<p><strong>alpha</strong> : float</p>
<blockquote>
<div><p>Confidence level for which to compute confidence interval.</p>
</div></blockquote>
<p><strong>N_fac</strong> : integer</p>
<blockquote>
<div><p>A factor by which to rescale the estimated number of degrees of freedom;
the effective number will be given by the number estimated from the dataset
divided by <tt class="docutils literal"><span class="pre">N_fac</span></tt>.</p>
</div></blockquote>
<p><strong>pbar</strong> : progress bar, optional</p>
<blockquote>
<div><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>results</strong> : tuple or <a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><tt class="xref py py-class docutils literal"><span class="pre">Dataset</span></tt></a> instance.</p>
<blockquote class="last">
<div><p>Three quantities are computed:</p>
<ul class="simple">
<li>The mean value of X</li>
<li>The probability of the computed value if the population mean was zero</li>
<li>The confidence interval of the mean at the level specified by alpha</li>
</ul>
<p>If the average is taken over all axes of X resulting in a scalar,
the above values are returned as a tuple in the order given. If not, the
results are provided as <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><tt class="xref py py-class docutils literal"><span class="pre">Var</span></tt></a> objects in a dataset.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#pygeode.difference" title="pygeode.difference"><tt class="xref py py-obj docutils literal"><span class="pre">difference</span></tt></a></p>
</div>
<p class="rubric">Notes</p>
<p>The number of effective degrees of freedom can be scaled as in <a class="reference internal" href="#pygeode.difference" title="pygeode.difference"><tt class="xref py py-meth docutils literal"><span class="pre">difference()</span></tt></a>.
The p-value and confidence interval are computed for the t-statistic defined in
eq (6.61) of von Storch and Zwiers 1999.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="climat.html"
title="previous chapter">Climat module</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="eof.html"
title="next chapter">EOF Analysis</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/stats.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="eof.html" title="EOF Analysis"
>next</a> |</li>
<li class="right" >
<a href="climat.html" title="Climat module"
>previous</a> |</li>
<li><a href="index.html">PyGeode 1.0 alpha documentation</a> »</li>
<li><a href="reference.html" >Reference</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2013, Mike Neish, Peter Hitchcock.
Last updated on Sep 13, 2015.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>