On Thu, 21 May 2009, Prew, Paul wrote:
> Hello,
>
> I'm trying to use the vcd package to analyze survey data. Expert
judges
> ranked possible features for product packaging. Seven features were
> listed, and 19 judges split between 2 cities ranked them.
>
> The following code (1) works, but the side-by-side plots for Cities PX,
> SF are shrunk too much. Stacking PX on top of SF would make for a
> better plot. (I could switch the order of Feature and Rank dimensions,
> and go with the default side-by-side, but would prefer not to).
Several comments:
- Adding keep_aspect_ratio = TRUE does probably change what you call
"shrunk too much". By default is aspect ratio is kept fixed for
2-way displays.
- I would switch the splitting order of Feature/Rank because you
probably want the distribution of ranks for a given feature and
not the other way round. In that case, you might find etting
split_vertical = TRUE aesthetically more pleasing. But it's probably
a matter of taste.
- Setting gp = shading_max is not really the best choice: If you would
want a conditional independence test based on the maximum of residuals
you should use panel = cotab_coindep. See the JCGS paper in the
references and the accompanying vignette("residual-shadings",
package
= "vcd") for more details. But note that the double maximum test
is not the most powerful test against ordinal alternatives (as one
might expect due to the ordered Rank variable).
hth,
Z
> (1)
> cotabplot(~ Rank + Feature| Cities, data = Pack.dat, gp = shading_max,
> rot_labels = c(90, 0, 0, 0),just_labels = c("left",
"left",
> "left", "right"),set_varnames = c(Feature =
""))
>
> Reading the vcd help, I got lost trying to understand the
> panel-generating parameters I should use. My best guess was below (2),
> but gave an error message. Clearly, I don't know what the paneling is
> asking for. This is where I would like some advice, if anyone is
> familiar with vcd.
>
> (2)
> #### Tried to change the layout of trellis plot from horizontal to
> vertical
> Pack.mos<-mosaic(~Feature + Rank, data = Pack.tab, gp = shading_max,
> rot_labels = c(0, 0, 0, 0),just_labels = c("left",
"left", "left",
> "right"),set_varnames = c(Feature = ""))
> ## attempt to create an object for panel argument in cotabplot function
>
> pushViewport(viewport(layout = grid.layout(ncol = 1)))
> pushViewport(viewport(layout.pos.row = 1))
> ## tell vcd to change the default layout, and what to put in the top
> plot
>
> cotabplot(~ Feature + Rank | Cities, data = Pack.dat, panel = Pack.mos,
> Pack.dat[["PX"]], gp = shading_max, rot_labels = c(0, 0, 0, 0))
> ## create mosaic plot that's conditional on Cities; first plot Cities
> PX
> ## panel argument is an attempt to modify an example in the vcd help
> file
>
> popViewport()
> ## create the graphic
>
> Error: Cannot pop the top-level viewport (grid and graphics output
> mixed?)
>
> # no point in gong on to code the plot for layout.pos.row = 2
>
>> str(Pack.tab)
> Error in `[.structable`(x, i, args[[2]]) : subscript out of bounds
>> class(Pack.tab)
> [1] "structable" "ftable"
>> dim(Pack.tab)
> [1] 7 2 7
>
> Cities PX SF
> Rank Feature
> 1 Flexible 2 0
> Integrate.Probes 1 2
> Large/heavy 1 0
> Lockout 0 1
> Recyclable 3 5
> Rigid 0 0
> Small/light 2 1
> 2 Flexible 1 6
> Integrate.Probes 2 0
> Large/heavy 1 1
> Lockout 1 0
> Recyclable 2 0
> Rigid 1 0
> Small/light 2 2
> 3 Flexible 1 1
> Integrate.Probes 3 0
> Large/heavy 1 1
> Lockout 2 1
> Recyclable 1 3
> Rigid 0 0
> Small/light 0 3
> 4 Flexible 3 0
> Integrate.Probes 0 2
> Large/heavy 0 0
> Lockout 2 2
> Recyclable 0 1
> Rigid 1 2
> Small/light 3 2
> 5 Flexible 1 1
> Integrate.Probes 1 1
> Large/heavy 0 3
> Lockout 0 2
> Recyclable 2 0
> Rigid 3 1
> Small/light 2 1
> 6 Flexible 0 1
> Integrate.Probes 1 3
> Large/heavy 3 2
> Lockout 3 1
> Recyclable 0 0
> Rigid 2 2
> Small/light 0 0
> 7 Flexible 1 0
> Integrate.Probes 1 1
> Large/heavy 3 2
> Lockout 1 2
> Recyclable 1 0
> Rigid 2 4
> Small/light 0 0
>
>
>
>> sessionInfo()
> R version 2.9.0 RC (2009-04-10 r48318)
> i386-pc-mingw32
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] grid tcltk stats graphics grDevices utils datasets
>
> [8] methods base
>
> other attached packages:
> [1] relimp_1.0-1 vcd_1.2-4 colorspace_1.0-0
> MASS_7.2-46
> [5] RSiteSearch_0.1-5 brew_1.0-3 lme4_0.999375-30
> Matrix_0.999375-26
> [9] lattice_0.17-22 Rcmdr_1.4-9 car_1.2-13
>
> loaded via a namespace (and not attached):
> [1] tools_2.9.0
>
>
> If someone can give advice on stacking the two cities' plots, I would
be
> grateful.
>
> Thanks, Paul
> CONFIDENTIALITY NOTICE: =\ \ This e-mail communication a...{{dropped:12}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>