package com.imsl.test.example.stat; import com.imsl.stat.*; import com.imsl.math.*; /** *

* Computes case statistics in a simple linear regression. *

* Selected case statistics of a simple linear regression model, with an * intercept, are computed. * * * @see Code * @see Output */ 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); } }