I would like to compile data from several published studies. I am trying to conduct a meta-regression using restricted cubic splines to analyse and plot the association between two variables (x and y), which is not linear.
Here's a simplified version of the code I used to fit the restricted cubic splines in the meta-regression:
library(metafor)
spl <- rma(y, y_se, mods = ~ rcs(x, c(1,2,3,4,5)), data=data, method="DL", random = ~ 1 | id)
However, the estimates of the regression between the knots are very high (+1111) and low (-1826), when I expected much less variation (-2 to 2).
Model Results:
estimate
intrcpt 89.7615
rcs(x, c(1,2,3,4,5))x 14.0133
rcs(x, c(1,2,3,4,5))x ' -112.4379
rcs(x, c(1,2,3,4,5))x '' 1111.1094
rcs(x, c(1,2,3,4,5))x ''' -1826.6025
And when I plot these, it gives me also a very odd plot:
with(predict(spl, dose), plot(dose, pred, type = "l"))
Do you have an idea why? Is this because rcs() cannot be used with rma()? If this is the problem, what is the alternative to include a restricted cubic spline model within rma()?
Thanks in advance for your help!
rma()
does not have arandom
argument. 2) You appear to pass the SE of the estimates as the second argument. However, the second argument ofrma()
is for the variances. Either userma(y, y_se^2, ...)
orrma(y, sei=y_se, ...)
. 3) You also may want to mention thatrcs()
comes from therms
package. Note that 1) and 2) do not explain these strange results. In general,rma()
plays nicely withrcs()
, but unless you provide a fully reproducible example illustrating the problems you are encountering, it will be next to impossible for me (or anybody else) to help. $\endgroup$