Manual Maximum-Likelihood Estimation of an AR-Model in R
I am trying to estimate a simple AR(1) model in R of the form y[t] = alpha + beta * y[t-1] + u[t] with u[t] being normally distributed with mean zero and standard deviation sigma. I have simulated an AR(1) model with alpha = 10 and beta = 0.1 : library(stats) data<-arima.sim(n=1000,list(ar=0.1),mean=10) First check: OLS yields the following results: lm(data~c(NA,data[1:length(data)-1])) Call: lm(formula = data ~ c(NA, data[1:length(data) - 1])) Coefficients: (Intercept) c(NA, data[1:length(data) - 1]) 10.02253 0.09669 But my goal is to estimate the coefficients with ML. My negative log