[R-sig-ME] Can DHARMa be used with natural splines in the glmer formula?
SuzyR Brun
@uzyr@brun @end|ng |rom gm@||@com
Thu Oct 8 13:22:54 CEST 2020
Dear all,
I haven’t found a way to simulate the residuals via
DHARMa::simulateResiduals in a fitted model when applying a natural spline
transformation (library splines) to a fixed term, say:
model <- glmer(alive ~ A + B + log(C) + ns(D,df=4) +... + (1 | id), data =
mydata, family = binomial(link = 'logit')...
All works fine, without warnings and renders quite reasonable coefficients.
Then I apply the DHARMa function to inspect the residuals: simulationOutput
<- simulateResiduals(fittedModel = model, n = 5000, use.u = T), but it
returns the next message:
Error in ns(D, knots = c(`50%` = 80.53), Boundary.knots = c(0, 149 :
object 'D' not found
For me (inexperienced in GLMMs and R) it is like the function can't
recognize the internal structure of the framemodel using frame[["ns(D, df =
5)"]], and the matrix generated by the knots.
I'm sorry that I can't send a workable example but these are confidential
data and to me it doesn't seem necessary here. It behaves in the same way
whatever the (continuous) factor I introduce as ns.
Interestingly, the "sjPlot" works fine helping to the interpreation of the
ns(D): plot_model(model, type = "eff", terms = c("D[all]")) and also does
the package "performance".
Is there any workaround that I have missed? I have done a quite intensive
search but haven't found anything.
Thanks a lot for your time, and please forgive me if all this is nonsense.
Kind regards
PD: I am using DHARMa version (0.3.3.0), lme4 (1.1 - 23), splines (4.02),
in RStudio (1.3.1093) with R-4.0.2[64-bit]
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list