summaryrefslogtreecommitdiff
path: root/commons-math3-3.6.1/docs/apidocs/org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html
blob: 27993076365f5280a622aa3cebcb34abcae09e09 (plain)
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OLSMultipleLinearRegression (Apache Commons Math 3.6.1 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="OLSMultipleLinearRegression (Apache Commons Math 3.6.1 API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/OLSMultipleLinearRegression.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/commons/math3/stat/regression/MultipleLinearRegression.html" title="interface in org.apache.commons.math3.stat.regression"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../org/apache/commons/math3/stat/regression/RegressionResults.html" title="class in org.apache.commons.math3.stat.regression"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html" target="_top">Frames</a></li>
<li><a href="OLSMultipleLinearRegression.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.commons.math3.stat.regression</div>
<h2 title="Class OLSMultipleLinearRegression" class="title">Class OLSMultipleLinearRegression</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression</a></li>
<li>
<ul class="inheritance">
<li>org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><a href="../../../../../../org/apache/commons/math3/stat/regression/MultipleLinearRegression.html" title="interface in org.apache.commons.math3.stat.regression">MultipleLinearRegression</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="strong">OLSMultipleLinearRegression</span>
extends <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">AbstractMultipleLinearRegression</a></pre>
<div class="block"><p>Implements ordinary least squares (OLS) to estimate the parameters of a
 multiple linear regression model.</p>

 <p>The regression coefficients, <code>b</code>, satisfy the normal equations:
 <pre><code> X<sup>T</sup> X b = X<sup>T</sup> y </code></pre></p>

 <p>To solve the normal equations, this implementation uses QR decomposition
 of the <code>X</code> matrix. (See <a href="../../../../../../org/apache/commons/math3/linear/QRDecomposition.html" title="class in org.apache.commons.math3.linear"><code>QRDecomposition</code></a> for details on the
 decomposition algorithm.) The <code>X</code> matrix, also known as the <i>design matrix,</i>
 has rows corresponding to sample observations and columns corresponding to independent
 variables.  When the model is estimated using an intercept term (i.e. when
 <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#isNoIntercept()"><code>isNoIntercept</code></a> is false as it is by default), the <code>X</code>
 matrix includes an initial column identically equal to 1.  We solve the normal equations
 as follows:
 <pre><code> X<sup>T</sup>X b = X<sup>T</sup> y
 (QR)<sup>T</sup> (QR) b = (QR)<sup>T</sup>y
 R<sup>T</sup> (Q<sup>T</sup>Q) R b = R<sup>T</sup> Q<sup>T</sup> y
 R<sup>T</sup> R b = R<sup>T</sup> Q<sup>T</sup> y
 (R<sup>T</sup>)<sup>-1</sup> R<sup>T</sup> R b = (R<sup>T</sup>)<sup>-1</sup> R<sup>T</sup> Q<sup>T</sup> y
 R b = Q<sup>T</sup> y </code></pre></p>

 <p>Given <code>Q</code> and <code>R</code>, the last equation is solved by back-substitution.</p></div>
<dl><dt><span class="strong">Since:</span></dt>
  <dd>2.0</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#OLSMultipleLinearRegression()">OLSMultipleLinearRegression</a></strong>()</code>
<div class="block">Create an empty OLSMultipleLinearRegression instance.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#OLSMultipleLinearRegression(double)">OLSMultipleLinearRegression</a></strong>(double&nbsp;threshold)</code>
<div class="block">Create an empty OLSMultipleLinearRegression instance, using the given
 singularity threshold for the QR decomposition.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateAdjustedRSquared()">calculateAdjustedRSquared</a></strong>()</code>
<div class="block">Returns the adjusted R-squared statistic, defined by the formula</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected <a href="../../../../../../org/apache/commons/math3/linear/RealVector.html" title="class in org.apache.commons.math3.linear">RealVector</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateBeta()">calculateBeta</a></strong>()</code>
<div class="block">Calculates the regression coefficients using OLS.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected <a href="../../../../../../org/apache/commons/math3/linear/RealMatrix.html" title="interface in org.apache.commons.math3.linear">RealMatrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateBetaVariance()">calculateBetaVariance</a></strong>()</code>
<div class="block">Calculates the variance-covariance matrix of the regression parameters.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../../org/apache/commons/math3/linear/RealMatrix.html" title="interface in org.apache.commons.math3.linear">RealMatrix</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateHat()">calculateHat</a></strong>()</code>
<div class="block">Compute the "hat" matrix.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateResidualSumOfSquares()">calculateResidualSumOfSquares</a></strong>()</code>
<div class="block">Returns the sum of squared residuals.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateRSquared()">calculateRSquared</a></strong>()</code>
<div class="block">Returns the R-Squared statistic, defined by the formula</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>double</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateTotalSumOfSquares()">calculateTotalSumOfSquares</a></strong>()</code>
<div class="block">Returns the sum of squared deviations of Y from its mean.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#newSampleData(double[],%20double[][])">newSampleData</a></strong>(double[]&nbsp;y,
             double[][]&nbsp;x)</code>
<div class="block">Loads model x and y sample data, overriding any previous sample.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#newSampleData(double[],%20int,%20int)">newSampleData</a></strong>(double[]&nbsp;data,
             int&nbsp;nobs,
             int&nbsp;nvars)</code>
