如何在SAS中进行逻辑回归预测概率? [英] How to predict probability in logistic regression in SAS?
问题描述
我对SAS非常陌生,并尝试使用SAS中的逻辑回归来预测概率.我从SAS支持网站获得以下代码:
I am very new to SAS and trying to predict probabilities using logistic regression in SAS. I got the code below from SAS Support web site:
data vaso;
length Response $12;
input Volume Rate Response @@;
LogVolume=log(Volume);
LogRate=log(Rate);
datalines;
3.70 0.825 constrict 3.50 1.09 constrict
1.25 2.50 constrict 0.75 1.50 constrict
0.80 3.20 constrict 0.70 3.50 constrict
0.60 0.75 no_constrict 1.10 1.70 no_constrict
0.90 0.75 no_constrict 0.90 0.45 no_constrict
0.80 0.57 no_constrict 0.55 2.75 no_constrict
0.60 3.00 no_constrict 1.40 2.33 constrict
0.75 3.75 constrict 2.30 1.64 constrict
3.20 1.60 constrict 0.85 1.415 constrict
1.70 1.06 no_constrict 1.80 1.80 constrict
0.40 2.00 no_constrict 0.95 1.36 no_constrict
1.35 1.35 no_constrict 1.50 1.36 no_constrict
1.60 1.78 constrict 0.60 1.50 no_constrict
1.80 1.50 constrict 0.95 1.90 no_constrict
1.90 0.95 constrict 1.60 0.40 no_constrict
2.70 0.75 constrict 2.35 0.03 no_constrict
1.10 1.83 no_constrict 1.10 2.20 constrict
1.20 2.00 constrict 0.80 3.33 constrict
0.95 1.90 no_constrict 0.75 1.90 no_constrict
1.30 1.625 constrict
;
ods graphics on;
proc logistic data=vaso PLOTS = (ROC EFFECT);
model Response(event='constrict')=LogRate LogVolume
/ctable pprob=0.5 selection=forward rsquare link=logit expb ;
run;
ods graphics off;
我想知道当我有logVolume= 1.5
和logRate=1.3
时如何预测概率.另外,您能解释一下length Response $12
的意思吗?
I am wondering how I could predict the probability when I have logVolume= 1.5
and logRate=1.3
. Also, can you please explain what length Response $12
above means?
推荐答案
2种获取预测值的方法: 1.在过程物流中使用分数方法 2.将数据添加到原始数据集中,减去响应变量,然后在输出数据集中获得预测.
2 ways to get predicted values: 1. Using Score method in proc logistic 2. Adding the data to the original data set, minus the response variable and getting the prediction in the output dataset.
下面的代码都对这两种方法进行了说明:
Both are illustrated in the code below:
*Create an dataset with the values you want predictions for;
data pred_wanted;
input logvolume lograte;
cards;
1.5 1.3
;
run;
*append to predicted data set;
data vaso2;
set vaso pred_wanted;
run;
*run model with new options;
proc logistic data=vaso2 ;
model Response(event='constrict')=LogRate LogVolume
/ctable pprob=0.5 selection=forward rsquare link=logit expb ;
*Get output from vaso2 (method2);
output out=estimates p=est_response;
*Get output from pred_wanted(method1);
score data=pred_wanted out=estimates2;
run;
这篇关于如何在SAS中进行逻辑回归预测概率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!