所以这就是我的数据头

  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


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

最佳答案

您会获得相同的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)

08-24 12:17