Learn R Programming

DPpackage (version 1.1-0)

DPMlmm: Bayesian analysis for a semiparametric linear mixed model using a DPM of normals

Description

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

Usage

DPMlmm(fixed,random,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
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 Dirichlet pr
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 DPMlmm to print an error message and terminate if there are any

Value

  • An object of class DPMlmm representing the 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, sigma2e, Sigma, mub, the elements of Sigmab, alpha, and the number of clusters. 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:
  • nclusteran integer giving the number of clusters.
  • alphagiving the value of the precision parameter
  • ba matrix of dimension (nsubjects)*(nrandom effects) giving the value of the random effects for each subject.
  • mua matrix of dimension (nsubjects)*(nrandom effects) giving the value of the means of the normal kernel for each cluster (only the first ncluster are considered to start the chain).
  • ssan interger vector defining to which of the ncluster clusters each subject belongs.
  • betagiving the value of the fixed effects.
  • sigmagiving the variance matrix of the normal kernel.
  • mubgiving the mean of the normal baseline distributions.
  • sigmabgiving the variance matrix of the normal baseline distributions.
  • sigma2egiving the error variance.

Details

This generic function fits a linear mixed-effects model (Verbeke and Molenberghs, 2000): $$y_i \sim N(X_i \beta_F + Z_i \beta_R + Z_i b_i, \sigma^2_e I_{n_i}), i=1,\ldots,n$$ $$\theta_i | G,\Sigma \sim \int N(\mu,\Sigma) G(d\mu)$$ $$G | \alpha, \mu_b,\Sigma_b \sim DP(\alpha N(\mu_b,\Sigma_b))$$ $$\sigma^{-2}_e | \tau_1, \tau_2 \sim \Gamma(\tau_1/2,\tau_2/2)$$ where, $\theta_i = \beta_R + b_i$, $\beta = \beta_F$, and $G_0=N(\theta| \mu, \Sigma)$. To complete the model specification, independent hyperpriors are assumed, $$\beta | \beta_0, S_{\beta_0} \sim N(\beta_0,S_{\beta_0})$$ $$\Sigma | \nu_0, T \sim IW(\nu_0,T)$$ $$\alpha | a_0, b_0 \sim Gamma(a_0,b_0)$$ $$\mu_b | m_b, S_b \sim N(m_b,S_b)$$ $$\Sigma_b | \nu_b, Tb \sim IW(\nu_b,Tb)$$ Note that the inverted-Wishart prior is parametrized such that $E(\Sigma)= T^{-1}/(\nu_0-q-1)$. The precision or total mass parameter, $\alpha$, of the DP prior can be considered as random, having a gamma distribution, $Gamma(a_0,b_0)$, 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 $a_0$ to NULL in the prior specification. The computational implementation of the model is based on the marginalization of the DP and on the use of MCMC methods for conjugate priors for a collapsed state of MacEachern (1998). The $\beta_R$ parameters are sampled using the $\epsilon$-DP approximation proposed by Muliere and Tardella (1998), with $\epsilon$=0.01.

References

Escobar, M.D. and West, M. (1995) Bayesian Density Estimation and Inference Using Mixtures. Journal of the American Statistical Association, 90: 577-588. MacEachern, S.N. (1998) Computational Methods for Mixture of Dirichlet Process Models, in Practical Nonparametric and Semiparametric Bayesian Statistics, eds: D. Dey, P. Muller, D. Sinha, New York: Springer-Verlag, pp. 1-22. Muliere, P. and Tardella, L. (1998) Approximating distributions of random functionals of Ferguson-Dirichlet priors. The Canadian Journal of Statistics, 26(2): 283-297. Verbeke, G. and Molenberghs, G. (2000). Linear mixed models for longitudinal data, New York: Springer-Verlag.

See Also

DPMrandom, DPMglmm, DPMolmm, DPlmm , DPglmm, DPolmm, PTlmm , PTglmm, PTolmm

Examples

Run this code
# School Girls Data Example

      data(schoolgirls)
      attach(schoolgirls)

    # Prior information

      prior<-list(alpha=1,
                  tau1=0.01,tau2=0.01,
                  nu0=4.01,
                  tinv=diag(10,2),
                  nub=4.01,
                  tbinv=diag(10,2),
                  mb=rep(0,2),
                  Sb=diag(1000,2))

    # Initial state
      state <- NULL

    # MCMC parameters

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

    # Fit the model: First run
    
      fit1<-DPMlmm(fixed=height~1,random=~age|child,prior=prior,mcmc=mcmc,
                   state=state,status=TRUE)
      fit1

    # Fit the model: Continuation
      state<-fit1$state     
    
      fit2<-DPMlmm(fixed=height~1,random=~age|child,prior=prior,mcmc=mcmc,
                  state=state,status=FALSE)
      fit2

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


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

    # Plot an specific model parameter (to see the plots gradually set ask=TRUE)
      plot(fit2,ask=FALSE,nfigr=1,nfigc=2,param="sigma-(Intercept)")	
      plot(fit2,ask=FALSE,nfigr=1,nfigc=2,param="ncluster")

Run the code above in your browser using DataLab