Reputation: 1463
I'm running code using ExtremeBounds and glm (logit) through several specifications and sometimes I run into the following problem:
Data <- data.frame(var1=rbinom(30,1,0.2),var2=rbinom(30,1,0.2),var3=rnorm(30),coll1=rep(3:32),coll2=rep(1:30))
eba <- eba(data=Data, y="var1",
free="var2",
doubtful=c("var3","coll1","coll2"),
reg.fun=glm, k=1, vif=7, draws=50, weights = "lri", family = binomial(logit))
where the error message is:
Error in reg.summary$coefficients[variable.label, 1] :
subscript out of bounds
Since my dataset is quite big, I have no idea which variable causes this problem in my actual application. Does anyone know one of the answers to these questions:
how can I see which variable causes it?
how can I drop it automatically (maybe with a message like: "coll2 omitted due to collinearity")
Am I right that this problem is caused by glm?
Upvotes: 1
Views: 1147
Reputation: 226761
Posting as an answer, a bit long for a comment:
options(error=recover)
se.fun=se.robust
) gives1: eba(data = Data, y = "var1", free = "var2", doubtful = c("var3", "coll1", "
2: .eba.wrap(formula = formula, data = data, y = y, free = free, doubtful = do
3: run.eba(y = y, v = focus, x = free, combinations = comb, data = data, level
4: run.regressions(y, v, x, combinations, data, level, vif.max, vars.labels, v
I choose option #4 (the lowest level)
I can run ls()
to see all the variables that exist within this scope. Since I know the problem occurs with reg.summary$coefficients[variable.label, 1]
I can try
Browse[1]> variable.label
# coll2
# "coll2"
Browse[1]> str(reg.summary$coefficients)
# num [1:3, 1:4] -0.9154 0.9436 -0.0504 1.1159 0.9728 ...
# - attr(*, "dimnames")=List of 2
# ..$ : chr [1:3] "(Intercept)" "var2" "coll1"
# ..$ : chr [1:4] "Estimate" "Std. Error" "z value" "Pr(>|z|)"
That shows me that reg.summary$coefficients
has apparently dropped the coll2
variable ...
Unfortunately I don't know enough about what eba()
is doing to know how to proceed farther with diagnosis ... if you do, you can inspect the reg.summary
object further to try to figure out what's going wrong ...
Upvotes: 4