Scalar<?> calculateImpliedRiskAversion(final PrimitiveMatrix assetWeights, final PrimitiveMatrix assetReturns) {

        Scalar<?> retVal = myCovariances.multiply(assetWeights).solve(assetReturns).toScalar(0, 0);

        if (retVal.isSmall(PrimitiveMath.ONE)) {
            retVal = BigScalar.ONE;
        } else if (!retVal.isAbsolute()) {
            retVal = retVal.negate();
        }

        return retVal;
    }
Scalar < ? > calculateImpliedRiskAversion ( final PrimitiveMatrix assetWeights , final PrimitiveMatrix assetReturns ) { Scalar < ? > retVal = myCovariances . multiply ( assetWeights ) . solve ( assetReturns ) . toScalar ( 0 , 0 ) ; if ( retVal . isSmall ( PrimitiveMath . ONE ) ) { retVal = BigScalar . ONE ; } else if ( ! retVal . isAbsolute ( ) ) { retVal = retVal . negate ( ) ; } return retVal ; }
Will calculate the risk aversion factor that is the best fit for an observed pair of market portfolio
weights and equilibrium/historical excess returns.