Hello StatMastars,
I'm coming enlightenment. Im sure this question is something very simple that Im missing. I would like to add in a report the linear predictor formula from a gee model. There is a Hmisc::Formula that extract the formula but it does not work for geeglm objects. Additionally, the model has a spline term and after a while looking around on how to extract the formula I was not able to do so.
fitar1_11 <- geeglm(outcome ~ v1 + v2 + v4_recoded + v5_trunc + bs(weeks, df = 3), family = binomial(), data = M2, id = f1p0, corstr = "ar1")
fitar1_11
geeglm(formula = outcome ~ v1 + v2 + v4_recoded + v5_trunc +
bs(weeks, df = 3), family = binomial(), data = M2, id = f1p0,
corstr = "ar1")
Coefficients:
(Intercept) v1
-1.586386e+00 8.363458e-02
v2 v4_recodedNET, NGT, JF, OET, GF or TPN
-3.763166e-02 4.503599e+15
v5_trunc bs(weeks, df = 3)1
7.261799e-02 3.469451e-03
bs(weeks, df = 3)2 bs(weeks, df = 3)3
3.756985e-01 4.542696e+00
Degrees of Freedom: 472 Total (i.e. Null); 464 Residual
> nd # newdata to predict at
v1 v2 v4_recoded v5_trunc weeks
1 8 3 No catheter 36 2
> predict(fitar1_11, type = "response", newdata = nd) # prediction from the model
1
0.8345324
# Not working prediction from the handmade formula
> plogis(-1.586386 + 0.08363458*nd$v1 + -0.03763166*nd$v2 + 4503599142291968*0 + 0.07261799*nd$v5_trunc + 0.003469451*nd$weeks + 0.3756985*pmax(nd$weeks-1,0)^3 + 4.542696*pmax(nd$weeks-8,0)^3)
[1] 0.8772541
What am I missing to make this formula to make correct predictions? Any further reading would also be nice.
Best regards,