R: Bayesian density estimation for interval-censored data using...

DPMdencens {DPpackage} | R Documentation

## Bayesian density estimation for interval-censored data using a DPM of normals

### Description

This function generates a posterior density sample for a Dirichlet process mixture of normals model for interval-censored data.

### Usage

    DPMdencens(left,right,ngrid=100,grid=NULL,prior,mcmc,state,status)

### Arguments

`left` | a vector or matrix giving the lower limit for each response variable. Note that the responses are defined on the entire real line and that unknown limits should be indicated by NA.
`right` | a vector or matrix giving the upper limit for each response variable. Note that the responses are defined on the entire real line and that unknown limits should be indicated by NA.
`ngrid` | number of grid points where the density estimate is evaluated. The default value is 100.
`grid` | matrix of dimension ngrid*nvar of grid points where the density estimate is evaluated. The default value is NULL and the grid is chosen according to the range of the interval limits.
`prior` | a list giving the prior information. The list includes the following parameter: `a0` and `b0` 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 `a0` is missing, see details below), `nu2` and `psiinv2` giving the hyperparameters of the inverted Wishart prior distribution for the scale matrix, `Psi1`, of the inverted Wishart part of the baseline distribution, `tau1` and `tau2` giving the hyperparameters for the gamma prior distribution of the scale parameter `k0` of the normal part of the baseline distribution, `m2` and `s2` giving the mean and the covariance of the normal prior for the mean, `m1`, of the normal component of the baseline distribution, respectively, `nu1` and `psiinv1` (it must be specified if `nu2` is missing, see details below) giving the hyperparameters of the inverted Wishart part of the baseline distribution and, `m1` giving the mean of the normal part of the baseline distribution (it must be specified if `m2` is missing, see details below) and, `k0` giving the scale parameter of the normal part of the baseline distribution (it must be specified if `tau1` is missing, see details below).
`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`.

### Details

This generic function fits a Dirichlet process mixture of normal model for density estimation (Escobar and West, 1995) based on interval-censored data:

yij in [lij,uij),i=1,…,n, j=1,…,m,

yi | mui, Sigmai ~ N(mui,Sigmai), i=1,…,n,

(mui,Sigmai) | G ~ G,

G | alpha, G0 ~ DP(alpha G0),

where, yi=(yi1,…,yim), and the baseline distribution is the conjugate normal-inverted-Wishart distribution,

G0 = N(mu| m1, (1/k0) Sigma) IW (Sigma | nu1, psi1)

To complete the model specification, independent hyperpriors are assumed (optional),

alpha | a0, b0 ~ Gamma(a0,b0)

m1 | m2, s2 ~ N(m2,s2)

k0 | tau1, tau2 ~ Gamma(tau1/2,tau2/2)

psi1 | nu2, psi2 ~ IW(nu2,psi2)

Note that the inverted-Wishart prior is parametrized such that if A ~ IWq(nu, psi) then E(A)= psiinv/(nu-q-1).

To let part of the baseline distribution fixed at a particular value, set the corresponding hyperparameters of the prior distributions to NULL in the hyperprior specification of the model.

Although the baseline distribution, G0, is a conjugate prior in this model specification, an algorithm based on auxiliary parameters is adopted. Specifically, the algorithm 8 with m=1 of Neal (2000) is considered in the `DPMdencens` function.

Finally, note that this function can be used to fit the DPM of normals model for ordinal data proposed by Kottas, Mueller and Quintana (2005). In this case, the arbitrary cut-off points must be specified in `left` and `right`. Samples from the predictive distribution contained in the (last columns) of the object randsave (please see below) can be used to obtain an estimate of the cell probabilities.

### Value

An object of class `DPMdencens` representing the DP mixture of normals model fit. Generic functions such as `print`, `summary`, and `plot` have methods to show the results of the fit. The results include the baseline parameters, `alpha`, and the number of clusters.

