I am new to Stan and I want to know if there is a built-in method to use the Metropolis Hasting algorithm in PyStan or CmdStan. If there is please tell how to use it.
Stan’s MCMC engine is designed entirely around an implementation of Hamiltonian Monte Carlo that includes a Metropolis accept/reject step but uses approximate Hamiltonian trajectories to generate the proposals. In the vast majority of cases, Stan’s algorithm will substantially outperform garden-variety Metropolis-Hastings.
To learn more, see 15 MCMC Sampling | Stan Reference Manual and references therein.
Casual reminder that Stan’s Hamiltonian Monte Carlo sampler does not use Hamiltonian trajectories to generate proposals for a Metropolis-Hastings procedure. That was the construction of the first Hamiltonian Monte Carlo method, sometimes referred to as “Hybrid Monte Carlo”, but the implementation in Stan is much more sophisticated and cannot be interpreted as a simple Metropolis-Hastings method.