Closed timflutre closed 6 years ago
Thanks @timflutre. Should be fixed with the latest commit (61d5173). Please re-open if you still have issues.
I would prefer to keep the same exact output structure, i.e. a list, whatever the length of parm (n
). Whereas, with your latest commit, it's much better than before, but the output is a list (n > 1
) or a matrix (n == 1
). In the latter case, why not keep a list, even if it has only a single component? This way, the user code can use the following command to extract the averaged CI whatever the value of n
:
CIs <- confint(fit.varbvs, idx, 0.95)
CIs <- do.call(rbind, lapply(CIs, function(x) x[nrow(x), ]))
Moreover, using a list as output whatever the value of n
would solve a current bug in summary.varbvs
. Indeed, in the current code, summary.varbvs
returns an error when retrieving the averaged CIs when n == 1
(which can happen when pip.cutoff
is used...):
> for(i in ...){
fit.varbvs <- varbvs(...)
print(summary(fit.varbvs))
}
Error in x[ns + 1, ] : incorrect number of dimensions
> traceback()
7: FUN(X[[i]], ...)
6: lapply(CIs, function(x) x[ns + 1, ])
5: do.call(rbind, lapply(CIs, function(x) x[ns + 1, ]))
4: summary.varbvs(fit.varbvs)
3: summary(fit.varbvs)
2: summary(fit.varbvs)
1: print(summary(fit.varbvs))
@timflutre I think the latest commit (4add2bc) addresses these issues. Thank you for pointing them out. I think I still could address these issues more carefully, but this fix is good enough for now.
There was another lingering bug… this should now be fixed in version 2.5-6 (commit c24c17e
).
Perfect, many thanks Peter!
In
varbvs::confint(object, parm, level)
, ifparm
is a single number, thenn = length(parm) = 1
and the following code is executed:As a result, the names of the output aren't intelligible anymore (see example below).
To solve this issue, the line above shouldn't be executed, or the names should be improved in the case
n=1
.Here is an example:
Compare to the case where two variables are given:
The difference forces user code to adapt to whether n=1 or not, to know how to retrieve the averaged CIs.