I want to make sure my R code below is accurate. Because generally
-2*logLik(lm_object) should equal
But in my R code below, these two numbers don't match. Do I have a bug I'm missing?
set.seed(2) n = 300 x <- rnorm(n) e <- rnorm(n, 0, 3) B0 = .5 ; B1 = 2 y <- B0 + B1*x + e m <- lm(y~x) -2*logLik(m) # 1500.681 !! deviance(m) # 2612.792 !!