I get an error when running posterior_survfit with any basehaz other than Weibull. This happens whether or not I include newdata.
The message reads:
Error in beta %*% t(x) : non-conformable arguments
It appears to be due to the inclusion of an Intercept term in the x matrix, where there is not an intercept term in the betas. At least not for any hazard except the weibull model.
Description:
I had done a quick hack to address this issue earlier, but forgot to document the bug. Documenting it here so it can be tracked.
The fix, which worked to resolve the issue but is admittedly a hack, is to literally remove the intercept term in pp_data as described here:
if (is.stanjm(object) & object$basehaz$type_name != 'weibull' & m == 'Event') {
# remove Intercept term, if present
x <- x[ ,-1*grep(colnames(x), pattern='(Intercept)')]
}
In the original model fit, the x matrix is prepared by coxph and so does not include the intercept term by default. In this function, however, the x matrix is prepared by evaluating the RHS of the formula using standard tools & so it includes the intercept term as specified in the formula.
Reproducible Steps:
Install develop2 branch of 'sambrilleman/rstanarm':
# latest commit of `develop2` branch, at the time of identification
devtools::install_github('sambrilleman/rstanarm', ref = '0176bc3', args = '--preclean', local = TRUE)
Summary:
I get an error when running
posterior_survfit
with anybasehaz
other than Weibull. This happens whether or not I include newdata.The message reads:
It appears to be due to the inclusion of an Intercept term in the
x
matrix, where there is not an intercept term in thebeta
s. At least not for any hazard except the weibull model.Description:
I had done a quick hack to address this issue earlier, but forgot to document the bug. Documenting it here so it can be tracked.
The fix, which worked to resolve the issue but is admittedly a hack, is to literally remove the intercept term in
pp_data
as described here:In the original model fit, the
x
matrix is prepared bycoxph
and so does not include the intercept term by default. In this function, however, thex
matrix is prepared by evaluating the RHS of the formula using standard tools & so it includes the intercept term as specified in the formula.Reproducible Steps:
Install
develop2
branch of 'sambrilleman/rstanarm':Fit example model with
basehaz = 'bs'
Run
ps_check
orposterior_survfit
on this fitted objectRStanARM Version:
See above
R Version:
3.3.3
Operating System:
Ubuntu