### Example2: Linear Regression

Selected case statistics of a simple linear regression model, with an intercept, are computed.
```
import com.imsl.stat.*;
import com.imsl.math.*;

public class LinearRegressionEx2 {

public static void main(String args[]) {
LinearRegression r = new LinearRegression(2, true);
double y[] = {3, 4, 5, 7, 7, 8, 9};
double x[][] = {
{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {0, 6}, {1, 7}
};
double[][] results = new double[7][5];
double[] confint = new double[2];
r.update(x, y);
for (int k = 0; k < 7; k++) {
LinearRegression.CaseStatistics cs
= r.getCaseStatistics(x[k], y[k]);
results[k][0] = cs.getJackknifeResidual();
results[k][1] = cs.getCooksDistance();
results[k][2] = cs.getDFFITS();
confint = cs.getConfidenceInterval();
results[k][3] = confint[0];
results[k][4] = confint[1];
}
PrintMatrix p = new PrintMatrix("Selected Case Statistics");
PrintMatrixFormat mf = new PrintMatrixFormat();
String labels[] = {
"Jackknife Residual.", "Cook's D", "DFFITS",
"[Conf. Interval", "on the Mean]"
};
mf.setColumnLabels(labels);
p.print(mf, results);
}
}
```

#### Output

```                        Selected Case Statistics
Jackknife Residual.  Cook's D  DFFITS  [Conf. Interval  on the Mean]
0        -0.343          0.045    -0.324       2.261           3.996
1        -0.327          0.018    -0.207       3.467           4.818
2        -0.338          0.011    -0.161       4.613           5.702
3         ?              0.276     ?           5.648           6.695
4        -0.418          0.024    -0.237       6.563           7.808
5         ?              ?         ?           6.736           9.264
6        -0.742          0.372    -0.996       8.201          10.227

```