Adding mpa.R

Still working on the code, it is not complete yet