<div class="block">Loads model x and y sample data from a flat input array, overriding any previous sample.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#newXSampleData(double[][])">newXSampleData</a></strong>(double[][]&nbsp;x)</code>
<div class="block">Loads new x sample data, overriding any previous data.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.commons.math3.stat.regression.<a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">AbstractMultipleLinearRegression</a></h3>
<code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#calculateErrorVariance()">calculateErrorVariance</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#calculateResiduals()">calculateResiduals</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#calculateYVariance()">calculateYVariance</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateErrorVariance()">estimateErrorVariance</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateRegressandVariance()">estimateRegressandVariance</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateRegressionParameters()">estimateRegressionParameters</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateRegressionParametersStandardErrors()">estimateRegressionParametersStandardErrors</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateRegressionParametersVariance()">estimateRegressionParametersVariance</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateRegressionStandardError()">estimateRegressionStandardError</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#estimateResiduals()">estimateResiduals</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#getX()">getX</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#getY()">getY</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#isNoIntercept()">isNoIntercept</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#newYSampleData(double[])">newYSampleData</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#setNoIntercept(boolean)">setNoIntercept</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#validateCovarianceData(double[][],%20double[][])">validateCovarianceData</a>, <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#validateSampleData(double[][],%20double[])">validateSampleData</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long,%20int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="OLSMultipleLinearRegression()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>OLSMultipleLinearRegression</h4>
<pre>public&nbsp;OLSMultipleLinearRegression()</pre>
<div class="block">Create an empty OLSMultipleLinearRegression instance.</div>
</li>
</ul>
<a name="OLSMultipleLinearRegression(double)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>OLSMultipleLinearRegression</h4>
<pre>public&nbsp;OLSMultipleLinearRegression(double&nbsp;threshold)</pre>
<div class="block">Create an empty OLSMultipleLinearRegression instance, using the given
 singularity threshold for the QR decomposition.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>threshold</code> - the singularity threshold</dd><dt><span class="strong">Since:</span></dt>
  <dd>3.3</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="newSampleData(double[], double[][])">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newSampleData</h4>
<pre>public&nbsp;void&nbsp;newSampleData(double[]&nbsp;y,
                 double[][]&nbsp;x)
                   throws <a href="../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></pre>
<div class="block">Loads model x and y sample data, overriding any previous sample.

 Computes and caches QR decomposition of the X matrix.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>y</code> - the [n,1] array representing the y sample</dd><dd><code>x</code> - the [n,k] array representing the x sample</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if the x and y array data are not
             compatible for the regression</dd></dl>
</li>
</ul>
<a name="newSampleData(double[], int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newSampleData</h4>
<pre>public&nbsp;void&nbsp;newSampleData(double[]&nbsp;data,
                 int&nbsp;nobs,
                 int&nbsp;nvars)</pre>
