I’m using SAS 9.4. Please run the attached code. I would like to add the regression line to the third of the three scatterplots. But, so far, I haven’t been able to find an easy way to do that. Of course, I can use the SG Annotation facility to add the line, but that’s inconvenient because it requires explicit computation and specification of the attributes of the line. It’s statistically sensible to add the line to the scatterplot because the scatterplot reflects a real situation in experimental research. This is the situation where the predictor variable is discrete (by virtue of the fact that this variable was MANIPULATED to have discrete values by the experimenter) but the underlying DIMENSION of the predictor variable is continuous. Therefore, adding the regression line to the scatterplot is reasonable as a way of (roughly) illustrating through interpolation what the values of the response variable do between the two used values of the predictor variable on the horizontal axis of the scatterplot. Also, the regression line helps the viewer to recognize the continuous nature of the relationship between the response and predictor variables. Is there an easy way to add the line? I understand that scatterplots with “dodging” points are difficult to program, and they may run into situations where the points from different values on the horizontal axis collide with each other. But that doesn’t mean that the scatterplots shouldn’t be available for the many cases in which the points don’t collide and thus the scatterplots are useful. Presumably the programmer could build a map in memory of the array of points that are lying on the surface of the scatterplot. And if the array is too tight and therefore the points start to collide with each other, then the procedure could try to make the points smaller. And if that doesn’t work, the procedure could stop with an error message that clearly explains the problem. Note that I’ve got SAS to generate the tightly dodged points on the third scatterplot by specifying that the horizontal axis is discrete. However, that gives rise to another serious problem if the variable plotted on the horizontal axis has values that aren’t equally spaced. In that case, if I specify that the horizontal axis is discrete, then the values on the horizontal axis will equally spaced on the axis even though in reality they should be spaced according to the values. For me, the ideal solution to this problem would be to have an option on the SCATTER statement that permits “dodging” of points in the horizontal direction, where “dodging” means that the points are only offset enough to avoid collisions, and not randomly offset as they are with the “jitter” option. I suppose that dodging in the vertical direction or dodging in both directions might also sometimes be useful. Thanks for your help, Don Macnaughton
... View more