I am setting up a simulation study using the gee package and need to capture calls to gee() that return warning messages. Eg:
> gee1 = gee(resp_ind ~ tmt_ind, id=cluster_id, family=gaussian, corstr="exchangeable", data=d1)
Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27
running glm to get initial regression estimate
(Intercept) tmt_ind
-0.1027732 0.2972790
Warning messages:
1: In gee(resp_ind ~ tmt_ind, id = cluster_id, family = gaussian, corstr = "exchangeable", :
Maximum number of iterations consumed
2: In gee(resp_ind ~ tmt_ind, id = cluster_id, family = gaussian, corstr = "exchangeable", :
Convergence not achieved; results suspect
3: In gee(resp_ind ~ tmt_ind, id = cluster_id, family = gaussian, corstr = "exchangeable", :
Cgee had an error (code= 104). Results suspect.
4: In gee(resp_ind ~ tmt_ind, id = cluster_id, family = gaussian, corstr = "exchangeable", :
Working correlation estimate not positive definite
> gee1$error
[1] 1104
A short answer might just be documentation on what the $error error value codes in gee() objects can be and what they correspond to. I assume that this holds information on convergence etc, but I have not been able to find any documentation on this.
Alternatively, I have explored solutions that capture the warning messages. I have seen solutions for lmer() that make use of the $optinfo properties (Eg: capturing convergence message from lme4 package in R), but there doesn't appear to be an equivalent property for gee() objects (?). I also explored purrr::safely(), but this seems to apply to function calls, not model objects (?) (Eg: How can I check whether a function call results in a warning?).
What is the best way to approach this?