17

Is it possible to set a stepwise linear model to use the BIC criteria rather than AIC?

I've been trying this but it still calculates each step using AIC values rather than BIC

null = lm(data[,1] ~ 1)
full = lm(data[,1] ~ age + bmi + gender + group)
step(null, scope = list(lower=null,upper=full),
     direction="both", criterion = "BIC")
rcs
  • 67,191
  • 22
  • 172
  • 153
user2846211
  • 949
  • 6
  • 16
  • 24

1 Answers1

26

Add the argument k=log(n) to the step function (n number of samples in the model matrix)

From ?step:

Arguments:
...

k the multiple of the number of degrees of freedom used for the penalty. Only k = 2 gives the genuine AIC; k = log(n) is sometimes referred to as BIC or SBC.

rcs
  • 67,191
  • 22
  • 172
  • 153
  • 5
    `n` is the number of observations which has to be known, while `k` is the numeric value of penalty per parameter to be used. –  Apr 01 '14 at 11:17
  • Sorry for asking after such a long time, I tried your method putting $k=log n$ in the argument, but the resulted best model has a different BIC compared with if I do the BIC directly with these selected variables. Why is that? Thanks! – Nan Nov 25 '18 at 22:57
  • Maybe it is calculated differently, often the constant in the log-likelihood function gets omitted. – rcs Nov 26 '18 at 08:30