A computer-implemented method for correcting a sample optical spectrum comprising: obtaining a training set of optical spectra for an interfering substance and obtaining a sample optical spectrum; decomposing the training set to obtain a principal component matrix having a plurality of principal component vectors; variably rejecting portions of a sample spectrum vector that do not correspond to a selected one of the plurality of principal component vectors by incrementally: selecting a sub-region of the sample spectrum vector and a corresponding sub-region of the selected principal component vector; and multiplying the selected sub-region of the sample spectrum vector with the corresponding sub-region of the selected principal component vector to provide a coefficient indicative of the weighting of the selected principal component vector for the selected sub-region; excluding sub-regions (300/302) of the sample spectrum vector and corresponding principal component vector based on the incrementally provided coefficients; multiplying the sample spectrum vector with the principal component matrix for the non-excluded sub-regions to provide a weighting vector indicative of the contribution of the principal component matrix; multiplying the weighting vector by the principal component matrix to provide a predicted interference vector; and subtracting the predicted interference vector from the sample spectrum vector to provide a corrected spectrum vector . obtaining a training set of optical spectra for an interfering substance and obtaining a sample optical spectrum; decomposing the training set to obtain a principal component matrix having a plurality of principal component vectors; variably rejecting portions of a sample spectrum vector that do not correspond to a selected one of the plurality of principal component vectors by incrementally: selecting a sub-region of the sample spectrum vector and a corresponding sub-region of the selected principal component vector; and multiplying the selected sub-region of the sample spectrum vector with the corresponding sub-region of the selected principal component vector to provide a coefficient indicative of the weighting of the selected principal component vector for the selected sub-region; selecting a sub-region of the sample spectrum vector and a corresponding sub-region of the selected principal component vector; and multiplying the selected sub-region of the sample spectrum vector with the corresponding sub-region of the selected principal component vector to provide a coefficient indicative of the weighting of the selected principal component vector for the selected sub-region; excluding sub-regions (300/302) of the sample spectrum vector and corresponding principal component vector based on the incrementally provided coefficients; multiplying the sample spectrum vector with the principal component matrix for the non-excluded sub-regions to provide a weighting vector indicative of the contribution of the principal component matrix; multiplying the weighting vector by the principal component matrix to provide a predicted interference vector; and subtracting the predicted interference vector from the sample spectrum vector to provide a corrected spectrum vector . <EOS>