Learn R Programming

DPpackage (version 1.1-0)

PTglmm: Bayesian analysis for a semiparametric generalized linear mixed model using a MMPT

Description

This function generates a posterior density sample for a semiparametric generalized linear mixed model, using a Mixture of Multivariate Polya Trees prior for the distribution of the random effects.

Usage

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

Arguments

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 + opera
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
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 fa
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 include the following parameter: a0 and b0 giving the hyperparameters for prior distribution of the precision parameter of the Polya Tree (
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
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 specifie
data
data frame.
na.action
a function that indicates what should happen when the data contain NAs. The default action (na.fail) causes PTglmm to print an error message and terminate if there are any

Value

  • An object of class PTglmm representing the generalized linear mixed-effects model fit. Generic functions such as print, plot, and summary have methods to show the results of the fit. The results include betaR, betaF, mu, the elements of Sigma, the precision parameter alpha, the dispersion parameter of the Gamma model, and ortho. The function PTrandom 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:
  • alphagiving the value of the precision parameter.
  • ba matrix of dimension (nsubjects)*(nrandom effects) giving the value of the random effects for each subject.
  • betagiving the value of the fixed effects.
  • mugiving the mean of the normal baseline distributions.
  • sigmagiving the variance matrix of the normal baseline distributions.
  • phigiving the precision parameter for the Gamma model (if needed).
  • orthogiving the orthogonal matrix H, used in the decomposition of the covariance matrix.

Details

This generic function fits a generalized linear mixed-effects model using a Mixture of Multivariate Polya Trees prior (see, Lavine 1992; 1994, for details about univariate PT) for the distribution of the random effects as described in Jara, Hanson and Lesaffre (2009). The linear predictor is modeled as follows: $$\eta_i = X_i \beta_F + Z_i \beta_R + Z_i b_i, i=1,\ldots,n$$ $$\theta_i | G \sim G$$ $$G | \alpha,\mu,\Sigma,O \sim PT^M(\Pi^{\mu,\Sigma,O},\mathcal{A})$$ where, $\theta_i = \beta_R + b_i$, $\beta = \beta_F$, and $O$ is an orthogonal matrix defining the decomposition of the centering covariance matrix. As in Hanson (2006), the PT prior is centered around the $N_d(\mu,\Sigma)$ distribution. However, we consider the class of partitions $\Pi^{\mu,\Sigma, O}$. The partitions starts with base sets that are Cartesian products of intervals obtained as quantiles from the standard normal distribution. A multivariate location-scale transformation $\theta=\mu+\Sigma^{1/2} z$ is applied to each base set yielding the final sets. Here $\Sigma^{1/2}=T'O'$, where $T$ is the unique upper triangular Cholesky matrix of $\Sigma$. The family $\mathcal{A}={\alpha_e: e \in E^{*}}$, where $E^{*}=\bigcup_{m=0}^{M} E_d^m$, with $E_d$ and $E_d^m$ the $d$-fold product of $E={0,1}$ and the the $m$-fold product of $E_d$, respectively. The family $\mathcal{A}$ was specified as $\alpha_{e_1 \ldots e_m}=\alpha m^2$. To complete the model specification, independent hyperpriors are assumed, $$\alpha | a_0, b_0 \sim Gamma(a_0,b_0)$$ $$\beta | \beta_0, S_{\beta_0} \sim N(\beta_0,S_{\beta_0})$$ $$\mu | \mu_b, S_b \sim N(\mu_b,S_b)$$ $$\Sigma | \nu_0, T \sim IW(\nu_0,T)$$ $$O \sim Haar(q)$$ Note that the inverted-Wishart prior is parametrized such that $E(\Sigma)= T^{-1}/(\nu_0-q-1)$. The precision parameter, $\alpha$, of the PT prior can be considered as random, having a gamma distribution, $Gamma(a_0,b_0)$, or fixed at some particular value. The inverse of the dispersion parameter of the Gamma model is modeled using gamma distribution, $\Gamma(\tau_1/2,\tau_2/2)$. The computational implementation of the model is based on the marginalization of the PT as discussed in Jara, Hanson and Lesaffre (2009).

References

Hanson, T. (2006) Inference for Mixtures of Finite Polya Trees. Journal of the American Statistical Association, 101: 1548-1565. Jara, A., Hanson, T., Lesaffre, E. (2009) Robustifying Generalized Linear Mixed Models using a New Mixture of Multivariate Polya Trees. Journal of Computational and Graphical Statistics (To Appear). Lavine, M. (1992) Some aspects of Polya tree distributions for statistical modelling. The Annals of Statistics, 20: 1222-11235. Lavine, M. (1994) More aspects of Polya tree distributions for statistical modelling. The Annals of Statistics, 22: 1161-1176.

See Also

PTrandom, PTglmm , PTolmm, DPMglmm, DPMlmm, DPMolmm, DPlmm , DPglmm, DPolmm

Examples

Run this code
# Respiratory Data Example
      data(indon)
      attach(indon)

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

    # Prior information

      prior <- list(alpha=1,
                    M=4, 
                    frstlprob=FALSE,
                    nu0=4,
                    tinv=diag(1,1),
                    mub=rep(0,1),
                    Sb=diag(1000,1),
                    beta0=rep(0,9),
                    Sbeta0=diag(10000,9))

    # Initial state
      state <- NULL

    # MCMC parameters

      nburn <- 5000
      nsave <- 5000
      nskip <- 20
      ndisplay <- 100
      mcmc <- list(nburn=nburn,
                   nsave=nsave,
                   nskip=nskip,
                   ndisplay=ndisplay,
                   tune1=0.5,tune2=0.5,
                   samplef=1)

    # Fitting the Logit model
      fit1 <- PTglmm(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)

      fit1 

      plot(PTrandom(fit1,predictive=TRUE))

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

    # Extract random effects
      PTrandom(fit1)
      PTrandom(fit1,centered=TRUE)

    # Extract predictive information of random effects
      PTrandom(fit1,predictive=TRUE)

    # Predictive marginal and joint distributions      
      plot(PTrandom(fit1,predictive=TRUE))

    # Fitting the Probit model
      fit2 <- PTglmm(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)
      fit2 

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

    # Extract random effects
      PTrandom(fit2)

    # Extract predictive information of random effects
      PTrandom(fit2,predictive=TRUE)

    # Predictive marginal and joint distributions      
      plot(PTrandom(fit2,predictive=TRUE))

Run the code above in your browser using DataLab