x <- lm(Sepal.Length ~ Petal.Width + Species, data = iris)
get_loglikelihood(x, estimator = "ML") # Equivalent to stats::logLik(x)
get_loglikelihood(x, estimator = "REML") # Equivalent to stats::logLik(x, REML=TRUE)
get_loglikelihood(x, estimator = "OLS")
Run the code above in your browser using DataLab