TDPdensity             package:DPpackage             R Documentation

_S_e_m_i_p_a_r_a_m_e_t_r_i_c _B_a_y_e_s_i_a_n _d_e_n_s_i_t_y _e_s_t_i_m_a_t_i_o_n _u_s_i_n_g _D_P _M_i_x_t_u_r_e_s _o_f _T_r_i_a_n_g_u_l_a_r _D_i_s_t_r_i_b_u_t_i_o_n_s

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

     This function generates a posterior density sample for a 
     Triangular-Dirichlet model.

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

     TDPdensity(y,support=3,transform=1,ngrid=1000,prior,mcmc,state,status,
               data=sys.frame(sys.parent()),na.action=na.fail)      
           

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

       y: a vector giving the data from which the density estimate  is
          to be computed.

 support: an integer number giving the support of the random density,
          1=[0,1], 2=(0, +Inf], and 3=(-In,+Inf). Depending on this,
          the data is transformed to lie in the [0,1] interval.

transform: an integer number giving the type of transformation to be
          considered, 1=Uniform, 2=Normal,3=Logistic,4=Cauchy. The
          types 2-4 can be only used when the support is the   real
          line.

   ngrid: number of grid points where the density estimate is 
          evaluated. This is only used if dimension of 'y' is lower or
          equal than 2. The default value is 1000.

   prior: a list giving the prior information. The list includes the
          following parameter: 'aa0' and 'ab0' giving the
          hyperparameters for prior distribution of the precision
          parameter of the Dirichlet process prior, 'alpha' giving the
          value of the precision parameter (it  must be specified if
          'aa0' is missing, see details below), 'a0' and 'b0' giving
          the parameters of the beta centering distribution of the DP
          prior, and 'kmax' giving the maximum value of the discrete
          uniform prior for number of components in the Mixture of
          Triangular distributions. Optionally, when the support of the
          data is the real line and the  parametric transformation 2-4
          are considered, the location 'mu' and the scale parameter
          'sigma2' can be included here. If not, they are taked as the
          mean and the variance of the data, respectively.                               

    mcmc: a list giving the MCMC parameters. The list must include the
          following integers: 'nburn' giving the number of burn-in 
          scans, 'nskip' giving the thinning interval, 'nsave' giving
          the total number of scans to be saved, and 'ndisplay' giving
          the number of saved scans to be displayed on screen (the
          function reports  on the screen when every 'ndisplay'
          iterations have been carried out).

   state: a list giving the current value of the parameters. This list
          is used if the current analysis is the continuation of a
          previous analysis.

  status: a logical variable indicating whether this run is new
          ('TRUE') or the  continuation of a previous analysis
          ('FALSE'). In the latter case the current value of the
          parameters must be specified in the  object 'state'.

    data: data frame.

na.action: a function that indicates what should happen when the data
          contain 'NA's. The default action ('na.fail') causes 
          'TDPdensity' to print an error message and terminate if there
          are any incomplete observations.

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

     This generic function fits a Triangular-Dirichlet model for
     density estimation:

                        yi | G ~ G, i=1,...,n


              G | kmax, alpha, G0 ~ TDP(kmax, alpha G0)


     where, yi is the transformed data to lie in [0,1], 'kmax' is the
     upper limit of the discrete uniform prior  for the number of
     components in the Mixture of Triangular distributions, alpha is
     the total mass parameter of the Dirichlet process component, and
     G0 is the centering distribution of the DP. The centering
     distribution corresponds to a G0=Beta(a0,b0) distribution.

     Note that our representation is different to the Mixture of
     Triangular  distributions proposed by Perron and Mengersen (2001).
     In this function we consider random weights following a Dirichlet
     prior and we exploit the  underlying DP structure. By so doing, we
     avoid using Reversible-Jumps algorithms. 

     The precision or total mass parameter, alpha, of the 'DP' prior 
     can be considered as random, having a 'gamma' distribution,
     Gamma(a0,b0),  or fixed at some particular value. When alpha is
     random the method described by Escobar and West (1995) is used. To
     let alpha to be fixed at a particular value, set a0 to NULL in the
     prior specification.

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

     An object of class 'TDPdensity' representing the
     Triangular-Dirichlet  model fit. Generic functions such as
     'print', 'summary', and 'plot' have methods to  show the results
     of the fit. The results include the degree of the polynomial 'k',
     'alpha', and the  number of clusters.

     The MCMC samples of the parameters and the errors in the model are
     stored in the object  'thetasave' and 'randsave', respectively.
     Both objects are included in the  list 'save.state' and are
     matrices which can be analyzed directly by functions  provided by
     the coda package.

     The list 'state' in the output object contains the current value
     of the parameters  necessary to restart the analysis. If you want
     to specify different starting values  to run multiple chains set
     'status=TRUE' and create the list state based on  this starting
     values. In this case the list 'state' must include the following
     objects: 

ncluster: an integer giving the number of clusters.

   yclus: a real vector giving the 'y' latent variables of the clusters
          (only the first 'ncluster' are  considered to start the
          chain).

      ss: an interger vector defining to which of the 'ncluster'
          clusters each observation belongs.

   alpha: giving the value of the precision parameter.

       k: giving the number of components in the Mixture of Triangular
          distriutions.

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

     Alejandro Jara <Alejandro.JaraVallejos@med.kuleuven.be>

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

     Escobar, M.D. and West, M. (1995) Bayesian Density Estimation and
     Inference  Using Mixtures. Journal of the American Statistical
     Association, 90: 577-588.

     Perron, F. and Mengersen, K. (2001) Bayesian Nonparametric
     Modeling Using Mixtures  of Triangular Distributions. Biometrics,
     57(2): 518-528.

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

     'DPdensity', 'PTdensity', 'BDPdensity'

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

     ## Not run: 
         # Data
           data(galaxy)
           galaxy<-data.frame(galaxy,speeds=galaxy$speed/1000) 
           attach(galaxy)

         # Initial state
           state <- NULL

         # MCMC parameters

           nburn<-1000
           nsave<-10000
           nskip<-10
           ndisplay<-100
           mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)

         # Prior
           prior<-list(aa0=2.01,
                       ab0=0.01,
                       kmax=50,
                       a0=1,
                       b0=1)

         # Fitting the model

           fit<-TDPdensity(y=speeds,prior=prior,mcmc=mcmc,state=state,status=TRUE)
           
           plot(fit)
           

     ## End(Not run)

