sas logistic回归案例
时间: 2023-07-19 20:53:19 浏览: 134
好的,以下是一个 SAS Logistic 回归分析的案例:
假设我们有一个医疗数据集,其中包含了患者的一些基本信息和是否患有糖尿病的标记。我们希望使用 Logistic 回归来预测患糖尿病的概率。
首先,我们需要导入数据。假设数据集的文件名为 diabetes.csv,其中第一列为标记(1表示患糖尿病,0表示不患糖尿病),后面的列为各种患病相关的特征,如年龄、体重等。
```sas
data diabetes;
infile 'diabetes.csv' delimiter=',' dsd;
input label age weight bp cholesterol;
run;
```
接下来,我们可以使用 PROC LOGISTIC 进行回归分析。假设我们使用所有特征进行分析。
```sas
proc logistic data=diabetes;
model label = age weight bp cholesterol / selection=stepwise;
run;
```
在这个例子中,我们使用了 stepwise 参数进行变量选择。这个参数会自动选择最优的特征组合。运行完毕后,我们可以查看模型的参数估计值和显著性检验结果。
此外,我们还可以使用 ROC 曲线和 AUC 值来评估模型的性能。可以使用以下代码来生成 ROC 曲线和计算 AUC 值:
```sas
proc logistic data=diabetes;
model label = age weight bp cholesterol / selection=stepwise;
roc 'ROC Curve' / plot=roc;
roc 'AUC' / summarize;
run;
```
最后,我们可以使用这个模型来预测新的患病概率。假设我们有一个新的患者,他的年龄为 50 岁,体重为 80 公斤,血压为 140 mmHg,胆固醇为 200 mg/dL。我们可以使用以下代码来预测他患糖尿病的概率:
```sas
data new_patient;
input age weight bp cholesterol;
cards;
50 80 140 200
;
run;
proc logistic data=new_patient;
score data=diabetes out=prediction;
run;
proc print data=prediction;
var _all_;
run;
```
这个代码会将新的患者数据输入到模型中,然后根据模型计算出他患病的概率。最后的输出结果会显示出这个患者的预测概率。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)