  We investigate the phase diagrams of RMn$_2$O$_5$ via a first-principles
effective-Hamiltonian method. We are able to reproduce the most important
features of the complicated magnetic and ferroelectric phase transitions. The
calculated polarization as a function of temperature agrees very well with
experiments. The dielectric-constant step at the commensurate-to
-incommensurate magnetic phase transition is well reproduced. The microscopic
mechanisms for the phase transitions are discussed.
