%sp_plotbx1x2 ---------------------------------------------------------------------- Creates an animated 3 dimensional plot of a regression surface with a changing interaction coefficient Description The %sp_plotbx1x2 macro will create an animated 3 dimensional plot of a regression surface based on the coefficients from two predictors and their interaction in a regression equation. The graph changes as the interaction incrementally changes between a specified minimum and maximum value. The graph can be saved as a .gif file and used in a web page. The individual plots that make up the animated gif can be viewed individually in the graph window of SAS. The code for this macro should end in a semicolon in order to avoid unnecessary error messages in the log file. Syntax %sp_plotbx1x2(outfile="c:\sp_plotbx1x2.gif", data=_spinplt, x1lo=-10, x1hi=10, x1by=1, x2lo=-10, x2hi=10, x2by=1, cons=0, bx1=0, bx2=0, bx1x2=0, bx1x1=0, bx2x2=0, bx1x1x2=0, bx1x2x2=0, dev=gif373, title=Spin Plot, cmd=plot, plot=, gopt=, angle=100, slen=6, bx1x2_lo=-5, bx1x2_hi=5, bx1x2_by=1 ); _spinplt - name of dataset where data created to be plotted in graph is saved x1lo - the minimum value of the range of x1 x1hi - the maximum value of the range of x1 x1by - the spacing of the grid of the regression surface x2lo - the minimum value of the range of x2 x2hi - the maximum value of the range of x2 x2by - the spacing of the grid of the regression surface const - the value of the constant in the regression function bx1 - the value of the coefficient of x1 in the regression function bx2 - the value of the coefficient of x2 in the regression function bx1x2 - the value of the coefficient of x1*x2 in the regression function bx1x1 - the value of the coefficient of x1*x1 in the regression function bx2x2 - the value of the coefficient of x2*x2 in the regression function bx1x1x2 - the value of the coefficient of x1*x1*x2 in the regression function bx1x2x2 - the value of the coefficient of x1*x2*x2 in the regression function outfile - saves the graph as a .gif file with the given name data - saves the data with the given name dev - specifies the graphic device used title - the title displayed at the top of the graph cmd - specifies if the graph is a plot (the data points define a surface) or a scatter plot (represents each data point with a specified shape, the default is a pyramid) plot - specifies other options for the graph, the options available will depend on whether cmd was specified as scatter or plot (plot is the default) gopt - specifies other goptions which can modify the detailed options on the size, color or the style of the plot angle - the angle the plot is viewed at slen - the length of the coefficient of x1 in the title bx1x2_lo - the minimum value of the coefficient of x1 bx1x2_hi - the maximum value of the coefficient of x1 bx1x2_by - the incriments that the bx1 is changing by, must be a positive number Examples %sp_plotbx1x2(outfile='c:\sp_plotbx1x2a.gif'); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2b.gif', cons=3, bx1=1, bx2=-2); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2c.gif',bx1x2=-1, bx1_lo=2, bx1_hi=8, bx1_by=1, slen=4); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2d.gif', cons=1, bx2=1.7, bx1x2=-.5, plot=grid, title=Great Plot!); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2e.gif', cons=0, bx2=.5, bx1x2=-.4, plot=grid cbottom=cyan ctop=purple, bx1_lo=-2, bx1_hi=4, bx1_by=1); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2f.gif', bx2=1.7, bx1x2=.5, plot= grid ctop=cyan cbottom=blue caxis=green); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2g.gif', cons=0, bx2=3, slen=6, cmd=scatter, gopt= delay=10, plot= shape='balloon' noneedle size=.6); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2h.gif', bx1x2=-1.5 , cmd=scatter, plot= noneedle shape='spade' size=.8, gopt = border); %sp_plotbx1x2(outfile='c:\sp_plotbx1x2i.gif', bx1x2x2=.1); Author Michael Mitchell mnm@ucla.edu UCLA Academic Technology Services Statistical Consulting Group Also See See a complete example in http://www.ats.ucla.edu/stat/sas/examples/aw/example_graphs.htm http://www.ats.ucla.edu/stat/sas/teach/reg_int/reg_int_cont.htm For more details about the cmd, plot and gopt options please refer to following sections in the SAS Manuals http://sasdocs.ats.ucla.edu/gref/z3d-plot.htm http://sasdocs.ats.ucla.edu/gref/zscatter.htm http://sasdocs.ats.ucla.edu/gref/zonschap.htm Also see the macro itself from http://www.ats.ucla.edu/stat/sas/macros/sp_plotbx1x2.sas.txt Also see the books (http://www.ats.ucla.edu/stat/books/ ) Multiple Regression: Testing and Interpreting Interactions by Leona S. Aiken and Steven G. West Interaction Effects in Multiple Regression by James Jaccard, Robert Turrisi and Choi K. Wan