svyplot                package:survey                R Documentation

_P_l_o_t_s _f_o_r _s_u_r_v_e_y _d_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

     Because observations in survey samples may represent very
     different numbers of units in the population ordinary plots can be
     misleading. The 'svyplot' function produces plots adjusted in
     various ways for sampling weights.

_U_s_a_g_e:

     svyplot(formula, design,...)
     ## Default S3 method:
     svyplot(formula, design, style = c("bubble", "hex", "grayhex","subsample","transparent"),
     sample.size = 500, subset = NULL, legend = 1, inches = 0.05,
     amount=NULL, basecol="black",
     alpha=c(0, 0.8),xbins=30,...)

_A_r_g_u_m_e_n_t_s:

 formula: A model formula

  design: A survey object (svydesign or svrepdesign)

   style: See Details below

sample.size: For 'style="subsample"'

  subset: expression using variables in the design object

  legend: For 'style="hex"' or '"grayhex"'

  inches: Scale for bubble plots

  amount: list with 'x' and 'y' components for amount of jittering to
          use in subsample plots, or 'NULL' for the default amount

 basecol: base color for transparent plots, or a function to compute
          the color (see below)

   alpha: minimum and maximum opacity for transparent plots

   xbins: Number of (x-axis) bins for hexagonal binning

     ...: Passed to 'plot' methods

_D_e_t_a_i_l_s:

     Bubble plots are scatterplots with circles whose area is
     proportional to the sampling weight.  The two "hex" styles produce
     hexagonal binning scatterplots, and require the 'hexbin' package
     from Bioconductor. The "transparent" style plots points with
     opacity proportional to sampling weight.

     The 'subsample' method uses the sampling weights to create a
     sample from approximately the population distribution and passes
     this to 'plot'

     Bubble plots are suited to small surveys, hexagonal binning and
     transparency to large surveys where plotting all the points would
     result in too much overlap.

     'basecol' can be a function taking one data frame argument, which
     will be passed the data frame of variables from the survey object.
     This could be memory-intensive for large data sets.

_V_a_l_u_e:

     None

_S_e_e _A_l_s_o:

     'symbols' for other options (such as colour) for bubble plots.

_E_x_a_m_p_l_e_s:

     data(api)
     dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)

     svyplot(api00~api99, design=dstrat, style="bubble")
     svyplot(api00~api99, design=dstrat, style="transparent",pch=19)
     ## Not run: 
     ## these two require the hexbin package from Bioconductor
     svyplot(api00~api99, design=dstrat, style="hex", xlab="1999 API",ylab="2000 API")
     svyplot(api00~api99, design=dstrat, style="grayhex",legend=0)
     ## End(Not run)

     dclus2<-svydesign(id=~dnum+snum,  weights=~pw,
                         data=apiclus2, fpc=~fpc1+fpc2)
     svyplot(api00~api99, design=dclus2, style="subsample")
     svyplot(api00~api99, design=dclus2, style="subsample",
               amount=list(x=25,y=25))

     svyplot(api00~api99, design=dstrat,
       basecol=function(df){c("goldenrod","tomato","sienna")[as.numeric(df$stype)]},
       style="transparent",pch=19,alpha=c(0,1))
     legend("topleft",col=c("goldenrod","tomato","sienna"), pch=19, legend=c("E","H","M"))

