Magnetic interactions and crystal field in RMg3 compounds (R = Ce, Pr, Nd)