继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

SAS Loess Scatter Plot

乌然娅措
关注TA
已关注
手记 64
粉丝 22
获赞 12

SAS Day 32: Loess Model Scatter Plot

When I was in Middle School, Sin(x) and Cos(x) are my favorite curves, because they are so predictable! Once we know the cycle and amplitude, we can solve everything about it. 
However, in statistical modeling, oscillating curves are not so welcomed. Today we will introduce the Loess Plot for finding a curve of best fit without assuming the data must fit some distribution shape.

Loess regression is a nonparametric technique that uses locally weighted regression to fit a smooth curve through points in a scatter plot.

LOESS: Locally weighted scatter plot smoothing

we will use ENSO dataset to perform a Loess graph.

ENSO-El Nino Southern Oscillation dataset capture the monthly averaged atmospheric pressure differences between Easter Island and Darwin, Australia for 168 months.

[caption id=“attachment_2190” align=“alignnone” width=“750”]

Cleverpix / Pixabay[/caption]

Basic Loess Graph with 95% Confidence Limits

image

proc sgplot data=sashelp.enso;
title “losess Fit”;
loess y=pressure x=month/clm;
run;

Advanced Loess Graph with Linear, Polynomial, and Penalized B-Spline Model comparison

proc sgplot data=sashelp.enso;
title “Fit Functions”;
reg y=pressure x=month/legendlabel=“Linear”;
reg y=pressure x=month/legendlabel=“Cubic” degree=3 nomarkers;
pbspline y=pressure x=month/nomarkers;
loess y=pressure x=month/nomarkers;
run;

image

proc template;
define statgraph Fits;
begingraph;
entrytitle “Fit Functions”;
layout overlay;
scatterplot y=pressure x=month;
regressionplot y=pressure x=month/lineattrs=GraphData1 name=“Linear”;
regressionplot y=pressure x=month/lineattrs=GraphData2 name=“Cubic” degree=3;
pbsplineplot y=pressure x=month/lineattrs=GraphData3 name=“Penalized B-spline”;
loessplot y=pressure x=month/lineattrs=GraphData4 name=“Loess”;
discretelegend “Linear” “Cubic” “Penalized B-spline” “Loess”;
endlayout;
endgraph;
end;
run;

proc sgrender data=sashelp.enso template=Fits;
run;

Both Proc SGPLOT and Proc Template would generate the same result. As we can see, Linear and 3rd-degree Polynomial are not great approaches for ENSO dataset.  The statistical model winner for ENSO dataset are LOESS and Penalized B-Spline.

Reference:

Creating Statistical Graphics in SAS,
*Warren F.Kuhfeld  *

Happy Practicing!  🍹

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP