LDDProc: Linear dependent DP model for conditional ROC curve...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This function generates a posterior density sample for a Linear Dependent Dirichlet Process Mixture of Normals model for conditional ROC curve estimations.

Usage

1
2
3
4
5
6
LDDProc(y.d,z.d,y.nond,z.nond,
        zpred.d,zpred.nond=NULL,prior.d,prior.nond=NULL,
        mcmc,state,status,ngrid=100,
        grid=NULL,compute.band=FALSE,type.band="PD",
        data=sys.frame(sys.parent()),na.action=na.fail,
        work.dir=NULL)

Arguments

y.d

a vector giving the responses for the diseased group.

z.d

a matrix giving the design matrix for the diseased group.

y.nond

a vector giving the responses for the non-diseased group.

z.nond

a matrix giving the design matrix for the non-diseased group.

zpred.d

a matrix giving the covariate values where the predictive density is evaluated for the diseased group.

zpred.nond

a matrix giving the covariate values where the predictive density is evaluated for the non-diseased group. By default, zpred.nond=NULL which means that zpred.nond=zpred.d.

prior.d

a list giving the prior information for the diseased group. The list includes the following parameters: 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), m0 and Sbeta0 giving the hyperparameters of the normal prior distribution for the mean of the normal baseline distribution, mub giving the mean of the normal baseline distribution of the regression coefficients (is must be specified if m0 is missing), nu and psiinv giving the hyperparameters of the inverted Wishart prior distribution for the scale matrix, sigmab, of the baseline distribution, sigmab giving the variance of the baseline distribution (is must be specified if nu is missing), tau1 giving the hyperparameter for the prior distribution of variance of the normal kernel, and taus1 and taus2 giving th hyperparameters of the gamma distribution for tau2.

prior.nond

a list giving the prior information for the non-diseased group. The list includes the same parameters than prior.d. The default specification (prior.nond = NULL) uses prior.nond=prior.d.

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, 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 for each individual model. 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.

ngrid

integer giving the number of grid points where the conditional density estimates are evaluated. The default is 100.

grid

vector of grid points where the conditional density estimate is evaluated. The default value is NULL and the grid is chosen according to the range of the data.

compute.band

logical variable indicating whether the credible band for the conditional density and mean function must be computed.

type.band

string indication the type of credible band to be computed; if equal to "HPD" or "PD" then the 95 percent pointwise HPD or PD band is computed, respectively.

data

data frame.

na.action

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

work.dir

working directory.

Details

The generic function fits the model described in Inacio et al. (2012) for conditional ROC curve estimation. Specifically, the function fits independent Linear Dependent Dirichlet Process Mixture of Normals models for the diseased (i=1) and non-diseased (i=2) groups. The conditional ROC curves are obtained from the conditional densities. The model is given by:

yij | fXij ~ fXij

fXi = \int N(Xij beta, sigma2) Gi(d beta d sigma2)

Gi | alphai, G0i ~ DP(alphai G0i)

where, G0 = N(beta| mubi, sbi)Gamma(sigma2|tau1/2,tau2i/2). To complete the model specification, independent hyperpriors are assumed,

alphai | a0i, b0i ~ Gamma(a0i,b0i)

mubi | m0i, Sbeta0i ~ N(m0i,Sbeta0i)

sbi | nui, psii ~ IW(nui,psii)

tau2i | taus1i, taus2i ~ Gamma(taus1i/2,taus2i/2)

The precision or total mass parameters, alphai, of the DP prior can be considered as random, having a gamma distribution, Gamma(a0i,b0i), or fixed at some particular value.

We refer the reader to the help file associated with the LDDPdensity function for more details about the prior specification, parameterizations and computational strategy.

Value

An object of class LDDProc representing the two LDDP mixture of normals model fits. Generic functions such as print, plot, and summary have methods to show the results of the fit. The results for each model include mub, sb, tau2, the precision parameter alpha, and the number of clusters.

