SAS:创建具有对数关系的图

时间:2019-01-19 07:42:09

标签: logging graph sas regression


我有两个变量:价格和克拉。对于回归,我确定我应该同时记录两个变量。现在,我正在尝试使用显示对数关系的曲线来绘制价格对克拉的图表。如何在SAS中创建这样的图形?谢谢。

我尝试了以下代码,但是我没有任何偏移量,因为我没有任何偏移量。但是,没有它们,我似乎无法获得95%的置信区间带。

 proc genmod data=diamonds; 
 model Price = Carat / dist=poisson link=log; 
 effectplot / clm moff; 
 run;

1 个答案:

答案 0 :(得分:2)

我不是GenMod专家,但也许可以使用更简单的SGPLOT日志转换。

此示例代码显示了线性变换和对数变换的图。

data prices; * https://www.creditdonkey.com/diamond-prices.html;
input carat price; 
logcarat = log(carat);
logprice = log(price);
datalines;
0.4 890
0.5 1520
0.75 2940
1 5810
1.5 10610
2 19520
run;

title "SGPLOT scatter with linear axes";
proc sgplot data=prices;
  scatter x=carat y=price;
run; 

title "SGPLOT Scatter with log axes";
proc sgplot data=prices;
  scatter x=carat y=price;
  xaxis type=log;
  yaxis type=log;
run; 

title "SGPLOT Linear Regression";
proc sgplot data=prices;
  reg x=carat y=price / CLM CLI;
run; 

title "SGPLOT Linear Regression of Log of variables";
proc sgplot data=prices;
  reg x=logcarat y=logprice / CLM CLI;
run; 

title "GenMod Effect Plot";
proc genmod data=prices;
  model price=carat;
  effectplot / clm; 
run;

title "GenMod Carat=Price (Poisson)";
proc genmod data=prices;
  model price=carat / dist=poisson;
  effectplot / clm; 
run;

title;

Example Plots