The function `DPrandom` can be used to extract the posterior mean of the subject-specific means and covariance matrices.

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.
`muclus` | a matrix of dimension (nobservations+100)*(nvariables) giving the means of the clusters (only the first `ncluster` are considered to start the chain).
`sigmaclus` | a matrix of dimension (nobservations+100)*( (nvariables)*((nvariables)+1)/2) giving the lower matrix of the covariance matrix 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.
`m1` | giving the mean of the normal components of the baseline distribution.
`k0` | giving the scale parameter of the normal part of the baseline distribution.
`psi1` | giving the scale matrix of the inverted-Wishart part of the baseline distribution.
`y` | giving the matrix of imputed data points.

### Author(s)

Alejandro Jara <atjara@uc.cl>

### References

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

Kottas, A., Mueller, P., Quintana, F. (2005). Nonparametric Bayesian modeling for multivariate ordinal data. Journal of Computational and Graphical Statistics, 14: 610-625.

Neal, R. M. (2000). Markov Chain sampling methods for Dirichlet process mixture models. Journal of Computational and Graphical Statistics, 9: 249-265.

### See Also

`DPrandom`, `DPdensity`

### Examples

    ## Not run:
        ####################################
        # Bivariate example:
        # Censored data is artificially
        # created
        ####################################

          data(airquality)
          attach(airquality)

          ozone <- Ozone**(1/3)
          radiation <- Solar.R
          y <- na.omit(cbind(radiation,ozone))

        # create censored-data
          xxlim <- seq(0,300,50)
          yylim <- seq(1.5,5.5,1)

          left <- matrix(0,nrow=nrow(y),ncol=2)
          right <- matrix(0,nrow=nrow(y),ncol=2)

          for(i in 1:nrow(y))
          {
              left[i,1] <- NA
              right[i,1] <- NA
              if(y[i,1] < xxlim[1]) right[i,1] <- xxlim[1]
              for(j in 1:length(xxlim))
              {
                  if(y[i,1] >= xxlim[j]) left[i,1] <- xxlim[j]
                  if(y[i,1] >= xxlim[j]) right[i,1] <- xxlim[j+1]
              }
              left[i,2] <- NA
              right[i,2] <- NA
              if(y[i,2] < yylim[1]) right[i,2] <- yylim[1]

              for(j in 1:length(yylim))
              {
                  if(y[i,2] >= yylim[j]) left[i,2] <- yylim[j]
                  if(y[i,2] >= yylim[j]) right[i,2] <- yylim[j+1]
              }
          }

        # Prior information
          s2 <- matrix(c(10000,0,0,1),ncol=2)
          m2 <- c(180,3)
          psiinv2 <- diag(c(1/10000,1),2)

          prior <- list(alpha=1,nu1=4,nu2=4,s2=s2,
                        m2=m2,psiinv2=psiinv2,tau1=0.01,tau2=0.01)

        # Initial state
          state <- NULL

        # MCMC parameters
          nburn <- 5000
          nsave <- 5000
          nskip <- 3
          ndisplay <- 1000
          mcmc <- list(nburn=nburn,
                       nsave=nsave,
                       nskip=nskip,
                       ndisplay=ndisplay)

        # Fitting the model
          fit1 <- DPMdencens(left=left,right=right,ngrid=100,
                             prior=prior,mcmc=mcmc,
                             state=state,status=TRUE)
          fit1
          summary(fit1)

        # Plot the estimated density
          plot(fit1)

        # Extracting the univariate density estimates
          cbind(fit1$grid[,1],fit1$funi[[1]])
          cbind(fit1$grid[,2],fit1$funi[[2]])

        # Extracting the bivariate density estimates
          fit1$grid[,1]
          fit1$grid[,2]
          fit1$fbiv[[1]]

        # Plot of the estimated density along with the
        # true data points and censoring limits
          contour(fit1$grid[,1],fit1$grid[,2],fit1$fbiv[[1]])
          points(y)
          abline(v=xxlim)
          abline(h=yylim)

    ## End(Not run)

[Package DPpackage version 1.1-7.4 Index]