  Using an effective low-energy Hamiltonian derived from the first-principles
electronic structure calculations for the narrow $t_{2g}$ bands of YTiO$_3$,
LaTiO$_3$, YVO$_3$, and LaVO$_3$, we evaluate the contributions of the
correlation energy ($E_C$) to the stability of different magnetic structures,
which can be realized in these distorted perovskite oxides. We consider two
approximations for $E_C$, which are based on the regular perturbation theory
expansion around a nondegenerate Hartree-Fock ground state. One is the second
order of perturbation theory, which allows us to compare the effects of local
and nonlocal correlations. Another one is the local $t$-matrix approach, which
allows us to treat some higher-order contributions to $E_C$. The correlation
effects systematically improve the agreement with the experimental data and
additionally stabilize the experimentally observed $G$- and $C$-type
antiferromagnetic (AFM) structures in YVO$_3$ and LaVO$_3$, though the absolute
magnitude of the stabilization energy is sensitive to the level of
approximations and somewhat smaller in the $t$-matrix method. The nonlocal
correlations additionally stabilize the ferromagnetic ground state in YTiO$_3$
and the $C$-type AFM ground state in LaVO$_3$. Amongst two inequivalent
transition-metal sites in the monoclinic structure, the local correlations are
stronger at the sites with the least distorted environment. Limitations of the
regular perturbation-theory expansion for LaTiO$_3$ are also discussed.
