'Return the \'main effect\' columns of a factor, choosing
an optional reference key.
The reference key can be one of the keys of the Factor,
or an integer, representing which column to remove.
It defaults to 0.'

def main_effect(self, reference=None):

    names = self.names()
    if (reference is None):
        reference = 0
    else:
        try:
            reference = self.keys.index(reference)
        except ValueError:
            reference = int(reference)
    def maineffect_func(value, reference=reference):
        rvalue = []
        keep = lrange(value.shape[0])
        keep.pop(reference)
        for i in range(len(keep)):
            rvalue.append((value[keep[i]] - value[reference]))
        return np.array(rvalue)
    keep = lrange(len(self.names()))
    keep.pop(reference)
    __names = self.names()
    _names = [('%s-%s' % (__names[keep[i]], __names[reference])) for i in range(len(keep))]
    value = Quantitative(_names, func=self, termname=('%s:maineffect' % self.termname), transform=maineffect_func)
    value.namespace = self.namespace
    return value
