Running mean or line smoothing ------------------------------ Author: Patrick Royston, Royal Postgraduate Medical School, London Support: FAX (011)-44-81-740 3119 or write. ^ksm^ yvar xvar [^if^ exp] [^in^ range] [^,^ [[^l^ine] [^w^eight] | [^low^ess]] [^bw^idth^(^#^)^] [^log^it] [^a^djust] [^gen(^newvar^)^] [[^nog^raph] | [graph_options]] ] Carries out unweighted or locally weighted smoothing of yvar on xvar and dis- plays a smoothed scatterplot of the results. Options are: ^line^ running-line least squares smoothing. Default is running mean. ^weight^ Use Cleveland's (1979) tricube weighting function. Default is unweighted. ^lowess^ equivalent to ^line weight^ and equivalent to Cleveland's "lowess" running-line smoother. ^bwidth(^#^)^ centered subsets of ^bwidth^*N observations are used for cal- culating the smoothed value of each point in the data except for the end points, where smaller, uncentered subsets are used. The greater the bwidth, the greater the smoothing. Default is 0.8. ^logit^ transforms smoothed yvar to logits. Predicted values <=.0001 or >=.9999 are set to 1/N and 1-1/N, respectively, before taking logits. ^adjust^ adjusts mean of smoothed yvar to equal mean of yvar, by multi- lying by an appropriate factor. Useful when smoothing binary (0/1) data. ^nograph^ suppress dislaying the graph, often used with ^gen()^. ^gen(^newvar^)^ in addition or instead of displaying graph, create newvar con- taining smoothed values of yvar. All the normal graph options are valid. WARNING: This program is computationaly intensive and may therefore take a long time time to run on a slow computer. lowess calculations on 1,000 obs- ervations, for instance, require estimating 1,000 regressions. Try a small data set first if in doubt. Examples ------- . ^ksm bp time, bwidth(.5) ylab xlab^ . ^ksm died haemo, lowess nograph gen(dsmooth) adjust logit^