encode_lowrank function

Encode a given factor variable using low rank encoding