Closed dewittpe closed 11 months ago
Thought - add formula and data to the cp
or cn
objects. This will also let the cpr
and cnr
calls reuse the data and formula instead of calling generate_cp_formula_data
many times over.
Maybe keeping the regression models would make this a easier as the data and formula would be part of that obejct.
I think this can be made easier by looking for factors and characters in the formula. replace those variables in the data set with the expanded columns from a call to model.matrix. Update the formula to use the expanded factors/characters. If I pass in the whole data set passed to cp/cn then odd things like the id variable for geepack::geeglms shouldn't cause a special case in the calls (i hope)
There is no need to build a new
data.frame
. You only need to redesign theformula
.Things that need to happen:
factors
orcharacters
set up the formula to include the neededI(var == level)
elementsNo need for a whole new data set. This change should save time and memory.