How to get the Mean Absolute Deviation (MAD) in grouped data