DPglmm               package:DPpackage               R Documentation

_B_a_y_e_s_i_a_n _a_n_a_l_y_s_i_s _f_o_r _a _s_e_m_i_p_a_r_a_m_e_t_r_i_c _g_e_n_e_r_a_l_i_z_e_d _l_i_n_e_a_r _m_i_x_e_d _m_o_d_e_l _u_s_i_n_g _a _M_D_P

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

     This function generates a posterior density sample for a 
     semiparametric generalized linear mixed model using a Dirichlet
     Process or a Mixture of Dirichlet process prior for the
     distribution of the random effects.

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

     DPglmm(fixed,random,family,offset,n,prior,mcmc,state,status,
           data=sys.frame(sys.parent()),na.action=na.fail)

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

   fixed: a two-sided linear formula object describing the
          fixed-effects part of the model, with the response on the
          left of a '~' operator and the terms, separated by '+'
          operators, on the right.

  random: a one-sided formula of the form '~z1+...+zn | g', with 
          'z1+...+zn' specifying the model for the random effects and 
          'g' the grouping variable. The random effects formula will be
          repeated for all levels of grouping.

  family: a description of the error distribution and link function to
          be used in the model. This can be a character string naming a
          family function, a family function or the result of a call to
          a family function. The families(links) considered by 
          'DPglmm' so far are binomial(logit), binomial(probit),
          Gamma(log), and poisson(log). The gaussian(identity) case is 
          implemented separately in the function 'DPlmm'.

  offset: this can be used to specify an a priori known component to be
          included in the linear predictor during the fitting (only for
          poisson and gamma models).

       n: this can be used to indicate the total number of cases in a
          binomial model (only implemented for the logistic link). If
          it is not specified the response variable must be binary.

   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), 'nu0' and 'Tinv' giving the
          hyperparameters of the  inverted Wishart prior distribution
          for the scale matrix of the normal baseline distribution,
          'sigma' giving the value of the covariance matrix of the
          centering distribution (it must be specified if  'nu0' and
          'tinv' are missing),  'mub' and 'Sb' giving the
          hyperparameters  of the normal prior distribution for the
          mean of the normal baseline distribution, 'mu' giving the
          value of the mean of the centering distribution (it must be
          specified if  'mub' and 'Sb' are missing), 'beta0' and
          'Sbeta0' giving the  hyperparameters of the normal prior
          distribution for the fixed effects (must be specified only if
          fixed effects are considered in the model), and 'tau1' and
          'tau2' giving the hyperparameters for the  gamma prior
          distribution for the inverse of the precision parameter  of
          the Gamma model  (they must be specified only if the Gamma
          model is considered).  

    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 the screen (the
          function reports  on the screen when every 'ndisplay'
          iterations have been carried out), 'tune1' giving the
          positive Metropolis tuning parameter for the  precision
          parameter of the Gamma model (the default value is 1.1).

   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 
          'DPglmm' 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 generalized linear mixed-effects
     model, where the linear predictor is modeled as follows:

            etai = Xi betaF + Zi betaR + Zi bi, i=1,...,n


                            thetai | G ~ G


                     G | alpha, G0 ~ DP(alpha G0)


     where, thetai = betaR + bi , beta = betaF, and G0 = N(theta| mu,
     Sigma). To complete the model  specification, independent
     hyperpriors are assumed,

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


                beta | beta0, Sbeta0 ~ N(beta0,Sbeta0)


                       mu | mub, Sb ~ N(mub,Sb)


                      Sigma | nu0, T ~ IW(nu0,T)


     Note that the inverted-Wishart prior is parametrized such that
     E(Sigma)= Tinv/(nu0-q-1).

     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. 

     The inverse of the dispersion parameter of the Gamma model is
     modeled using 'gamma' distribution, Gamma(tau1/2,tau2/2). 

     The computational implementation of the model is based on the
     marginalization of the 'DP' and the MCMC is model-specific. 

     For the 'poisson', 'Gamma', and 'binomial' (when the total number
     of cases, 'n', is  specified) MCMC methods for nonconjugate priors
     (see, MacEachern and Muller, 1998; Neal, 2000)  are used.
     Specifically, the algorithm 8 with 'm=1' of Neal (2000), is
     considered in  the 'DPglmm' function. In this case, the fully
     conditional distributions for fixed and  in the resampling step of
     random effects are generated through the Metropolis-Hastings
     algorithm  with a IWLS proposal (see, West, 1985 and Gamerman,
     1997).

     For conditonal bernoulli models, 'binomial(probit)' and
     'binomial(logit)', (i.e., the total number of cases is not
     specified) the following latent variable representation is used:

                     yij = I(wij > 0), j=1,...,ni


   wij | beta, thetai, lambdai ~ N(Xij beta + Zij thetai, lambdaij)


     In the probit case, lambdaij=1  while in the logit case (see,
     Andrews and Mallows, 1974),

                        lambdaij = (2 phiij)^2


                              phiij ~ KS


     where KS refers to the Kolmogorov Smirnov distribution. In this
     case, the computational  implementation of the model is based on
     the marginalization of the 'DP' and on the use of MCMC methods for
     conjugate priors (Escobar, 1994; Escobar and West, 1998). For the
     logistic model, the full conditional distribution of the scale 
     parameters, lambdaij are sampled via the rejection sampling
     algorithm as proposed by Holmes and Held (2006).

     The betaR parameters are sampled using the epsilon-DP
     approximation proposed by Muliere and Tardella (1998), with
     epsilon=0.01.

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

     An object of class 'DPglmm' representing the generalized linear
     mixed-effects model fit. Generic functions such as 'print',
     'plot', 'summary', and 'anova' have methods to show the results of
     the fit. The results include  'betaR', 'betaF', 'mu', the elements
     of 'Sigma', the precision parameter  '\alpha', the number of
     clusters, and the dispersion parameter of the Gamma model.

     The function 'DPrandom' can be used to extract the posterior mean
     of the  random effects.

     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.

   alpha: giving the value of the precision parameter.

       b: a matrix of dimension (nsubjects)*(nrandom effects) giving
          the value of the random effects for each subject.

   bclus: a matrix of dimension (nsubjects)*(nrandom effects) giving
          the value of the random effects for each clusters (only the
          first 'ncluster' are considered to start the chain).

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

    beta: giving the value of the fixed effects.

      mu: giving the mean of the normal baseline distributions.

   sigma: giving the variance matrix of the normal baseline
          distributions.

     phi: giving the precision parameter for the Gamma model (if
          needed).

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

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

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

     Andrews, D. and Mallows, C. (1974) Scale mixture of normal
     distributions. Journal of the Royal Statistical Society, B, 36:
     99-102.

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

     Escobar, M.D. and West, M. (1998) Computing Bayesian Nonparametric
     Hierarchical Models, in Practical Nonparametric and Semiparametric
     Bayesian Statistics,  eds: D. Dey, P. Muller, D. Sinha, New York:
     Springer-Verlag, pp. 1-22.

     Gamerman, D. (1997) Sampling from the posterior distribution in
     generalized linear mixed models. Statistics and Computing, 7:
     57-68. 

     Holmes, C.C. and Held, L. (2006) Bayesian auxiliary variable
     models for binary and multinomial regression. Bayesian Analysis,
     1: 145-168.

     MacEachern, S. N. and Muller, P. (1998) Estimating mixture of
     Dirichlet Process Models. Journal of Computational and Graphical
     Statistics, 7 (2): 223-338.

     Muliere, P. and Tardella, L. (1998) Approximating distributions of
     random functionals of Ferguson-Dirichlet priors. The Canadian
     Journal of Statistics, 26(2): 283-297.

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

     West, M. (1985) Generalized linear models: outlier accomodation,
     scale parameter and prior distributions. In Bayesian Statistics 2
     (eds Bernardo et al.), 531-558, Amsterdam: North Holland.

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

     'DPrandom', 'DPlmm'   , 'DPolmm' , 'DPMlmm'  ,'DPMglmm' ,
     'DPMolmm'

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

     ## Not run: 
         # Respiratory Data Example

           data(indon)
           attach(indon)

           baseage2<-baseage**2
           follow<-age-baseage
           follow2<-follow**2 

         # Prior information

           beta0<-rep(0,9)
           Sbeta0<-diag(1000,9)
           tinv<-diag(1,1)
           prior<-list(a0=2,b0=0.1,nu0=4,tinv=tinv,mub=rep(0,1),Sb=diag(1000,1),
                       beta0=beta0,Sbeta0=Sbeta0)

         # Initial state
           state <- NULL

         # MCMC parameters

           nburn<-5000
           nsave<-25000
           nskip<-20
           ndisplay<-1000
           mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay)

         # Fit the Probit model
           fit1<-DPglmm(fixed=infect~gender+height+cosv+sinv+xero+baseage+baseage2+
                        follow+follow2,random=~1|id,family=binomial(probit),
                        prior=prior,mcmc=mcmc,state=state,status=TRUE)

         # Fit the Logit model
           fit2<-DPglmm(fixed=infect~gender+height+cosv+sinv+xero+baseage+baseage2+
                        follow+follow2,random=~1|id,family=binomial(logit),
                        prior=prior,mcmc=mcmc,state=state,status=TRUE)

         # Summary with HPD and Credibility intervals
           summary(fit1)
           summary(fit1,hpd=FALSE)

           summary(fit2)
           summary(fit2,hpd=FALSE)

         # Plot model parameters (to see the plots gradually set ask=TRUE)
           plot(fit1,ask=FALSE)
           plot(fit1,ask=FALSE,nfigr=2,nfigc=2)      

         # Plot an specific model parameter (to see the plots gradually set ask=TRUE)
           plot(fit1,ask=FALSE,nfigr=1,nfigc=2,param="baseage")      
           plot(fit1,ask=FALSE,nfigr=1,nfigc=2,param="ncluster")     
     ## End(Not run)

