Running into a somewhat cryptic error when fitting a model where dataLong is a tbl_df rather than a data.frame.
Error: Invalid grouping factor specification, id
Description:
Tracked the problem down to this line in handle_assocmod:
rows <- rownames(model.frame(y_mod_stuff$mod))
df <- dataLong[rows,] # <-- this line
mf <- data.table::data.table(df, key = c(id_var, time_var))
This method of indexing into rows will not work correctly if dataLong has class tbl_df. It will then return a complete dataframe with NA values, leading to lmer::glFormula complaining that the factor spec is invalid (because it's operating on an empty dataframe).
Summary:
Running into a somewhat cryptic error when fitting a model where dataLong is a
tbl_df
rather than a data.frame.Description:
Tracked the problem down to this line in
handle_assocmod
:This method of indexing into rows will not work correctly if
dataLong
has classtbl_df
. It will then return a complete dataframe withNA
values, leading tolmer::glFormula
complaining that the factor spec is invalid (because it's operating on an empty dataframe).Reproducible Steps:
Code:
Output:
RStanARM Version:
Current
master
branch ofsambrilleman/rstanarm
(commit 8404e2ba86c186c212fe2a57ca8a36fd263a80ae)R Version:
3.3.3
Operating System:
Linux / ubuntu