R 中的模型选择,所有模型都提供相同的 AIC 和 BIC
Model selection in R, all models giving the same AIC and BIC
所以这是我的数据头部,
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/thickness 的计算,则必须在公式中通过将计算包含在 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)
所以这是我的数据头部,
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/thickness 的计算,则必须在公式中通过将计算包含在 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)