class NamedVariableLeastSquaresRegressionResult extends LeastSquaresRegressionResult {

  public Double getPredictedValue(final Map<String, Double> namesAndValues) {
    if (namesAndValues == null) {
      throw new IllegalArgumentException("Map was null");
    }
    if (namesAndValues.isEmpty()) {
      s_logger.warn("Map was empty: returning 0");
      return 0.;
    }
    final double[] betas = getBetas();
    double sum = 0;
    if (hasIntercept()) {
      if (namesAndValues.size() < betas.length - 1) {
        throw new IllegalArgumentException("Number of named variables in map was smaller than that in regression");
      }
    } else {
      if (namesAndValues.size() < betas.length) {
        throw new IllegalArgumentException("Number of named variables in map was smaller than that in regression");
      }
    }
    int i = hasIntercept() ? 1 : 0;
    for (final String name : getIndependentVariableNames()) {
      if (name.equals(INTERCEPT_STRING)) {
        sum += betas[0];
      } else {
        if (!namesAndValues.containsKey(name) || namesAndValues.get(name) == null) {
          throw new IllegalArgumentException("Do not have value for " + name);
        }
        sum += betas[i++] * namesAndValues.get(name);
      }
    }
    return sum;
  }

  public  NamedVariableLeastSquaresRegressionResult(final List<String> independentVariableNames, final LeastSquaresRegressionResult result);

}