在metafor中为带有样条线的多变量模型生成regplot(边际关系)
我试图使用 metafor
包中的 regplot()
生成回归图,通过使用 rms 将连续预测器拟合为受限三次样条
R 中的包,在多变量回归的背景下。
但是,仔细查看此处列出的所有示例后: https://wviechtb.github.io /metafor/reference/regplot.html,我无法重现所需的图(即,建模为受限三次样条的连续预测器的回归图)。
这是一个可重现的示例:
library(metafor)
library(rms)
dat <- dat.bcg
#Fitting the meta-analysis
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat)
#Fit a multivariable meta-regression with ablat as a rcs with 3 knots
res <- rma(yi, vi, mods = ~ rcs(ablat,3)+year+alloc, data=dat)
模型的结果报告如下:
Model Results:
estimate se zval pval ci.lb ci.ub
intrcpt -24.8731 38.8083 -0.6409 0.5216 -100.9361 51.1898
rcs(ablat, 3)ablat 0.0043 0.0290 0.1497 0.8810 -0.0525 0.0611
rcs(ablat, 3)ablat' -0.0504 0.0466 -1.0799 0.2802 -0.1418 0.0410
year 0.0125 0.0196 0.6384 0.5232 -0.0259 0.0509
allocrandom -0.3525 0.4090 -0.8618 0.3888 -1.1541 0.4491
allocsystematic -0.2187 0.4832 -0.4526 0.6508 -1.1659 0.7284
现在,如果我想生成该模型的正则图(即样条预测变量和效应大小之间的边际关系),我必须使用:
regplot(res, mod="rcs(ablat, 3)ablat")
但是生成的图(如下报告)在我看来,只考虑了样条建模变量的第一项:
始终如一,如果我将 regplot 的调用更改为 regplot(res, mod="rcs(ablat, 3)ablat'")
(即,指定多变量回归模型中 ablat 的非线性项作为调节变量)。
我尝试通过 predict()
函数预先指定预测,然后将参数传递给 regplot
,但我仍然无法生成所需的绘图。
I was trying to produce a regression plot with the regplot()
in the metafor
package, fitting a continuous predictor as a restricted cubic spline through the use of the rms
package in R, in the context of a multivariable regression.
However, after carefully reviewing all the examples listed here: https://wviechtb.github.io/metafor/reference/regplot.html, I was unable to reproduce the plot desired (i.e., the regression plot of the continuous predictor modelled as a restricted cubic spline).
Here is a reproducible example:
library(metafor)
library(rms)
dat <- dat.bcg
#Fitting the meta-analysis
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat)
#Fit a multivariable meta-regression with ablat as a rcs with 3 knots
res <- rma(yi, vi, mods = ~ rcs(ablat,3)+year+alloc, data=dat)
The result of the model is reported below:
Model Results:
estimate se zval pval ci.lb ci.ub
intrcpt -24.8731 38.8083 -0.6409 0.5216 -100.9361 51.1898
rcs(ablat, 3)ablat 0.0043 0.0290 0.1497 0.8810 -0.0525 0.0611
rcs(ablat, 3)ablat' -0.0504 0.0466 -1.0799 0.2802 -0.1418 0.0410
year 0.0125 0.0196 0.6384 0.5232 -0.0259 0.0509
allocrandom -0.3525 0.4090 -0.8618 0.3888 -1.1541 0.4491
allocsystematic -0.2187 0.4832 -0.4526 0.6508 -1.1659 0.7284
Now if I want to produce a regplot of this model (i.e., the marginal relationship between the spline predictor and the effect size), I must use:
regplot(res, mod="rcs(ablat, 3)ablat")
But the resulting plot (reported below) seems to me taking into account only the first term of the spline-modelled variable:
Consistently, I am able to produce another plot if I change my call of regplot to regplot(res, mod="rcs(ablat, 3)ablat'")
(i.e., specifying as the moderator variable the non-linear term of ablat in the multivariable regression model).
I have tried to pre-specify prediction through the predict()
function and then passing the argument to regplot
, but I am still unable to produce the desired plot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里发布解决方案,在评论中 @Wolfgang 的不可估量的帮助后,我设法安排了该解决方案,以防万一其他人将来需要:
这是结果图,代表 rcs 的边际关系(ablat,3) 效果大小:
I am posting here the solution, that I have managed to arrange after the inestimable help of @Wolfgang in the comments, just in case someone else needs in the future:
And here's the resulting plot, with represent the marginal relation of
rcs(ablat,3)
with the effect size: