Return to Statistical Graphics Home

Please rate the graphic:

%VOTE{id="Evalgraph" stars1="Graph Rating" global="off" open="off" secret="off" format="| $key | $small
Score: $score, My vote: $mylast, Total votes: $sum |" }%

Please add comments and then click on the "Add comment" button.

%COMMENT%

OriginalStatGraphicsForm edit

Image %LIGHTBOX{ image="scatterdensity.jpg" thumbnail="tn_scatterdensity.jpg" caption="Scatterplot" }% Click to enlarge image.
Title Scatterplot w/ Density and Smoothed Regression
Graph_Subgroup General Principles
Code Added Yes
Description This is a scatterplot of efficacy counts at baseline versus counts at the end of treatment. It includes density estimates of the distributions at both baseline and end of treatment in the margins of the figure. Smoothed regression lines are provided within the scatterplot.
Contributor/Email Mat Soukup (email: Mat.Soukup@fda.hhs.gov)
Background Efficacy comparison of two treatment groups where improvement is defined as a reduction in the count. The data set is a randomly generated data set (currently not provided).

This type of plot allows one to see the bivariate relationship in the baseline and end of treatment counts for all subjets while also included a smoothed regression line which can be used as a way of assessing the treatment effect across all ranges of the baseline count. The densities provide a way to compare the distributions at baseline and end of treatment.
Special Considerations
Date Original
Original Date 2007
Modified Date
Use/Suitability Publication
Software Program R
Software
R-Code - Attachment Scatter Plot Density
R-Code dat <- read.csv('//cdsnas/oebdbdms/Graphics/DataSets/CleanTrial.csv')<br />
base <- subset(dat, visit%in%2)<br />eot <- subset(dat, visit%in%6)<br />
rallx <- range(base$count)<br />rally <- range(eot$count)<br />
lev <- levels(base$trtf)<br />coluer <- c('blue','grey60')<br />
def.par <- par(no.readonly = TRUE) # save default, for resetting... <br />
ctb <- dat$count[dat$visit==2]<br />cte <- dat$count[dat$visit==6]<br />ptrt <- dat$trtf[dat$visit==2]<br />lev <- levels(ptrt)<br />#png('C:/Research/Graphics/Graphs4Display/webpages/classes/pages/images/scatterdensity.png',
# width=500, height=500)


nf <- layout(matrix(c(2,1,3,4),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE) <br />#layout.show(nf)

#Add legend in upper right quadrant
par(mar=c(0,0,0,0))
plot(1:10,1:10, axes=FALSE, type='n', xlab='',ylab='')
points(1,7, col=coluer[1], pch=1, cex=1.5)
points(1,4, col=coluer[2], pch=1, cex=1.5)
text(1.1,7,'Active',col='blue', pos=4, cex=1.5)
text(1.1,4,'Placebo',col='grey60', pos=4, cex=1.5)

par(mar=c(0,4,1,1))

plot(c(min(ctb)-1,max(ctb)+1),c(0,.02), type='n',axes=FALSE,xlab='',ylab='')
dd <- density(ctb[ptrt==lev[1]])<br />lines(dd$x, dd$y, col=coluer[1])
dd2 <- density(ctb[ptrt==lev[2]])<br />lines(dd2$x, dd2$y, col=coluer[2])

par(mar=c(5,4,1,1))
plot(cte~ctb, type='n', xlab='Baseline Count',
ylab='End of Treatment Count',
xlim=c(min(ctb)-1,max(ctb)+1),
ylim=c(min(cte)-1, max(cte)+1))
for(k in 1:length(lev)){
points(cte[ptrt==lev[k]]~ctb[ptrt==lev[k]],
col=coluer[k], pch=1)
plsmo(ctb[ptrt==lev[k]],cte[ptrt==lev[k]], add=TRUE, lty=1,
col=coluer[k],lwd=2)
}
lines(c(-10,200),c(-10,200), lty=2, col='grey60')

par(mar=c(5,0,1,1))

plot(c(0,0.02),c(min(cte)-1,max(cte)+1), type='n',axes=FALSE,xlab='',ylab='')
dd <- density(cte[ptrt==lev[1]])<br />lines(dd$y, dd$x, col=coluer[1])
dd2 <- density(cte[ptrt==lev[2]])<br />lines(dd2$y, dd2$x, col=coluer[2])
#dev.off()

par(def.par)
SAS-Code - Attachment
SAS-Code
Stata-Code - Attachment
Stata-Code
Other Code - Attachment
Other Code
Keywords scatterplot, baseline count, end of treatment count, bivariate relationship
OPTIONAL FIELDS
References This graph essentially is just combining several basic plotting functions paying close attention to the par setting of mar. The location of each graph on the plotting region is controlled by using the layout function.

An example of this type of graph is provided in the statistical review of NDA 50-802 by Mat Soukup, Ph.D.
Datasets
Data
Attached Data
CATEGORIZATIONS
Classification-Evaluation Efficacy
Classification-Graph Type Scatterplot
Graph_Type Scatterplot
Variable Relationship Continuous versus Continuous
Data Types Continuous
Special Cases
Disclaimer 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 scatterdensity_reference_200.jpg
This topic: CTSpedia > WebHome > StatGraphHome > ContributeGraphics > StatGraphTopic013
Topic revision: 30 Mar 2012, MaryBanach
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback