commons-statistics-regression/src/main/java/org/apache/commons/statistics/regression/stored/ols/OLSRegression.java
/**
     * <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 inputNewSampleData} methods before invoking this method; otherwise a
     * {@code NullPointerException} will be thrown.
     * </p>
     *
     * @return The beta variance-covariance matrix
     */

Calculates the variance-covariance matrix of the regression parameters.


Var(b) = (XTX)-1


Uses QR decomposition to reduce (XTX)-1 to
(RTR)-1, with only the top p rows of R included, where
p = the length of the beta vector.


Data for the model must have been successfully loaded using one of the
inputNewSampleData methods before invoking this method; otherwise a
NullPointerException will be thrown.

@return The beta variance-covariance matrix
Calculates the variance - covariance matrix of the regression parameters . Var ( b ) = ( XTX ) - 1 Uses QR decomposition to reduce ( XTX ) - 1 to ( RTR ) - 1 with only the top p rows of R included where p = the length of the beta vector . Data for the model must have been successfully loaded using one of the inputNewSampleData methods before invoking this method ; otherwise a NullPointerException will be thrown . @return The beta variance - covariance matrix
@Override
    protected StatisticsMatrix calculateBetaVariance() {
        QRDecomposition<DMatrixRMaj> qr = new QRDecomposition_DDRB_to_DDRM();
        qr.decompose(getX().getDDRM().copy());
        int p = getX().numCols();
        StatisticsMatrix qrR = new StatisticsMatrix(qr.getR(null, false)).extractMatrix(0, p, 0, p);
        StatisticsMatrix invR = qrR.invert();
        return invR.mult(invR.transpose());
    }
@ Override protected StatisticsMatrix calculateBetaVariance ( ) { QRDecomposition < DMatrixRMaj > qr = new QRDecomposition_DDRB_to_DDRM ( ) ; qr . decompose ( getX ( ) . getDDRM ( ) . copy ( ) ) ; int p = getX ( ) . numCols ( ) ; StatisticsMatrix qrR = new StatisticsMatrix ( qr . getR ( null , false ) ) . extractMatrix ( 0 , p , 0 , p ) ; StatisticsMatrix invR = qrR . invert ( ) ; return invR . mult ( invR . transpose ( ) ) ; }
<p>
 Calculates the variance-covariance matrix of the regression parameters.
<p > Calculates the variance - covariance matrix of the regression parameters .