Tags:
create new tag
, view all tags, tagging instructions
Return to Stat Tools Home

Title: ScatterW Interaction

Evaluate this tool by clicking on the stars:

  • 5 stars = highest rating
  • 1 star = lowest
  • SCORE = average of all votes
Tools Overall Rating
Score: 0, My vote: 0, Total votes: 0
Code Works Well
Score: 0, My vote: 0, Total votes: 0
Good Instructions
Score: 0, My vote: 0, Total votes: 0

Add Comments and then click on "Add comment" button

Please note any errors found in the macros.

 

StatToolsForm edit

Type of Tool R-Function
Title ScatterW Interaction
Programmer/Email SallyThurston thurston@bst.rochester.edu
Contributing Site Rochester
Description This function makes a scatterplot of y versus x, with different symbols for the two levels of a dummy variable, where the dummy variable is coded as 0 or 1. From the regression of y on x, dummy variable, interaction (x * dummy variable) and optionally other covariates, the function superimposes on the plot the separate slope of y on x for dummy variable = 0 or 1. These slopes are the predicted lines at mean values of the other covariates (in "covnames" arguments). Options include adding a legend, printing out the regression results to screen, and varying color, size, line type, etc of the lines, as well as plotting symbol and size of the points in the plot.
Classification Graph Type Other, Scatterplot
Graph_Type Scatterplot, Other
References

Datasets Other
Data Any dataset suitable for linear regression with an interaction of a dummy variable with another variable. The function is illustrated with airquality (a default dataset in R)
Software Program R
Software R version 2.9.0 (2009-04-17)
Macro Parameters ### ARGUMENTS:
### tdat is database
### yname is name of y variable in tdat
### xname is name of x variable in tdat, for which we want partial plot
### dummyvar is name of dummy variable for which we want interaction
### x0name is name of x*I(dummy variable==0) (THIS MUST BE PART OF THE DATASET)
### x1name is name of x*I(dummy variable==1) (THIS MUST BE PART OF THE DATASET)
### covnames is vector of names of remaining variables
### txlab is name to go on x-axis of plot (default is xname)
### tylab is name to go on y-axis of plot (default is yname)
### cex.xylab is size of x and y axes
### ttitle is title of plot (default is none)
### cex.title is size of title
### print.results=TRUE if want to print regression results on screen
###
### show.legend=TRUE means include legend
### legend.x0name is what to go in the legend to indicate slope for x0
### legend.x1name is what to go in the legend to indicate slope for x1
### legend.loc is location of legend. Possible values are:
### "topleft","topright","bottomleft","bottomright","top","bottom","left","right","center"
### cex.legend is size of legend
###
### confidence.bands=TRUE if want confidence bands on the plot
### lty.lev0 is line type for plotting the line for dummy=0
### lty.lev1 is line type for plotting the line for dummy=1
### lty.confidence is line type for the confidence interval
### col.lev0 is color for points and line for dummy=0
### col.lev1 is color for points and line for dummy=1
### pch.lev0 is plotting character for dummy=0
### pch.lev1 is plotting character for dummy=1
### cex.points is size of points
###
### lwd.slope is lwd for slopes
### lwd.confidence is lwd for confidence bands
###
### The user has the option to either view the plots on the screen
### (save.plots=FALSE, which is the default), or to save the plots
### (save.plots=TRUE)
### If save.plots=TRUE, save either to pdf files (type.plots="pdf", the default)
### or as eps files (type.plots="eps"). The user controls the base name
### of the plots with the basename= argument, so if basename=silly and
### type.plots="pdf" then the plots will be silly1.pdf, silly2.pdf, etc.
###
### ndigits is number of digits to show when printing regression model
R-Code - Attachment

R-Code scatterWinteraction.R: This is the R function file
SAS-Code - Attachment

SAS-Code

Stata-Code - Attachment

Stata-Code

Other Code - Attachment

Other Code

Called Data Manipulation

Called Tool/Utility

Called Checking Macro

Called Other

Creation-Date September 17, 2012
Revision-Date

Example Code R Example Code
Example Output R Example Output
SAS Examples

SAS_Example_Code

SAS_Example_Output

R Examples

R_Example_Code scatterWinteractionExample.R: scatterWinteraction example file (in R)
scatterWinteractionExample.Rnw: scatterWinteraction example file (in Sweave)
R_Example_Output scatterWinteractionExample.pdf: scatterWinteraction example output (from running the example Sweave program)
Stats Examples

Special Features

Special Features Attached

Special Features Text

Notes1-Legend Section with calls to needed macros
Notes1

Notes2-Legend Macro call with fully specified parameters
Notes2

Notes3-Legend Section with definitions of global macro parameters
Notes3

Notes4-Legend Section with definitions of local macro variables
Notes4

See Also

Checklists

Stat Tools Disclaimer

Discliamer The views expressed within CTSpedia are those of the author and must not be taken to represent policy or guidance on the behalf of any organization or institution with which the author is affiliated.
Permission Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT OLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Reference Image

Topic revision: r3 - 18 Sep 2012 - 13:27:36 - MaryBanach
 

Copyright & by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CTSPedia? Send feedback