使用R中的MuMIn包不能再返回beta系数

时间:2013-05-10 13:37:11

标签: r mumin

使用R包MuMIn(v1.9.5)和命令dredge时,beta = TRUE开关不再按预期运行。

# load Cement data set with MuMIn package
data(Cement)

# build global model
fmd <- lm(y ~ X1 + X2 + X3 + X4, data = Cement)

# dredge global model without returning standardized coefficients (default); 
# WORKING

ms1 <- dredge(fmd)

# dredge global model and return standardized coefficients; 
# NOT WORKING

ms1 <- dredge(fmd, beta = TRUE)

后者返回:

Error in dimnames(ret) <- list(names(model$coefficients), c("Estimate",  : 
  length of 'dimnames' [1] not equal to array extent

使用R v3.0.0

1 个答案:

答案 0 :(得分:1)

使用MuMIn 1.9.5确认...看起来beta.weights()函数中存在错误。

第四行,

 coefmat <- coefTable(model)[, 1L:2L]

应该是

 coefmat <- coefTable(model)[, 1L:2L, drop=FALSE]

您可以暂时解决此问题,如下所示:

fix(beta.weights)
## opens an editor; make the change in the editor and save/exit
assignInNamespace("beta.weights",beta.weights,"MuMIn")

但是,联系软件包维护者肯定是个好主意(参见help(package="MuMIn")并提交错误报告......