svysmooth               package:survey               R Documentation

_S_c_a_t_t_e_r_p_l_o_t _s_m_o_o_t_h_i_n_g _a_n_d _d_e_n_s_i_t_y _e_s_t_i_m_a_t_i_o_n

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

     Scatterplot smoothing and density estimation for
     probability-weighted data.

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

     svysmooth(formula, design, method = c("locpoly","quantreg"), bandwidth,quantile,df, ...)
     ## S3 method for class 'svysmooth':
     plot(x, which=NULL, type="l", xlabs=NULL, ylab=NULL,...)
     ## S3 method for class 'svysmooth':
     lines(x,which=NULL,...)
     make.panel.svysmooth(design,bandwidth=NULL)

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

 formula: One-sided formula for density estimation, two-sided for
          smoothing

  design: Survey design object

  method: local polynomial smoothing for the mean or regression splines
          for quantiles

bandwidth: Smoothing bandwidth for "locpoly"

quantile: quantile to be estimated for "quantreg"

      df: Degrees of freedom for "quantreg"

   which: Which plots to show (default is all)

    type: as for 'plot'

   xlabs: Optional vector of x-axis labels

    ylab: Optional y-axis label

     ...: More arguments

       x: Object of class 'svysmooth'

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

     'svysmooth' does one-dimensional smoothing. If 'formula' has
     multiple predictor variables a separate one-dimensional smooth is
     performed for each one. 

     For 'method="locpoly"' the extra arguments are passed to 'locpoly'
     from the KernSmooth package, for 'method="quantreg"' they are
     passed to 'rq' from the quantreg package.

     'make.panel.svysmooth()' makes a function that plots points and
     draws a weighted smooth curve through them, a weighted replacement
     for 'panel.smooth' that can be passed to functions such as
     'termplot' or 'plot.lm'.

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

     An object of class 'svysmooth', a list of lists, each with 'x' and
     'y' components.

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

     'svyhist' for histograms

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

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

      smth<-svysmooth(api00~api99+ell,dstrat, bandwidth=c(40,10))
      dens<-svysmooth(~api99, dstrat,bandwidth=30)
      qsmth<-svysmooth(api00~ell,dstrat, quantile=0.75, df=3,method="quantreg")

      plot(smth)
      plot(smth, which="ell",lty=2,ylim=c(500,900))
      lines(qsmth, col="red")

      svyhist(~api99,design=dstrat)
      lines(dens,col="purple",lwd=3)

      m<-svyglm(api00~sin(api99/100)+stype, design=dstrat)
      termplot(m, data=model.frame(dstrat), partial.resid=TRUE, se=TRUE,
       smooth=make.panel.svysmooth(dstrat))

