* * Example of non-parametric regression from pp 224-227 * open data pulppric.dat data(format=free,org=columns) 1 25 shipments price * * The non-parametric regression is done using the instruction NPREG. NPREG * doesn't do the precise method of locally weighted regression described in the * text; METHOD=LOWESS takes as its stiffness parameter the fraction of the data * set to be considered "neighbors" to be included in the local regression. (The * more distant members of this are then downweighted). Here, the fraction needs * to be boosted a bit from the default of .5 to get roughly the same fit as shown. * * NPREG generates a pair of series - the first ("grid") is the grid of "x" values * and the second ("fit") are the corresponding estimated curve values. * npreg(method=lowess,fract=.75) shipments price / grid fit * * To get the smoothed curve on the same graph as the observed points, you need to * use the options OVERLAY=LINE and OVSAME. OVERLAY allows two different styles to * share the graph. OVSAME forces both pairs of series to share the same vertical * axis. * scatter(footer="Figure 5-18 Locally Weighted Fit",$ hlabel="World pulp price",vlabel="Pulp shipments",overlay=line,ovsame) 2 # price shipments # grid fit