bandplot               package:gplots               R Documentation

_P_l_o_t _x-_y _P_o_i_n_t_s _w_i_t_h _L_o_c_a_l_l_y _S_m_o_o_t_h_e_d _M_e_a_n _a_n_d _S_t_a_n_d_a_r_d _D_e_v_i_a_t_i_o_n

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

     Plot x-y Points with lines showing the locally smoothed mean and
     standard deviation.

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

       bandplot(x, y, ..., add = FALSE, sd = c(-2:2),
                sd.col = c("lightblue", "blue", "red", "blue", "lightblue"),
                method = "frac", width = 1/5, n=50) 

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

       x: numeric vector of x locations

       y: numeric vector of x locations

     ...: Additional plotting parameters. 

     add: Boolean indicating whether the local mean and standard
          deviation lines should be added to an existing plot. 
          Defaults to FALSE.

      sd: Vector of multiples of the standard devation that should be
          plotted.  '0' gives the mean, '-1' gives the mean minus one
          standard deviation, etc.  Defaults to -2:2.

  sd.col: Color of each plotted line.

method, width, n: Parameters controlling the smoothing. See the help
          page for 'wapply' for details.

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

     'bandplot' was created to look for changes in the mean or variance
     of scatter plots, particularly plots of regression residuals.

     The local mean and standard deviation are calculated by calling
     'wapply'.  By default, bandplot asks wapply to smooth using
     intervals that include the nearest 1/5 of the data.  See the
     documentation of that function for details on the algorithm.

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

     Invisibly returns a list containing the x,y points plotted for
     each line.

_A_u_t_h_o_r(_s):

     Gregory R. Warnes gregory.r.warnes@pfizer.com

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

     'wapply', 'lowess'

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

     # fixed mean, changing variance
     x <- 1:1000
     y <- rnorm(1000, mean=1, sd=1 + x/1000 )
     bandplot(x,y)

     # fixed varance, changing mean
     x <- 1:1000
     y <- rnorm(1000, mean=x/1000, sd=1)
     bandplot(x,y)

     #
     # changing mean and variance
     #
     x <- abs(rnorm(500))
     y <- rnorm(500, mean=2*x, sd=2+2*x)

     # the changing mean and dispersion are hard to see whith the points alone:
     plot(x,y )

     # regression picks up the mean trend, but not the change in variance
     reg <- lm(y~x)
     summary(reg)

     # using bandplot on the original data helps to show the mean and
     # variance trend
     bandplot(x,y)

     # using bandplot on the residuals helps to see that regression removes
     # the mean trend but leaves the trend in variability
     bandplot(predict(reg),resid(reg))