<div class="block"><p>Loads model x and y sample data from a flat input array, overriding any previous sample.
 </p>
 <p>Assumes that rows are concatenated with y values first in each row.  For example, an input
 <code>data</code> array containing the sequence of values (1, 2, 3, 4, 5, 6, 7, 8, 9) with
 <code>nobs = 3</code> and <code>nvars = 2</code> creates a regression dataset with two
 independent variables, as below:
 <pre>
   y   x[0]  x[1]
   --------------
   1     2     3
   4     5     6
   7     8     9
 </pre>
 </p>
 <p>Note that there is no need to add an initial unitary column (column of 1's) when
 specifying a model including an intercept term.  If <a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#isNoIntercept()"><code>AbstractMultipleLinearRegression.isNoIntercept()</code></a> is <code>true</code>,
 the X matrix will be created without an initial column of "1"s; otherwise this column will
 be added.
 </p>
 <p>Throws IllegalArgumentException if any of the following preconditions fail:
 <ul><li><code>data</code> cannot be null</li>
 <li><code>data.length = nobs * (nvars + 1)</li>
 <li><code>nobs > nvars</code></li></ul>
 </p>
 <p>This implementation computes and caches the QR decomposition of the X matrix.</p></div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#newSampleData(double[],%20int,%20int)">newSampleData</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">AbstractMultipleLinearRegression</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>data</code> - input data array</dd><dd><code>nobs</code> - number of observations (rows)</dd><dd><code>nvars</code> - number of independent variables (columns, not counting y)</dd></dl>
</li>
</ul>
<a name="calculateHat()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>calculateHat</h4>
<pre>public&nbsp;<a href="../../../../../../org/apache/commons/math3/linear/RealMatrix.html" title="interface in org.apache.commons.math3.linear">RealMatrix</a>&nbsp;calculateHat()</pre>
<div class="block"><p>Compute the "hat" matrix.
 </p>
 <p>The hat matrix is defined in terms of the design matrix X
  by X(X<sup>T</sup>X)<sup>-1</sup>X<sup>T</sup>
 </p>
 <p>The implementation here uses the QR decomposition to compute the
 hat matrix as Q I<sub>p</sub>Q<sup>T</sup> where I<sub>p</sub> is the
 p-dimensional identity matrix augmented by 0's.  This computational
 formula is from "The Hat Matrix in Regression and ANOVA",
 David C. Hoaglin and Roy E. Welsch,
 <i>The American Statistician</i>, Vol. 32, No. 1 (Feb., 1978), pp. 17-22.
 </p>
 <p>Data for the model must have been successfully loaded using one of
 the <code>newSampleData</code> methods before invoking this method; otherwise
 a <code>NullPointerException</code> will be thrown.</p></div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the hat matrix</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - unless method <code>newSampleData</code> has been
 called beforehand.</dd></dl>
</li>
</ul>
<a name="calculateTotalSumOfSquares()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>calculateTotalSumOfSquares</h4>
<pre>public&nbsp;double&nbsp;calculateTotalSumOfSquares()</pre>
<div class="block"><p>Returns the sum of squared deviations of Y from its mean.</p>

 <p>If the model has no intercept term, <code>0</code> is used for the
 mean of Y - i.e., what is returned is the sum of the squared Y values.</p>

 <p>The value returned by this method is the SSTO value used in
 the <a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateRSquared()"><code>R-squared</code></a> computation.</p></div>
<dl><dt><span class="strong">Returns:</span></dt><dd>SSTO - the total sum of squares</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the sample has not been set</dd><dt><span class="strong">Since:</span></dt>
  <dd>2.2</dd>
<dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#isNoIntercept()"><code>AbstractMultipleLinearRegression.isNoIntercept()</code></a></dd></dl>
</li>
</ul>
<a name="calculateResidualSumOfSquares()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>calculateResidualSumOfSquares</h4>
<pre>public&nbsp;double&nbsp;calculateResidualSumOfSquares()</pre>
<div class="block">Returns the sum of squared residuals.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>residual sum of squares</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/linear/SingularMatrixException.html" title="class in org.apache.commons.math3.linear">SingularMatrixException</a></code> - if the design matrix is singular</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the data for the model have not been loaded</dd><dt><span class="strong">Since:</span></dt>
  <dd>2.2</dd></dl>
</li>
</ul>
<a name="calculateRSquared()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>calculateRSquared</h4>
<pre>public&nbsp;double&nbsp;calculateRSquared()</pre>
<div class="block">Returns the R-Squared statistic, defined by the formula <pre>
 R<sup>2</sup> = 1 - SSR / SSTO
 </pre>
 where SSR is the <a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateResidualSumOfSquares()"><code>sum of squared residuals</code></a>
 and SSTO is the <a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateTotalSumOfSquares()"><code>total sum of squares</code></a>

 <p>If there is no variance in y, i.e., SSTO = 0, NaN is returned.</p></div>
<dl><dt><span class="strong">Returns:</span></dt><dd>R-square statistic</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the sample has not been set</dd>
<dd><code><a href="../../../../../../org/apache/commons/math3/linear/SingularMatrixException.html" title="class in org.apache.commons.math3.linear">SingularMatrixException</a></code> - if the design matrix is singular</dd><dt><span class="strong">Since:</span></dt>
  <dd>2.2</dd></dl>
</li>
</ul>
<a name="calculateAdjustedRSquared()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>calculateAdjustedRSquared</h4>
<pre>public&nbsp;double&nbsp;calculateAdjustedRSquared()</pre>
<div class="block"><p>Returns the adjusted R-squared statistic, defined by the formula <pre>
 R<sup>2</sup><sub>adj</sub> = 1 - [SSR (n - 1)] / [SSTO (n - p)]
 </pre>
 where SSR is the <a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateResidualSumOfSquares()"><code>sum of squared residuals</code></a>,
 SSTO is the <a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateTotalSumOfSquares()"><code>total sum of squares</code></a>, n is the number
 of observations and p is the number of parameters estimated (including the intercept).</p>

 <p>If the regression is estimated without an intercept term, what is returned is <pre>
 <code> 1 - (1 - <a href="../../../../../../org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html#calculateRSquared()"><code>calculateRSquared()</code></a>) * (n / (n - p)) </code>
 </pre></p>

 <p>If there is no variance in y, i.e., SSTO = 0, NaN is returned.</p></div>
<dl><dt><span class="strong">Returns:</span></dt><dd>adjusted R-Squared statistic</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the sample has not been set</dd>
<dd><code><a href="../../../../../../org/apache/commons/math3/linear/SingularMatrixException.html" title="class in org.apache.commons.math3.linear">SingularMatrixException</a></code> - if the design matrix is singular</dd><dt><span class="strong">Since:</span></dt>
  <dd>2.2</dd>
<dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#isNoIntercept()"><code>AbstractMultipleLinearRegression.isNoIntercept()</code></a></dd></dl>
</li>
</ul>
<a name="newXSampleData(double[][])">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newXSampleData</h4>
<pre>protected&nbsp;void&nbsp;newXSampleData(double[][]&nbsp;x)</pre>
<div class="block"><p>Loads new x sample data, overriding any previous data.
 </p>
 The input <code>x</code> array should have one row for each sample
 observation, with columns corresponding to independent variables.
 For example, if <pre>
 <code> x = new double[][] {{1, 2}, {3, 4}, {5, 6}} </code></pre>
 then <code>setXSampleData(x) </code> results in a model with two independent
 variables and 3 observations:
 <pre>
   x[0]  x[1]
   ----------
     1    2
     3    4
     5    6
 </pre>
 </p>
 <p>Note that there is no need to add an initial unitary column (column of 1's) when
 specifying a model including an intercept term.
 </p>
 <p>This implementation computes and caches the QR decomposition of the X matrix
 once it is successfully loaded.</p></div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#newXSampleData(double[][])">newXSampleData</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">AbstractMultipleLinearRegression</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - the rectangular array representing the x sample</dd></dl>
</li>
</ul>
<a name="calculateBeta()">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>calculateBeta</h4>
<pre>protected&nbsp;<a href="../../../../../../org/apache/commons/math3/linear/RealVector.html" title="class in org.apache.commons.math3.linear">RealVector</a>&nbsp;calculateBeta()</pre>
<div class="block">Calculates the regression coefficients using OLS.

 <p>Data for the model must have been successfully loaded using one of
 the <code>newSampleData</code> methods before invoking this method; otherwise
 a <code>NullPointerException</code> will be thrown.</p></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#calculateBeta()">calculateBeta</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">AbstractMultipleLinearRegression</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>beta</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/linear/SingularMatrixException.html" title="class in org.apache.commons.math3.linear">SingularMatrixException</a></code> - if the design matrix is singular</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the data for the model have not been loaded</dd></dl>
</li>
</ul>
<a name="calculateBetaVariance()">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>calculateBetaVariance</h4>
<pre>protected&nbsp;<a href="../../../../../../org/apache/commons/math3/linear/RealMatrix.html" title="interface in org.apache.commons.math3.linear">RealMatrix</a>&nbsp;calculateBetaVariance()</pre>
<div class="block"><p>Calculates the variance-covariance matrix of the regression parameters.
 </p>
 <p>Var(b) = (X<sup>T</sup>X)<sup>-1</sup>
 </p>
 <p>Uses QR decomposition to reduce (X<sup>T</sup>X)<sup>-1</sup>
 to (R<sup>T</sup>R)<sup>-1</sup>, with only the top p rows of
 R included, where p = the length of the beta vector.</p>

 <p>Data for the model must have been successfully loaded using one of
 the <code>newSampleData</code> methods before invoking this method; otherwise
 a <code>NullPointerException</code> will be thrown.</p></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html#calculateBetaVariance()">calculateBetaVariance</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../../org/apache/commons/math3/stat/regression/AbstractMultipleLinearRegression.html" title="class in org.apache.commons.math3.stat.regression">AbstractMultipleLinearRegression</a></code></dd>
<dt><span class="strong">Returns:</span></dt><dd>The beta variance-covariance matrix</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../../org/apache/commons/math3/linear/SingularMatrixException.html" title="class in org.apache.commons.math3.linear">SingularMatrixException</a></code> - if the design matrix is singular</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang">NullPointerException</a></code> - if the data for the model have not been loaded</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/OLSMultipleLinearRegression.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/commons/math3/stat/regression/MultipleLinearRegression.html" title="interface in org.apache.commons.math3.stat.regression"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../org/apache/commons/math3/stat/regression/RegressionResults.html" title="class in org.apache.commons.math3.stat.regression"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html" target="_top">Frames</a></li>
<li><a href="OLSMultipleLinearRegression.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2003&#x2013;2016 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>