'Manually estimate probit model with autoregressive structure in R

I would like to write an R algorithm which would perform the Maximum Likelihood estimation of a binary choice model (probit/logit, it does not really matter) with the following structure for the latent variable:

equation

I understand the logics provided in this answer, however, I do not understand how to account for the presence of the lagged value of latent variable.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source