hdr                  package:hdrcde                  R Documentation

_H_i_g_h_e_s_t _D_e_n_s_i_t_y _R_e_g_i_o_n_s

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

     Calculates and plots highest density regions in one dimension
     including the HDR boxplot.

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

     hdr(x, prob = c(50, 95, 99), den, h=hdrbw(BoxCox(x,lambda),mean(prob)), lambda=1, 
         nn=5000, all.modes=FALSE)
     hdr.den(x, prob = c(50, 95, 99), den, h=hdrbw(BoxCox(x,lambda),mean(prob)), lambda=1, 
         xlab=NULL, ylab="Density", ...)
     hdr.boxplot(x, prob = c(99, 50), h=hdrbw(BoxCox(x,lambda),mean(prob)), lambda=1, 
         boxlabels = "", col = gray((9:1)/10), main="", xlab="", ylab="", pch=1, ...)

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

       x: Numeric vector containing data. In 'hdr' and 'hdr.den', if
          'x' is missing then 'den' must be provided, and the HDR is
          computed from the given density. For 'hdr.boxplot', 'x' can
          be a list containing several vectors.

    prob: Probability coverage required for HDRs

     den: Density of data as list with components 'x' and 'y'. If
          omitted, the density is estimated from 'x' using 'density'.

       h: Optional bandwidth for calculation of density.

  lambda: Box-Cox transformation parameter where '0 <= lambda <= 1'.

      nn: Number of random numbers used in computing f-alpha quantiles.

all.modes: Return all local modes or just the global mode?

boxlabels: Label for each box plotted.

     col: Colours for regions of each box.

    main: Overall title for the plot.

    xlab: Label for x-axis.

    ylab: Label for y-axis.

     pch: Plotting character.

     ...: Other arguments passed to plot.

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

     Either 'x' or 'den' must be provided. When 'x' is provided, the
     density is estimated using kernel density estimation. A Box-Cox
     transformation is used if 'lambda!=1', as described in Wand,
     Marron and  Ruppert (1991). This allows the density estimate to be
     non-zero only on the positive real line. The kernel bandwidth is 
     selected using the algorithm of Samworth and Wand (2009).

     Hyndman's (1996) density quantile algorithm is used for
     calculation. 'hdr.den' plots the density with the HDRs 
     superimposed. 'hdr.boxplot' displays a boxplot based on HDRs.

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

     'hdr.boxplot' retuns nothing. 'hdr' and 'hdr.den' return a list of
     three components: 

     hdr: The endpoints of each interval in each HDR

    mode: The estimated mode of the density.

  falpha: The value of the density at the boundaries of each HDR.

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

     Rob Hyndman

_R_e_f_e_r_e_n_c_e_s:

     Hyndman, R.J. (1996) Computing and graphing highest density
     regions. _American Statistician_, *50*, 120-126.

     Samworth, R.J., and Wand, M.P. (2009).  Asymptotics and optimal 
     bandwidth selection for highest density region estimation.  
     Working paper. <URL: http://www.uow.edu.au/~mwand/hdrpap.pdf>.

     Wand, M.P., Marron, J S., Ruppert, D. (1991) Transformations in
     density estimation. _Journal of the American Statistical
     Association_, *86*, 343-353.

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

     'hdr.boxplot.2d'

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

     # Old faithful eruption duration times
     hdr(faithful$eruptions)
     hdr.boxplot(faithful$eruptions)
     hdr.den(faithful$eruptions)

     # Simple bimodal example
     x <- c(rnorm(100,0,1), rnorm(100,5,1))
     par(mfrow=c(1,2))
     boxplot(x)
     hdr.boxplot(x)
     par(mfrow=c(1,1))
     hdr.den(x)

     # Highly skewed example
     x <- exp(rnorm(100,0,1))
     par(mfrow=c(1,2))
     boxplot(x)
     hdr.boxplot(x,lambda=0)

