MLE in R

Note: This exercise is borrowed from Jason Blevins This is a short exercise in running maximum likelihood estimation (MLE) in R. We will do it for the following AR(1) process: [ zt = \mu + \rho (z{t - 1} - \mu) + \sigma \varepsilon_t ] where (\varepsilon_t \sim N(0, 1)). Before I get into the details of MLE, what is the fundamental insight of MLE? The idea is that we want to estimate the parameters of the model that are generating our data.