The list state in the output object contains the current value of the parameters necessary to restart the analysis. Two different objects are included: state.d and state.nd. 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, each of the lists included in state must include the following objects:

betaclus

a matrix of dimension (number of subject + 100) times the number of columns in the design matrix, giving the regression coefficients for each cluster (only the first ncluster are considered to start the chain).

sigmaclus

a vector of dimension (number of subjects + 100) giving the variance of the normal kernel for each cluster (only the first ncluster are considered to start the chain).

alpha

giving the value of the precision parameter.

mub

giving the mean of the normal baseline distributions.

sb

giving the covariance matrix the normal baseline distributions.

ncluster

an integer giving the number of clusters.

ss

an interger vector defining to which of the ncluster clusters each subject belongs.

tau2

giving the value of the tau2 parameter.

Author(s)

Alejandro Jara <atjara@uc.cl>

References

Inacio, V., Jara, A., Hanson, T.E., de Carvalho, M. (2012) Bayesian nonparametric ROC regression modeling with application to diabetes diagnosis. Technical report.

See Also

LDDPdensity

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
## Not run: 

    ##############################################################
    # Simulated data example.
    # - Data generated using "perfect" simulation.
    # - one binary predictor.
    # - 250 observations in each 
    #   combination of predictor and 
    #   status.
    ##############################################################

    # Functions required for simulation

      findq <- function(true.cdf,target,low,upp,
                        epsilon=0.0000001)
      {
           plow <- true.cdf(low)
           pupp <- true.cdf(upp)
           pcenter <- true.cdf((upp+low)/2) 
           err <- abs(pcenter-target)
           i <- 0 
           while(err > epsilon)
           {
                 i <- i + 1
                 if(target< pcenter)
                 {  
                    upp <- (upp+low)/2
                    pupp <- pcenter
                    pcenter <- true.cdf((upp+low)/2) 
                    err <- abs(pcenter-target)
                 }  
                 if(target>= pcenter)
                 {   
                    low <- (upp+low)/2
                    plow <- pcenter
                    pcenter <- true.cdf((upp+low)/2) 
                    err <- abs(pcenter-target)
                 } 
           }
           return((upp+low)/2)	
      }


      true.cdf.nond1 <- function(x)
      {
         pnorm(x,2.1,sqrt(0.0324))
      }

      true.cdf.nond2 <- function(x)
      {
	 0.5*pnorm(x,1.85,sqrt(0.005))+
         0.5*pnorm(x,2.25,sqrt(0.005))
      }

      true.cdf.d1 <- function(x)
      {
	 0.5*pnorm(x,1.95,sqrt(0.005))+
         0.5*pnorm(x,2.35,sqrt(0.005))
      }

      true.cdf.d2 <- function(x)
      {
          pnorm(x,2.5,sqrt(0.0324))
      }
	
    # Simulating the data

      nsim <- 250 
      qq <- seq(1,nsim)/(nsim+1)

      y.nond1 <- rep(0,nsim)
      for(i in 1:nsim)
      {
          aa <- findq(true.cdf.nond1,qq[i],
                      low=-6,upp=6,epsilon=0.0000001)
          y.nond1[i] <- aa 
      }	

      y.nond2 <- rep(0,nsim)
      for(i in 1:nsim)
      {
          aa <- findq(true.cdf.nond2,qq[i],
                      low=-6,upp=6,epsilon=0.0000001)
          y.nond2[i] <- aa 
      }	
      y.nond <- c(y.nond1,y.nond2)
      trt.nond <- c(rep(0,nsim),rep(1,nsim))

      y.d1 <- rep(0,nsim)
      for(i in 1:nsim)
      {
          aa <- findq(true.cdf.d1,qq[i],
                      low=-6,upp=6,epsilon=0.0000001)
          y.d1[i] <- aa 
      }	

      y.d2 <- rep(0,nsim)
      for(i in 1:nsim)
      {
          aa <- findq(true.cdf.d2,qq[i],
                      low=-6,upp=6,epsilon=0.0000001)
          y.d2[i] <- aa 
      }	

      y.d <- c(y.d1,y.d2)
      trt.d <- c(rep(0,nsim),rep(1,nsim))

    # Design matrices

      z.d <- cbind(rep(1,2*nsim),trt.d)
      colnames(z.d) <- c("(Intercept)","trt")
      z.nond <- cbind(rep(1,2*nsim),trt.nond)
      colnames(z.nond) <- c("(Intercept)","trt")

    # design matrix for posterior predictive inference 

      zpred <- rbind(c(1,0),c(1,1))  

    # Prior information
      prior <- list(a0=10,
                    b0=1,
                    nu=4,
                    m0=rep(0,2),
                    S0=diag(100,2),
                    psiinv=diag(1,2),
                    tau1=6.01,
                    taus1=6.01,
                    taus2=2.01)

    # Initial state
      state <- NULL

    # MCMC parameters

      nburn <- 5000
      nsave <- 5000
      nskip <- 4
      ndisplay <- 500
      mcmc <- list(nburn=nburn,
                   nsave=nsave,
                   nskip=nskip,
                   ndisplay=ndisplay)

    # Fitting the model

      fit1 <- LDDProc(y.d=y.d,z.d=z.d,
                      y.nond=y.nond,z.nond=z.nond,
                      zpred.d=zpred,
                      prior.d=prior,
                      prior.nond=prior,
                      mcmc=mcmc,
                      state=state, 
                      status=TRUE,
                      compute.band=TRUE)

      fit1
      summary(fit1)
      plot(fit1)


     # Ploting the conditional
     # ROC curve for x=c(1,0),
     # along with the true curve

       par(cex=1.7,mar=c(4.1, 4.1, 1, 1))

       plot(fit1$rocgrid,fit1$rocp.h[1,],type="l",
            lty=2,lwd=2,ylim=c(0,1),xlim=c(0,1),
            xlab="False positive rate",
            ylab="True positive rate")
       lines(fit1$rocgrid,fit1$rocp.l[1,],lty=2,lwd=2)
       lines(fit1$rocgrid,fit1$rocp.m[1,],lty=1,lwd=2)

       nn <- length(fit1$rocgrid)
       tt <- rep(0,nn)
       for(i in 1:nn)
       {
	   tt[i] <- findq(true.cdf.nond1,
                          1-fit1$rocgrid[i],
                          low=-6,upp=6,
                          epsilon=0.0000001)
       }	
       true.roc1 <- 1.0 - true.cdf.d1(tt) 
       lines(fit1$rocgrid,true.roc1,
             lty=1,lwd=3,col="red")

     # Ploting the conditional
     # ROC curve for x=c(1,1),
     # along with the true curve

       par(cex=1.7,mar=c(4.1, 4.1, 1, 1))

       plot(fit1$rocgrid,fit1$rocp.h[2,],type="l",
            lty=2,lwd=2,ylim=c(0,1),xlim=c(0,1),
            xlab="False positive rate", 
            ylab="True positive rate")
       lines(fit1$rocgrid,fit1$rocp.l[2,],lty=2,lwd=2)
       lines(fit1$rocgrid,fit1$rocp.m[2,],lty=1,lwd=2)

       nn <- length(fit1$rocgrid)
       tt <- rep(0,nn)
       for(i in 1:nn)
       {
           tt[i] <- findq(true.cdf.nond2,
                          1-fit1$rocgrid[i],
                          low=-6,upp=6,
                          epsilon=0.0000001)
       }	
       true.roc2 <- 1.0 - true.cdf.d2(tt) 
       lines(fit1$rocgrid,true.roc2,lty=1,lwd=3,col="red")


## End(Not run)

DPpackage documentation built on May 1, 2019, 10:23 p.m.

Related to LDDProc in DPpackage...