Regress

The standard package Statistics`LinearRegression` defines a function called Regress, which allows you to extract more information during the fitting process. First load the package.

<< Statistics`LinearRegression`

Now import a HIV P24 sedimentation equilibrium dataset and plot the primary data.

p24data  =  Import["p24.dat"];

\(\(P24plot = 
        ListPlot[p24data, \ 
          AxesOrigin -> {6.56, \ 
              0}, \ \ PlotStyle\  -> 
\ \ \ \ \ {RGBColor[1, 0, \ 0], 
              PointSize[ .015]}, 
          AxesLabel\  -> \ {"Radius", \ "Absorbance"}];\)\)

report = 
      Regress[p24data, {1, x, (x^2), (x^3)}, x, 
        RegressionReport -> {AdjustedRSquared, ANOVATable, BestFit, 
            CoefficientOfVariation, CorrelationMatrix, CovarianceMatrix, 
            DurbinWatsonD, EigenstructureTable, EstimatedVariance, 
            ParameterTable, PartialSumOfSquares, RSquared, 
            SequentialSumOfSquares, VarianceInflation, FitResiduals, 
            SinglePredictionCITable}]; Take[report, {1, -3}]

Here is a plot of the residuals.

residualplot = 
        ListPlot[FitResiduals /. report, FrameTicks -> None, 
          Frame -> True, Ticks -> None, 
          PlotStyle -> {Hue[ .7], PointSize[ .025]}, 
          TextStyle -> {FontSize -> 9}, 
          PlotLabel -> "Residuals"];

You can combine several results on the same graph.

{observed, predicted, se, ci} =  Transpose[(SinglePredictionCITable /. report)[[1]]];

(xval = p24data[[All,1]];
predicted = Transpose[{xval, predicted}];
lowerCI = Transpose[{xval, Map[First, ci]}];
upperCI = Transpose[{xval, Map[Last, ci]}]);

<<Graphics`MultipleListPlot`

MultipleListPlot[
 predicted, lowerCI, upperCI,
 SymbolShape->{None,None,None},
 PlotJoined -> {True, True, True},
 AxesOrigin->{6.56, 0},
 PlotStyle -> { Thickness[.006],
 Dashing[{.02,.01}], Dashing[{.02, .01}]},
 Epilog->{Rectangle[{6.48,0.5},{6.78,.85},residualplot],PointSize[0.01],
    Hue[0],Map[Point,p24data]},PlotLabel->"Cubic fit",AxesLabel -> {"Radius", 
    "Absorbance"}
];