Emma Smith Emma Smith - 4 years ago 128
R Question

Model selection in R, all models giving the same AIC and BIC

So this is the head of my data,

thickness grains resistivity
1 25.1 14.9 0.0270
2 368.4 58.1 0.0267
3 540.4 77.3 0.0160
4 712.1 95.6 0.0105
5 883.7 113.0 0.0090
6 1055.7 130.0 0.0247


And I want to find AIC and BIC for three different models involving thickness and grains.

AIC(lm(formula = resistivity ~ (1/thickness), data=z)) #142.194
BIC(lm(formula = resistivity ~ (1/thickness), data=z)) #142.9898

AIC(lm(formula = resistivity ~ (1/grains), data=z)) #142.194
BIC(lm(formula = resistivity ~ (1/grains), data=z)) #142.9898

AIC(lm(formula = resistivity ~ (1/thickness) + (1/grains), data=z)) #142.194
BIC(lm(formula = resistivity ~ (1/thickness) + (1/grains), data=z)) #142.9898


I've commented the output beside each, why are they all the same?

G5W G5W
Answer Source

You get the same AIC & BIC because the models are all the same. You are just getting a constant, the mean value of resistivity.

lm(formula = resistivity ~ (1/thickness), data = z)
  Coefficients:
  (Intercept)  
      0.01898 

The problem is that if you want a computation like 1/thickness in your formula, you must indicate that in your formula by enclosing the calculation in I(). This is described in help(formula). What you want is

lm(formula = resistivity ~ I(1/thickness), data=z)
lm(formula = resistivity ~ I(1/grains), data=z)
lm(formula = resistivity ~ I(1/thickness) + I(1/grains), data=z)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download