-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstats.html
418 lines (400 loc) · 35.6 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Stats module — PyGeode 1.4.1-rc2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/pygtheme.css" />
<link rel="stylesheet" type="text/css" href="_static/plot_directive.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-binder.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-dataframe.css" />
<link rel="stylesheet" type="text/css" href="_static/sg_gallery-rendered-html.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="shortcut icon" href="_static/pygeode_icon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.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="header" role="banner"><img class="logo" src="_static/pygeode_logo.png" width=79px alt="Logo"/>
<h1 class="heading"><a href="index.html">
<span>PyGeode 1.4.1-rc2 documentation</span></a></h1>
<h2 class="heading"><span>Stats module</span></h2>
</div>
<div class="topnav" role="navigation" aria-label="top navigation">
<p>
«  <a href="climat.html">Climat module</a>
  ::  
<a class="uplink" href="reference.html">Reference</a>
  ::  
<a class="uplink" href="tutorial.html">Tutorial</a>
  ::  
<a class="uplink" href="gallery/index.html">Gallery</a>
  ::  
<a href="eof.html">EOF Analysis</a>  »
</p>
</div>
<div class="content">
<div class="section" id="stats-module">
<h1>Stats module<a class="headerlink" href="#stats-module" title="Permalink to this headline">¶</a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="pygeode.correlate">
<span class="sig-prename descclassname"><span class="pre">pygeode.</span></span><span class="sig-name descname"><span class="pre">correlate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'r,p'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/stats.html#correlate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pygeode.correlate" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes Pearson correlation coefficient between variables X and Y.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>X, Y</strong><span class="classifier"><a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a></span></dt><dd><p>Variables to correlate. Must have at least one axis in common.</p>
</dd>
<dt><strong>axes</strong><span class="classifier">list, optional</span></dt><dd><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>
</dd>
<dt><strong>output</strong><span class="classifier">string, optional</span></dt><dd><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 ‘r,p’.</p>
</dd>
<dt><strong>pbar</strong><span class="classifier">progress bar, optional</span></dt><dd><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>results</strong><span class="classifier"><a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dataset</span></code></a></span></dt><dd><p>The names of the variables match the output request string (i.e. if <code class="docutils literal notranslate"><span class="pre">ds</span></code>
is the returned dataset, the correlation coefficient can be obtained
through <code class="docutils literal notranslate"><span class="pre">ds.r2</span></code>).</p>
<ul class="simple">
<li><p>‘r’: The Pearson correlation coefficient <span class="math notranslate nohighlight">\(\rho_{XY}\)</span></p></li>
<li><p>‘r2’: The coefficient of determination <span class="math notranslate nohighlight">\(\rho^2_{XY}\)</span></p></li>
<li><p>‘p’: The p-value; see notes.</p></li>
</ul>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>The coefficient <span class="math notranslate nohighlight">\(\rho_{XY}\)</span> is computed following von Storch and Zwiers
1999, section 8.2.2. The p-value is the probability of finding a correlation
coeefficient of equal or greater magnitude (two-sided) to 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="py function">
<dt class="sig sig-object py" id="pygeode.regress">
<span class="sig-prename descclassname"><span class="pre">pygeode.</span></span><span class="sig-name descname"><span class="pre">regress</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">N_fac</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'m,b,p'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/stats.html#regress"><span class="viewcode-link"><span class="pre">[source]</span></span></a><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>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>X, Y</strong><span class="classifier"><a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a></span></dt><dd><p>Variables to regress. Must have at least one axis in common.</p>
</dd>
<dt><strong>axes</strong><span class="classifier">list, optional</span></dt><dd><p>Axes over which to compute correlation; if nothing is specified, the correlation
is computed over all axes common to X and Y.</p>
</dd>
<dt><strong>N_fac</strong><span class="classifier">integer</span></dt><dd><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 <code class="docutils literal notranslate"><span class="pre">N_fac</span></code>.</p>
</dd>
<dt><strong>output</strong><span class="classifier">string, optional</span></dt><dd><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>
</dd>
<dt><strong>pbar</strong><span class="classifier">progress bar, optional</span></dt><dd><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>results</strong><span class="classifier"><a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dataset</span></code></a></span></dt><dd><p>The returned variables are specified by the <code class="docutils literal notranslate"><span class="pre">output</span></code> argument. The names of the
variables match the output request string (i.e. if <code class="docutils literal notranslate"><span class="pre">ds</span></code> is the returned dataset, the
linear coefficient of the regression can be obtained by <code class="docutils literal notranslate"><span class="pre">ds.m</span></code>).</p>
<p>A fit of the form <span class="math notranslate nohighlight">\(Y = m X + b + \epsilon\)</span> is assumed, and the
following parameters can be returned:</p>
<ul class="simple">
<li><p>‘m’: Linear coefficient of the regression</p></li>
<li><p>‘b’: Constant coefficient of the regression</p></li>
<li><p>‘r2’: Fraction of the variance in Y explained by X (<span class="math notranslate nohighlight">\(R^2\)</span>)</p></li>
<li><p>‘p’: Probability of this fit under null hypothesis that true linear coefficient is zero</p></li>
<li><p>‘sm’: Standard deviation of linear coefficient estimate (<span class="math notranslate nohighlight">\(\hat{\sigma}_E/\sqrt{S_{XX}}\)</span>)</p></li>
<li><p>‘se’: Standard deviation of residuals (<span class="math notranslate nohighlight">\(\hat{\sigma}_E\)</span>)</p></li>
</ul>
</dd>
</dl>
</dd>
</dl>
<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 ‘sm’ or ‘se’. The data is assumed to be normally
distributed.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="pygeode.multiple_regress">
<span class="sig-prename descclassname"><span class="pre">pygeode.</span></span><span class="sig-name descname"><span class="pre">multiple_regress</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">Xs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">N_fac</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'B,p'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/stats.html#multiple_regress"><span class="viewcode-link"><span class="pre">[source]</span></span></a><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>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>Xs</strong><span class="classifier">list of <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a> instances</span></dt><dd><p>Variables to treat as independent regressors. Must have at least one axis
in common with each other and with Y.</p>
</dd>
<dt><strong>Y</strong><span class="classifier"><a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a></span></dt><dd><p>The dependent variable. Must have at least one axis in common with the Xs.</p>
</dd>
<dt><strong>axes</strong><span class="classifier">list, optional</span></dt><dd><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>
</dd>
<dt><strong>N_fac</strong><span class="classifier">integer</span></dt><dd><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 <code class="docutils literal notranslate"><span class="pre">N_fac</span></code>.</p>
</dd>
<dt><strong>output</strong><span class="classifier">string, optional</span></dt><dd><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>
</dd>
<dt><strong>pbar</strong><span class="classifier">progress bar, optional</span></dt><dd><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>results</strong><span class="classifier">tuple of floats or <a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a> instances.</span></dt><dd><p>The return values are specified by the <code class="docutils literal notranslate"><span class="pre">output</span></code> argument. The names of the
variables match the output request string (i.e. if <code class="docutils literal notranslate"><span class="pre">ds</span></code> is the returned dataset, the
linear coefficient of the regression can be obtained by <code class="docutils literal notranslate"><span class="pre">ds.m</span></code>).</p>
<p>A fit of the form <span class="math notranslate nohighlight">\(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><p>‘B’: Linear coefficients <span class="math notranslate nohighlight">\(\beta_i\)</span> of each regressor</p></li>
<li><p>‘r2’: Fraction of the variance in Y explained by all Xs (<span class="math notranslate nohighlight">\(R^2\)</span>)</p></li>
<li><p>‘p’: p-value of regession; see notes.</p></li>
<li><p>‘sb’: Standard deviation of each linear coefficient</p></li>
<li><p>‘covb’: Covariance matrix of the linear coefficients</p></li>
<li><p>‘se’: Standard deviation of residuals</p></li>
</ul>
<p>The outputs ‘B’, ‘p’, and ‘sb’ will produce as many outputs as there are
regressors.</p>
</dd>
</dl>
</dd>
</dl>
<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 notranslate nohighlight">\(\hat{\vec{a}}\)</span> given in section
8.4.2; it corresponds to the probability of obtaining the regression
coefficient under the null hypothesis that there is no linear relationship.
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 notranslate nohighlight">\(\hat{\sigma}_E\)</span> and the square root of the
diagonal elements of <span class="math notranslate nohighlight">\(\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="py function">
<dt class="sig sig-object py" id="pygeode.difference">
<span class="sig-prename descclassname"><span class="pre">pygeode.</span></span><span class="sig-name descname"><span class="pre">difference</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Nx_fac</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Ny_fac</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'d,p,ci'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/stats.html#difference"><span class="viewcode-link"><span class="pre">[source]</span></span></a><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>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>X, Y</strong><span class="classifier"><a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a></span></dt><dd><p>Variables to difference. Must have at least one axis in common.</p>
</dd>
<dt><strong>axes</strong><span class="classifier">list, optional, defaults to None</span></dt><dd><p>Axes over which to compute means; if othing is specified, the mean
is computed over all axes common to X and Y.</p>
</dd>
<dt><strong>alpha</strong><span class="classifier">float, optional; defaults to 0.05</span></dt><dd><p>Confidence level for which to compute confidence interval.</p>
</dd>
<dt><strong>Nx_fac</strong><span class="classifier">integer, optional: defaults to None</span></dt><dd><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 <code class="docutils literal notranslate"><span class="pre">Nx_fac</span></code>.</p>
</dd>
<dt><strong>Ny_fac</strong><span class="classifier">integer, optional: defaults to None</span></dt><dd><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 <code class="docutils literal notranslate"><span class="pre">Ny_fac</span></code>.</p>
</dd>
<dt><strong>output</strong><span class="classifier">string, optional</span></dt><dd><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 ‘d,p,ci’.</p>
</dd>
<dt><strong>pbar</strong><span class="classifier">progress bar, optional</span></dt><dd><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>results</strong><span class="classifier"><a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dataset</span></code></a></span></dt><dd><p>The returned variables are specified by the <code class="docutils literal notranslate"><span class="pre">output</span></code> argument. The names
of the variables match the output request string (i.e. if <code class="docutils literal notranslate"><span class="pre">ds</span></code> is the
returned dataset, the average of the difference can be obtained by
<code class="docutils literal notranslate"><span class="pre">ds.d</span></code>). The following four quantities can be computed:</p>
<ul class="simple">
<li><p>‘d’: The difference in the means, X - Y</p></li>
<li><p>‘df’: The effective number of degrees of freedom, <span class="math notranslate nohighlight">\(df\)</span></p></li>
<li><p>‘p’: The p-value; see notes.</p></li>
<li><p>‘ci’: The confidence interval of the difference at the level specified by <code class="docutils literal notranslate"><span class="pre">alpha</span></code></p></li>
</ul>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#pygeode.isnonzero" title="pygeode.isnonzero"><code class="xref py py-obj docutils literal notranslate"><span class="pre">isnonzero</span></code></a></dt><dd></dd>
<dt><a class="reference internal" href="#pygeode.paired_difference" title="pygeode.paired_difference"><code class="xref py py-obj docutils literal notranslate"><span class="pre">paired_difference</span></code></a></dt><dd></dd>
</dl>
</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 notranslate nohighlight">\(n_X\)</span> and <span class="math notranslate nohighlight">\(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="py function">
<dt class="sig sig-object py" id="pygeode.paired_difference">
<span class="sig-prename descclassname"><span class="pre">pygeode.</span></span><span class="sig-name descname"><span class="pre">paired_difference</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Y</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">N_fac</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'d,p,ci'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/stats.html#paired_difference"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pygeode.paired_difference" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the mean value and statistics of X - Y, assuming that individual elements
of X and Y can be directly paired. In contrast to <a class="reference internal" href="#pygeode.difference" title="pygeode.difference"><code class="xref py py-func docutils literal notranslate"><span class="pre">difference()</span></code></a>, X and Y must have the same
shape.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>X, Y</strong><span class="classifier"><a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a></span></dt><dd><p>Variables to difference. Must share all axes over which the means are being computed.</p>
</dd>
<dt><strong>axes</strong><span class="classifier">list, optional</span></dt><dd><p>Axes over which to compute means; if nothing is specified, the mean
is computed over all axes common to X and Y.</p>
</dd>
<dt><strong>alpha</strong><span class="classifier">float</span></dt><dd><p>Confidence level for which to compute confidence interval.</p>
</dd>
<dt><strong>N_fac</strong><span class="classifier">integer</span></dt><dd><p>A factor by which to rescale the estimated number of degrees of freedom of
X and Y; the effective number will be given by the number estimated from the
dataset divided by <code class="docutils literal notranslate"><span class="pre">N_fac</span></code>.</p>
</dd>
<dt><strong>output</strong><span class="classifier">string, optional</span></dt><dd><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 ‘d,p,ci’.</p>
</dd>
<dt><strong>pbar</strong><span class="classifier">progress bar, optional</span></dt><dd><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>results</strong><span class="classifier"><a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dataset</span></code></a></span></dt><dd><p>The returned variables are specified by the <code class="docutils literal notranslate"><span class="pre">output</span></code> argument. The names
of the variables match the output request string (i.e. if <code class="docutils literal notranslate"><span class="pre">ds</span></code> is the
returned dataset, the average of the difference can be obtained by
<code class="docutils literal notranslate"><span class="pre">ds.d</span></code>). The following four quantities can be computed:</p>
<ul class="simple">
<li><p>‘d’: The difference in the means, X - Y</p></li>
<li><p>‘df’: The effective number of degrees of freedom, <span class="math notranslate nohighlight">\(df\)</span></p></li>
<li><p>‘p’: The p-value; see notes.</p></li>
<li><p>‘ci’: The confidence interval of the difference at the level specified by <code class="docutils literal notranslate"><span class="pre">alpha</span></code></p></li>
</ul>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#pygeode.isnonzero" title="pygeode.isnonzero"><code class="xref py py-obj docutils literal notranslate"><span class="pre">isnonzero</span></code></a></dt><dd></dd>
<dt><a class="reference internal" href="#pygeode.difference" title="pygeode.difference"><code class="xref py py-obj docutils literal notranslate"><span class="pre">difference</span></code></a></dt><dd></dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>Following section 6.6.6 of von Storch and Zwiers 1999, a one-sample t test is used to test the
hypothesis. The number of degrees of freedom is the sample size scaled by N_fac, less one. This
provides a means of taking into account serial correlation in the data (see sections 6.6.7-9), but
the appropriate 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.21).</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="pygeode.isnonzero">
<span class="sig-prename descclassname"><span class="pre">pygeode.</span></span><span class="sig-name descname"><span class="pre">isnonzero</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">X</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">axes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.05</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">N_fac</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'m,p'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbar</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygeode/stats.html#isnonzero"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pygeode.isnonzero" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the mean value of X and statistics relevant for a test against
the hypothesis that it is 0.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>X</strong><span class="classifier"><a class="reference internal" href="var.html#pygeode.Var" title="pygeode.Var"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a></span></dt><dd><p>Variable to average.</p>
</dd>
<dt><strong>axes</strong><span class="classifier">list, optional</span></dt><dd><p>Axes over which to compute the mean; if nothing is specified, the mean is
computed over all axes.</p>
</dd>
<dt><strong>alpha</strong><span class="classifier">float</span></dt><dd><p>Confidence level for which to compute confidence interval.</p>
</dd>
<dt><strong>N_fac</strong><span class="classifier">integer</span></dt><dd><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 <code class="docutils literal notranslate"><span class="pre">N_fac</span></code>.</p>
</dd>
<dt><strong>output</strong><span class="classifier">string, optional</span></dt><dd><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,p’.</p>
</dd>
<dt><strong>pbar</strong><span class="classifier">progress bar, optional</span></dt><dd><p>A progress bar object. If nothing is provided, a progress bar will be displayed
if the calculation takes sufficiently long.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>results</strong><span class="classifier"><a class="reference internal" href="dataset.html#pygeode.Dataset" title="pygeode.Dataset"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dataset</span></code></a></span></dt><dd><p>The names of the variables match the output request string (i.e. if <code class="docutils literal notranslate"><span class="pre">ds</span></code>
is the returned dataset, the mean value can be obtained through <code class="docutils literal notranslate"><span class="pre">ds.m</span></code>).
The following quantities can be calculated.</p>
<ul class="simple">
<li><p>‘m’: The mean value of X</p></li>
<li><p>‘p’: The probability of the computed value if the population mean was zero</p></li>
<li><p>‘ci’: The confidence interval of the mean at the level specified by alpha</p></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"><code class="xref py py-class docutils literal notranslate"><span class="pre">Var</span></code></a> objects in a dataset.</p>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#pygeode.difference" title="pygeode.difference"><code class="xref py py-obj docutils literal notranslate"><span class="pre">difference</span></code></a></dt><dd></dd>
</dl>
</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"><code class="xref py py-meth docutils literal notranslate"><span class="pre">difference()</span></code></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 class="bottomnav" role="navigation" aria-label="bottom navigation">
<p>
«  <a href="climat.html">Climat module</a>
  ::  
<a class="uplink" href="reference.html">Reference</a>
  ::  
<a class="uplink" href="tutorial.html">Tutorial</a>
  ::  
<a class="uplink" href="gallery/index.html">Gallery</a>
  ::  
<a href="eof.html">EOF Analysis</a>  »
</p>
</div>
<div class="footer" role="contentinfo">
© Copyright 2020, Mike Neish, Peter Hitchcock.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
</div>
</body>
</html>