Just noting some thoughts here for the record. I'll close this issue once I've made the changes described below.
Here a model frame is constructed for the longitudinal submodel, including the time variable, and this is then converted to a data.table and used for constructing the assoc_parts (i.e. the design matrices for the quadrature).
But, the model frame causes a headache, primarily because functions of variables are evaluated (e.g. sqrt(age), cbind(successes, failures), poly(time, 2)), some of which induce columns of the incorrect length (e.g. poly(time, 2) returns a 2-column matrix which is then treated as a single column in the model frame... and therefore data.table throws an error because the model frame has columns of differing lengths).
It would be much cleaner to pass data.table a data frame with the raw variables. The data frame would just be the longitudinal data (dataLong) but then row matched to the model frame for the longitudinal submodel (returned as part of handle_glmod). The row matching would make sure that any rows removed from dataLong (as a consequence of na.action I guess) are also removed from the data frame before making assoc_parts.
Just noting some thoughts here for the record. I'll close this issue once I've made the changes described below.
Here a model frame is constructed for the longitudinal submodel, including the time variable, and this is then converted to a data.table and used for constructing the assoc_parts (i.e. the design matrices for the quadrature).
But, the model frame causes a headache, primarily because functions of variables are evaluated (e.g. sqrt(age), cbind(successes, failures), poly(time, 2)), some of which induce columns of the incorrect length (e.g. poly(time, 2) returns a 2-column matrix which is then treated as a single column in the model frame... and therefore data.table throws an error because the model frame has columns of differing lengths).
It would be much cleaner to pass data.table a data frame with the raw variables. The data frame would just be the longitudinal data (dataLong) but then row matched to the model frame for the longitudinal submodel (returned as part of handle_glmod). The row matching would make sure that any rows removed from dataLong (as a consequence of na.action I guess) are also removed from the data frame before making assoc_parts.