There were two places that evaluating the response variable was causing
problems:
1) In handle_glmod and make_assoc_parts, the matched call needed to be
evaluated in the correct environment, instead of the parent.frame()
which should now be fixed. Also, there is no need to include the
response in the glFormula evalaution for make_assoc_terms, since that
function is only used for constructing design matrices. So I now drop
the response from the formula in make_assoc_terms, and tell glFormula to
not bother checking the LHS of the formula.
2) In jm_data the response wasn't being constructed, since it is only
really needed for log_lik and nothing else. So, previously the response
was being evaluated using the data in log_lik. This caused errors when
the data already included an evaluated function of the response
variable, for example sqrt(CD4), because the data was the model frame
from the original model. Now, instead, the response is constructed in
jm_data -- if newdataLong is NULL in jm_data, then the response is just
taken as get_y(object), so that there is no need to reevaluate the
formula for the response if there is no newdataLong passed by the user.
This evaluated response variable, now returned by jm_data, can then be
used in log_lik etc.
There were two places that evaluating the response variable was causing problems:
1) In handle_glmod and make_assoc_parts, the matched call needed to be evaluated in the correct environment, instead of the parent.frame() which should now be fixed. Also, there is no need to include the response in the glFormula evalaution for make_assoc_terms, since that function is only used for constructing design matrices. So I now drop the response from the formula in make_assoc_terms, and tell glFormula to not bother checking the LHS of the formula.
2) In jm_data the response wasn't being constructed, since it is only really needed for log_lik and nothing else. So, previously the response was being evaluated using the data in log_lik. This caused errors when the data already included an evaluated function of the response variable, for example sqrt(CD4), because the data was the model frame from the original model. Now, instead, the response is constructed in jm_data -- if newdataLong is NULL in jm_data, then the response is just taken as get_y(object), so that there is no need to reevaluate the formula for the response if there is no newdataLong passed by the user. This evaluated response variable, now returned by jm_data, can then be used in log_lik etc.
The intention is that this will close #48