SAS宏作RCS限制性立方样条
SAS宏做限制性立方样条挺简单的,需要注意的可能有以下几个参数:
- AIC:在SAS的LOG窗口查看AIC值。可比较不同knot数目下的AIC值,AIC越小,说明模型能更好地解释暴露,从而为最终模型选择knot数和位置。
- Exp_beta:default为0,此时spline展示Ln(OR/HR)与暴露的关系,可直观地观察暴露和结局的线性趋势如何。而=1时,spline展示OR/HR与暴露的关系。
- Knots:可借助AIC判断3/5-knot更好。因为knot的位置对spline的形状影响很小,故此确定knot数目后,推荐使用Durrleman and Simon的经典knot位置,即5,25,50,75,95;或5,25,75,95;或5,50,95。
- RCS适用于,当logistic/cox回归有意义,但是线性回归没意义时,即考虑暴露和结局之间存在关联,但该关联可能不是线性的。所以,RCS是看“非线性”关系是否存在,而不是什么dose-response relationship please !
- 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 看图像的变化
- 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宏。其中就有宏的作者对各个参数的说明,认真看上半小时,没理由不懂。
~喜欢或者觉得有用就给我点赞和投币吧~
~会持续更新更多统计方面的资源~