CHAPTER14. CONDITIONINGANDPLOTTINGTHREEORMOREVARIABLES
143
xYplot(Cbind(y, Lower, Upper) ∼ month | factor(year),
method=’filled bands’, type=’l’, data=s)
# Figure 14.3
# Use method=’bands’ for ordinary unfilled bands
2
3
4
5
6
7
2
4
6
8
10
12
1997
2
4
6
8
10
12
1998
month
y
Figure 14.3:
Nonparametric bootstrap confidence limits for each month, but depicted with filled
bands
·
Here is an example using double bands, to depict the following quantiles:
.1 .25 .5 .75 .9
. The
0.25
and
0.75
quantiles are drawn with line thickness 2,
and the central line with a thickness of 4. Note that summarize produces a
matrix for
y
when
type=’matrix’
is specified, and
Cbind(y)
trusts the first
column to be the point estimate (here the median)
s ← summarize(y, llist(month,year), quantile, probs=c(.5,.1,.25,.75,.9),
type=’matrix’)
xYplot(Cbind(y) ∼ month | factor(year), data=s,
type=’l’, method=’bands’, lwd.bands=c(1,2,2,1), lwd=4)
# Figure 14.4
Change pdf to powerpoint - software SDK project:C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
www.rasteredge.com
Change pdf to powerpoint - software SDK project:VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
www.rasteredge.com
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
144
2
4
6
8
2
4
6
8
10
12
1997
2
4
6
8
10
12
1998
month
y
Figure 14.4:
Central line depicts the median, and bands depict the
0.1,0.25,0.75,0.9
quantiles of the
raw data
xYplot
with
method=’quantile’
or
method=functionname
·
method=’quantile’
:
xYplot
automatically groups the
x
variable into inter-
vals containing a target of
nx
observations
·
Default value of
nx
is the lesser of 40 and
1
4
×
stratum size (specify
nx=0
to
do no grouping; useful when
x
variable is discrete such as
month
)
·
Quantiles given by the
probs
argument; default is
probs=c(.5,.25,.75)
software SDK project:Online Convert PowerPoint to PDF file. Best free online export
Online Powerpoint to PDF Converter. Download Free Trial. Then just wait until the conversion from Powerpoint to PDF is complete and download the file.
www.rasteredge.com
software SDK project:RasterEdge XDoc.PowerPoint for .NET - SDK for PowerPoint Document
Able to view and edit PowerPoint rapidly. Convert. Convert PowerPoint to PDF. Convert PowerPoint to HTML5. Convert PowerPoint to Tiff. Convert PowerPoint to Jpeg
www.rasteredge.com
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
145
·
Within each
x
group computes three quantiles of
y
and plots these as three
lines
·
Mean
x
within each
x
group is taken as the
x
-coordinate
·
Useful empirical display for large datasets in which scatterdiagrams are too
busy to see patterns of central tendency and variability; good for residual
plots for showing symmetry and lack of trend in central tendency and vari-
ability
b
·
Can also specify a general function of a data vector that returns a matrix of
statistics for
method
;the statistic in the first column should be the measure
of central tendency
·
Arguments can be passed to that function a list
methodArgs
·
Example: Group
x
into intervals containing 40 observations, plot the
0.5, 0.25,0.75
quantiles of
y
against mean
x
in interval
set.seed(1)
age ← rnorm(1000, 30, 10)
sbp ← 0.3*(age-30) + rnorm(1000, 120, 15)
xYplot(sbp ∼ age, method=’quantile’,
# Figure 14.5
xlim=c(5,60), ylim=c(100,140))
·
Instead of quantiles of raw data, show parametric confidence bands, and
require 60 observations in a group
xYplot(sbp ∼ age, method=smean.cl.normal, # Figure 14.6
xlim=c(5,60), ylim=c(100,140), nx=60)
b
Specify
method=smean.sdl
toinsteadplotmeanand
±2×
S.D.
software SDK project:C# WinForms Viewer: Load, View, Convert, Annotate and Edit
to PDF; Convert PowerPoint to PDF; Convert Image to PDF; Convert Jpeg to PDF; Merge PDF Files; Split PDF Document; Remove Password from PDF; Change PDF Permission
www.rasteredge.com
software SDK project:How to C#: Overview of Using XDoc.PowerPoint
How to C#: Overview of Using XDoc.PowerPoint. Overview for How to Use XDoc.PowerPoint in C# .NET Programming Project. PowerPoint Conversion.
www.rasteredge.com
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
146
100
110
120
130
140
10
20
30
40
50
60
age
sbp
Figure 14.5:
0.25,0.5,0.75
quantiles of
sbp
vs. intervals of
age
containing 40 observations
software SDK project:C# HTML5 Viewer: Load, View, Convert, Annotate and Edit PowerPoint
Such as load and view PowerPoint without Microsoft Office software installed, convert PowerPoint to PDF file, Tiff image and HTML file, as well as add
www.rasteredge.com
software SDK project:VB.NET PowerPoint: Read, Edit and Process PPTX File
create image on desired PowerPoint slide, merge/split PowerPoint file, change the order of How to convert PowerPoint to PDF, render PowerPoint to SVG
www.rasteredge.com
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
147
100
110
120
130
140
10
20
30
40
50
60
age
sbp
Figure 14.6:
Mean and parametric 0.95 confidence limits for means, for intervals of
age
containing
60 observations
software SDK project:VB.NET PDF Password Library: add, remove, edit PDF file password
Add password to PDF. Change PDF original password. Remove password from PDF. Set PDF security level. VB: Change and Update PDF Document Password.
www.rasteredge.com
software SDK project:C# powerpoint - Convert PowerPoint to PDF in C#.NET
C# PowerPoint - Convert PowerPoint to PDF in C#.NET. Online C# Tutorial for Converting PowerPoint to PDF (.pdf) Document. PowerPoint to PDF Conversion Overview.
www.rasteredge.com
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
148
Dotplot
·
“Multivariate response”packaged by
Cbind
appears as the
x
-variable after
the
·
Does not work well with superposition of
groups
·
Example: Display proportions and approximate 0.95 confidence limits from
already-tabulated data
d ← expand.grid(continent=c(’USA’,’Europe’), year=1999:2001)
d$proportion ← c(.2, .18, .19, .22, .23, .20)
d$SE ← c(.02, .01, .02, .015, .021, .025)
d
continent year proportion
SE
1
USA 1999
0.20 0.020
2
Europe 1999
0.18 0.010
3
USA 2000
0.19 0.020
4
Europe 2000
0.22 0.015
5
USA 2001
0.23 0.021
6
Europe 2001
0.20 0.025
Dotplot(year ∼ Cbind(proportion, proportion-1.96*SE, proportion+1.96*SE) |
continent, data=d, ylab=’Year’) # Figure 14.7
·
To re-arrange the order of the vertical groups, use the
reorder.factor
func-
tion
AH11.4,4.6
·
First just reverse the order of years on the
y
-axis
yr ← factor(d$year, 2001:1999)
Dotplot(yr ∼ Cbind(proportion, proportion-1.96*SE, proportion+1.96*SE) |
continent, data=d, ylab=’Year’)
·
Next, reorder years by the average proportion over the two continents
yr ← factor(d$year)
# reorder.factor only accepts factors
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
149
1999
2000
2001
0.16
0.20
0.24
USA
0.16
0.20
0.24
Europe
proportion
Month
Figure 14.7:
Dot plot showing proportions and approximate 0.95 confidence limits for population
probabilities
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
150
yr ← reorder.factor(yr, d$proportion, mean)
levels(yr)
[1] "1999" "2000" "2001"
This happens to be in the original order so the dot plot will be the same as
Figure 14.7
·
To use more accurate Wilson confidence intervals on raw data:
set.seed(3)
d ← expand.grid(continent=c(’USA’,’Europe’), year=1999:2001,
reps=1:100)
# Generate binary events from a population probability of 0.2
# of the event, same for all years and continents
d$y ← ifelse(runif(6*100) <= .2, 1, 0)
rm(y)
# remove old y so as to not confuse the following
attach(d)
s ← summarize(y, llist(continent,year),
function(y) {
n ← sum(!is.na(y))
s ← sum(y, na.rm=T)
binconf(s, n)
}, type=’matrix’)
Dotplot(year ∼ Cbind(y) | continent,
data=s, ylab=’Year’)
# Same format of output as Figure 14.7
·
Example:
dfr
data frame and associated raw response variable
y
from
above
·
Display a 5-number (5-quantile) summary (2 intervals, dot=median)
s ← summarize(y, llist(month,year), quantile,
probs=c(.5,.05,.25,.75,.95), type=’matrix’)
Dotplot(month ∼ Cbind(y) | factor(year),
data=s, ylab=’Month’) # Figure 14.8
dev.off()
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
151
1
2
3
4
5
6
7
8
9
10
11
12
2
4
6
8
1997
2
4
6
8
1998
y
Month
Figure 14.8:
Multi-tiered dot plot showing
.05,.25,.5,.75,.95
quantiles of raw data
CHAPTER 14. CONDITIONING AND PLOTTING THREE OR MORE VARIABLES
152
14.7.9 Summary of Functions for Aggregating Data for Plotting
AH11.4.4
tapply
·
Stratifies a single variable by one or a list of stratification variables
·
When stratify by
> 1
variable, result is a matrix which difficult to plot
directly
·
Hmisc
reShape
function can be used to re–shape the result into a data
frame for plotting
·
When stratify by a single variable,
tapply
creates a vector of summary
statistics suitable for making a simple dot or bar plot without conditioning
aggregate
·
Input = vector or a data frame and a
by
list of one or more stratification
variables
·
Handy to enclose the
by
variables in the
llist
function
·
Can summarize many variables at once but only a single number such
as the mean is computed for each one
·
aggregate
does not preserve numeric stratification variables —it trans-
forms them into factors which are not suitable for certain graphics
·
Result is data frame
summary.formula
·
Can compute separate summaries for each of the stratification variables
·
Can also do
×
classifications when
method=’cross’
Documents you may be interested
Documents you may be interested