R中的模型选择,所有模型都给出相同的AIC和BIC

时间:2017-02-06 00:35:48

标签: r model-comparison

所以这是我数据的负责人,

  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

我想找到三种不同型号的AIC和BIC,包括厚度和颗粒。

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

我评论了每个旁边的输出,它们为什么都一样?

1 个答案:

答案 0 :(得分:3)

你获得相同的AIC& BIC因为模型都是一样的。你只是得到一个常数,即电阻率的平均值。

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

问题在于,如果您希望公式中的计算类似1 /厚度,则必须在公式中通过将计算括在I()中来表明。这在help(formula)中有所描述。你想要的是

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)