Example 3d Graphs from 
Multiple Regression: Testing and Interpreting Interactions
by Leona Aiken and Stephen West

These examples show how you can use SAS to produce three dimensional spin plots corresponding to the figures shown in Aiken and West.  A 2-dimensional page sometimes cannot convey the nature of a three dimensional relationship, so these examples are aimed to help further illustrate the examples in Aiken and West and to show how you can demonstrate the relationships that you find using three dimensional plots as shown in the examples below.

See the SAS FAQ on Visualizing interactions among continuous variables in multiple regression for information on downloading and using the SAS macros used here.

This first example shows how to make a spin plot of the graph shown on page 41 in Figure 2.1a.  The outfile parameter specifies where the output file will be stored.  It is stored as a .gif file that you can view with a web browser (the output is not viewable from within SAS)The bx1=1.14,bx2=3.58,bx1x2=2.58,cons=2.54 parameters provide the regression equation to be plotted (which matches the one from Figure 2.1a.).  The x1lo=-2,x1hi=2,x1by=.2,x2lo=-1,x2hi=1,x2by=.2 parameters specify the range of values to be plotted for x1 and x2 (note that we refer to the axes as x1 and x2, whereas Aiken and West refer to them as X and Z, so X corresponds to x1 and Z corresponds to x2).  Finally, the title parameter is used to provide a title (no title) and the plot= zmin=-12 zmax=18 parameter provides options to specify the high and low values on the y axis (but SAS refers to it as the Z axis).

* figure 2.1a, page 41, plane ;
%sp_plota(outfile="c:\aiken_west\spin21a_plane.gif",
          bx1=1.14,bx2=3.58,bx1x2=2.58,cons=2.54,
          x1lo=-2,x1hi=2,x1by=.2,
          x2lo=-1,x2hi=1,x2by=.2,
          title=" ",
          plot= zmin=-12 zmax=18 );

This next example shows how to get Figure 2.1b.  It is essentially the same as Figure 2.1a, except that the coefficients are different and the scale is different for the Y axis.

* figure 2.1b, page 41, plane ;
%sp_plota(outfile="c:\aiken_west\spin21b_plane.gif",
          bx1=-24.68,bx2=-9.33,bx1x2=2.58,cons=90.15,
          x1lo=0,x1hi=6,x1by=.2,
          x2lo=8,x2hi=12,x2by=2,
          title=" ",
          plot= zmin=-60 zmax=80 );

This example below shows how to get Figure 5.2a as a 3d spin plot.  We supply the coefficients as we have above, except that this also includes bx1x1 which reflects the coefficient for x1-squared.  As you can see, the plane is curved with respect to x1.

* figure 5.2a page 68, plane ;
%sp_plota(outfile="c:\aiken_west\spin52a_plane.gif",
          bx1=1.59,bx1x1=6.18,bx2=3.55,cons=3.44,
          x1lo=-1,x1hi=1,x1by=.2,
          x2lo=-2.2,x2hi=2.2,x2by=.2,
          title=" ",
          plot= zmin=-6 zmax=20 yticknum=3);

This example below shows how to get Figure 5.2b as a 3d spin plot.  This example adds the bx1x2 term which causes the plane to flare upward as x1 and x2 jointly increase and to dip as x1 and x2 jointly decrease.

* figure 5.2b page 68, plane ;
%sp_plota(outfile="c:\aiken_west\spin52b_plane.gif",
          bx1=1.13,bx1x1=3.56,bx2=3.61,bx1x2=2.93,cons=3.44,
          x1lo=-1,x1hi=1,x1by=.2,
          x2lo=-2.2,x2hi=2.2,x2by=.2,
          title=" ",
          plot= zmin=-10 zmax=30 yticknum=3);

The example below shows how to get Figure 5.2c, which adds the bx1x1x2 term, the interaction of x1-squared by x2.  To better see the subtleties of this relationship, we increased the size of this plot (via the gopt=vsize=4 hsize=6 option).  As you can see, this additional term makes the curve U shaped between X1 and Y when X2 is high, but the relationship becomes a slight inverted U when X2 is low.

* figure 5.2c page 68, plane ;
%sp_plota(outfile="c:\aiken_west\spin52c_plane.gif",
          bx1=-2.04,bx1x1=3.00,bx2=2.14,bx1x2=2.79,bx1x1x2=1.96,cons=3.50,
          x1lo=-1,x1hi=1,x1by=.2,
          x2lo=-2.2,x2hi=2.2,x2by=.2,
          title=" ",
          plot= zmin=-16 zmax=20 yticknum=3, gopt=vsize=4 hsize=6);


How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.