dxy logo
首页丁香园病例库全部版块
搜索
登录

SAS宏作RCS限制性立方样条

环境卫生学医学生 · 最后编辑于 2022-10-09 · IP 湖北湖北
4856 浏览
这个帖子发布于 4 年零 238 天前,其中的信息可能已发生改变或有所发展。

SAS宏做限制性立方样条挺简单的,需要注意的可能有以下几个参数:

  1. AIC:在SAS的LOG窗口查看AIC值。可比较不同knot数目下的AIC值,AIC越小,说明模型能更好地解释暴露,从而为最终模型选择knot数和位置。
  2. Exp_beta:default为0,此时spline展示Ln(OR/HR)与暴露的关系,可直观地观察暴露和结局的线性趋势如何。而=1时,spline展示OR/HR与暴露的关系。
  3. Knots:可借助AIC判断3/5-knot更好。因为knot的位置对spline的形状影响很小,故此确定knot数目后,推荐使用Durrleman and Simon的经典knot位置,即5,25,50,75,95;或5,25,75,95;或5,50,95。
  4. RCS适用于,当logistic/cox回归有意义,但是线性回归没意义时,即考虑暴露和结局之间存在关联,但该关联可能不是线性的。所以,RCS是看“非线性”关系是否存在,而不是什么dose-response relationship please !
  5. ref_val :暴露水平的参考值。changed the reference value. ref_val = 0 (reference is set when exposure value is 0) is changed to ref_val= 10th or median. 改变ref_val 看图像的变化
  6. y_ref_line:if set to 1, a horizontal dashed green line is displayed to materialize the null hypothesis H0. The Y-coordinate of the line is 0 when a linear regression is requested, or when a logistic or a Cox


*先运行RCS的宏;

*在调用宏之前,先file-import dataset;

*如无图像输出,查看log是否缺少字体文件,百度下载sas字体文件,解压后复制到SAS安装目录中的\ReportFontsforClients\9.4\即可;

还有宏本身生成的图片清晰度很低,这里我用ods命令创建高清的rtf输出(用word即可打开)

ods 语句:创建rtf文件(类似word的多媒体文件),输出运行后的结果数据和图像。

ods listing image_dpi=600; *更改图片清晰度至600 dpi;

ods rtf file = ‘file_location\file_name.rtf’ ; *创建rtf文件;

ods rtf select where =(_name_='file_name'); *命名rtf文件。注意文件名称与上一行语句一致;

ods rtf close; *完成rtf功能;


logistic回归的示例代码:

ods listing image_dpi=600;

ods rtf file="D:\Timo\curve_recover.rtf";

ods rtf select where =(_name_='curve_recover');


%RCS_Reg(infile=recover,

main_spline_var=Y,

ref_val=0,

avk_msv=0,

knots_msv=5 25 50 75 95,

typ_reg=log,

dep_var=X,


*adjusted variables must be converted into dummies if there are categorical variables;

adjust_var=age gender education_2 education_3 education_4,

exp_beta=1,

specif_val=0 20 42,

y_ref_line=1,

max_xaxis=100,

no_delete_files=1);

ods rtf close;


具体这些参数如何设置,可以看我的附件。附件复制到sas中,就是sas宏。其中就有宏的作者对各个参数的说明,认真看上半小时,没理由不懂。

~喜欢或者觉得有用就给我点赞和投币吧~

~会持续更新更多统计方面的资源~

RCS_introduction.docx (107 KB)

全部讨论(0)

默认最新
avatar
5
分享帖子
share-weibo分享到微博
share-weibo分享到微信
认证
返回顶部