.- help for ^running^ (STB-41: sed9.1) .- Symmetric nearest neighbor smoothing ------------------------------------- ^running^ yvar [xvar] [^if^ exp] [^in^ range] [weight] [^,^ ^ci^ ^d^ouble ^gen(^newvar^)^ ^gense(^sevar^)^ ^genb(^bvar^)^ ^k^nn^(^# | knnvar^)^ ^log^it ^m^ean ^nog^raph ^r^epeat^(^#^)^ ^sp^an^(^#^)^ ^tw^ice graph_options ] ^running^ smooths yvar on xvar. By default the smoothed version is a running line: a running mean is also available. A graph of yvar together with its smooth is plotted against xvar, unless suppressed. If xvar is not provided, yvar is smoothed against the ordered observations. Only analytic weights (^aweight^) are allowed; see help @weights@. Options ------- ^ci^ produces a pointwise confidence interval for the smoothed values of yvar. The width is determined by the current value of the macro $^S_level^. Not available with ^twice^, ^repeat^ or ^logit^. ^double^ doubles the value of ^repeat^. If ^repeat^ is not specified, ^double^ is equivalent to ^repeat(2)^. ^gen(^newvar^)^ creates newvar containing the smoothed values of yvar. Note that newvar will be on a logit scale if ^logit^ is used. ^gense(^sevar^)^ creates sevar containing the pointwise standard error of smoothed values of yvar. Not available with ^twice^, ^repeat^ or ^logit^. ^genb(^bvar^)^ creates bvar containing the local slope estimates. They constitute a local estimate of the derivative of the smoothed values of yvar with respect to xvar. Not available with ^mean^, ^twice^ or ^logit^. ^nograph^ suppresses the graph. ^knn(^# | knnvar^)^ controls the number (K) of Nearest Neighbors used on each side of the smoothed point. You may specify a constant (#) or a variable (knnvar). The value # is stored in $^S_1^. The greater the value, the greater the smoothing. You are not allowed to specify both ^span()^ and ^knn()^. ^logit^ transforms the smooth and plots the y-axis on a logit scale. Zero-one observations are automatically jittered in the vertical scale and are plotted just above and outside the range of the smoothed curve. ^mean^ specifies running-mean least-squares smoothing; default is running-line. ^repeat(^#^)^ specifies the number of times the data are to be smoothed. The default is 1. Increasing ^repeat^ increases the time it takes to calculate the smooth but improves the smooth. ^repeat(2)^ corresponds to "smoothing the smooth". ^span(^#^)^ controls the span or proportion of the data to be used in the symmetric nearest neighbors. If ^span^ is specified, ^knn^ is defined to be (N*^span^-1)/2, where N is the number of observations. If both ^span^ and ^knn^ are specified, an error results. ^span^ must be be in the range (0,2]. (It must be less than 1 when using ^mean^.) Span 2 corresponds to fitting a straight line. Stored in $^S_2^. ^twice^ carries out Tukey's `twicing' procedure whereby residuals from the original fit are smoothed and added back to the fit to obtain the final smooth ("smoothing the rough" or "reroughing" in Tukey's terminology). The result is somewhat rougher than would have been obtained without the application of twicing, but may be a better fit to the data. graph_options are any of the options allowed with ^graph, twoway^; see ^help^ ^graph^. Graph plots yvar followed by its smooth against xvar, the default options are s(oiii) (or s(.iii) with over 299 observations), c(.lll) and p(23) (or p(2344) when ^ci^ is specified). Remarks ------- Subsets of (2*k+1) observations are used for calculating smoothed values for each point in the data except for end points, for which smaller uncentered subsets are used. The subsets consist of the closest k points with xvar values less than or equal to that of the given point, the point itself, and the closest k points with xvar values greater than or equal to the given point. Since the neighborhoods are asymmetric in the tails, the running-mean is subject to bias in the tails. For this reason the smooth is set to missing in the tails if ^mean^ is specified. Other than in the tails, using ^mean^ will produce the same result as using the default smooth whenever the xvar values are evenly spaced. ^repeat(3)^, for instance, first smooths yvar creating yhat1, say; next yhat1 is smoothed creating yhat2, and finally yhat2 is smoothed creating yhat3. Author ------ Peter Sasieni Imperial Cancer Research Fund, London FAX 44-171-269-3429 Patrick Royston Royal Postgraduate Medical School, London FAX 44-181-383-8573 Also see -------- STB: STB-41 sed9.1, STB-24 sed9 Manual: [R] ksm, [R] smooth On-line: help for @ksm@ and @smooth@