[R-meta] Restricted cubic spline behaviour in moderator variable

Mick Girdwood M@G|rdwood @end|ng |rom |@trobe@edu@@u
Thu Aug 31 04:16:47 CEST 2023


Hi everyone,

I am fitting an rma.mv model with a restricted cubic spline moderator. I have followed the helpful examples from the metafor website, as well as looking through this mailing list for previous examples. All of that went well. I have however run into an interesting issue.

I guess this relates less to meta-analysis as such and more specifically to the rcs fitting/package. Here is my model:

model1 <- rma.mv(yi, V,
                     mods = ~rcs(timepoint, 4),
                     data = data,
                     random = list(~ timepoint|cohort),
                     struct = c("CAR”))

I have been comparing the model fit for different moderator structures using heuristics (AIC, BIC etc) as well as visually looking at predicted plots. The fit of this example seemed quite strange, with the tail of the spline at the last knot angling well away from any data points. I was curious and went and extracted the knot positions with:

knots <- attr(rcs(model.matrix(model1)[,2], 4), "parms”)
(e.g. in my example: 3.00000,  6.00000, 12.00000, 51.64118)

I then refit another model, but specifying these exact same knot positions

model2 <- rma.mv(yi, V,
                     mods = ~rcs(timepoint, c(3.00000,  6.00000, 12.00000, 51.64118)),
                     data = data,
                     random = list(~ timepoint|cohort),
                     struct = c("CAR”))

This time the fit is completely different (not subtle, they are two completely different angles on the 3rd spline/last knot) - i.e. in model 2 the tail of the spline is perhaps what would be ‘expected' of the data. What is going on here? To my mind I am fitting the same model with the same knot positions (as I used the knot positions from the first model to fit the second), but have just specified them differently, why are they behaving differently? Is there some other parameter of rcs that I am not using/missing/misunderstanding? I tried reading into the help and source for rcs but didn’t notice anything.  I’m guessing this wouldn’t be metafor related... I tried testing what the attributes of the two different rcs calls looked like but they were identical too, so I don’t understand how it can fit them so differently? I also tried fitting the same model with splines::ns and the fit was identical to model2. Any ideas what is happening with model1?

Sorry if this question is perhaps slightly off topic.
Thank you for your help as always.

Mick Girdwood
La Trobe University | Australia




La Trobe University | TEQSA PRV12132 - Australian University | CRICOS Provider 00115M


More information about the R-sig-meta-analysis mailing list