0

We've tried using the MillerUpdatingRegression class in one of our projects and ran into an issue. After creating an instance of the class, providing the number of variables to expect and adding observations from the entire sample set, we call the "regress(int[])" method, informing the regression process which variables we'd like to include (a subset of the entire predictor set).

When we do this, we receive an ArrayIndexOutOfBounds exception during the process because the number of variables to expect (nvars, provided when the MillerUpdatingRegression class was instantiated) is less than the number of variables passed to the "regress(int[])" method. Our understanding was that this array of integers could be a subset of the predictor indices from all observations.

Does anyone know what we're missing here?

==== Updated with Code ====

double predictorData[][] = new double[n][125]; double predictions[] = new double[n];

//predictorData is a [n x 125] two-dimensional array of //features/predictors with n samples and 125 predictors //predictionsArray is a n-length array of predictions //for the sample set

int numberOfPredictorVariables = 125; boolean includeConstantWhenBuildingModel = true; MillerUpdatingRegression regression = new MillerUpdatingRegression(numberOfPredictorVariables,includeConstantWhenBuildingModel); regression.addObservations(predictorData,predictionsArray)

int predictorsToIncludeInRegression[] = {0,3,9,11}; regression.regress(predictorsToIncludeInRegression); //this is where the ArrayIndexOutOfBounds exception is generated

eugene
  • 956
  • 1
  • 11
  • 13
  • Thanks for pointing that out Braj. I've updated the question with an example of the code we're using. – eugene May 08 '14 at 16:52

1 Answers1

0

I can just guess here without a complete code example, but the number of observations must must be larger than the number of variables (which is 125 in your example).

To be more precisely, the n in your code must be larger than 125 for for the regression to work. The number of predictors passed into the regress method can be less than that.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38