In linear regression, suppose I have Residual Sum of Squares, how to calculate AIC from it?
set.seed(2019)
x = rnorm(1000,5,1)
e = rnorm(1000)
y = x * 2+e
m0 = lm(y~x)
RSS = sum(residuals(m0)^2) # 1029.991
AIC(m0) # 2873.427
How to calculate AIC = 2873.427 given there's 1 predictor, there's 1000 observations and the RSS is 1029.991?