LDDPdensity {DPpackage} | R Documentation |
This function generates a posterior density sample for a Linear Dependent Dirichlet Process Mixture of Normals model. Support provided by the NIH/NCI R01CA75981 grant.
LDDPdensity(formula,prior,mcmc,state,status,grid=seq(-10,10,length=1000), xpred,data=sys.frame(sys.parent()),na.action=na.fail)
formula |
a two-sided linear formula object describing the
model fit, with the response on the
left of a ~ operator and the terms, separated by +
operators, on the right. The design matrix is used to model
the distribution of the response in the LDPP mixture of normals model. |
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), code{m} and S
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 m is missing),
nu and psiinv giving the hyperparameters of the
inverted Wishart prior distribution for the scale matrix, sigmab ,
of the baseline distribution, code{sigmab} giving the variance
of the baseline distribution (is must be specified if nu is missing),
tau1 and tau2 giving the hyperparameters for the
prior distribution of variance of the normal kernel, and
code{sigma2k} giving the variance of the normal kernel
(is must be specified if tau1 is missing). |
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. 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 . |
grid |
grid points where the density estimate is evaluated. The default is seq(-10,10,length=1000). |
xpred |
a matrix giving the covariate values where the predictive density is evaluated. |
data |
data frame. |
na.action |
a function that indicates what should happen when the data
contain NA s. The default action (na.fail ) causes
LDDPdensity to print an error message and terminate if there are any
incomplete observations. |
This generic function fits a Linear Dependent Dirichlet Process Mixture of Normals model,
yi | GXi ~ GXi
GXi = int N(Xi beta, sigma2k) H(d beta)
H | alpha, H0 ~ DP(M H0)
where, H0 = N(beta| mub, sigmab). To complete the model specification, independent hyperpriors are assumed,
alpha | a0, b0 ~ Gamma(a0,b0)
mub | m, S ~ N(m,S)
sigma | nu, psi ~ IW(nu,psi)
sigma2k^-1 | tau1, tau2 ~ Gamma(tau1/2,tau2/2)
Note that the inverted-Wishart prior is parametrized such that if A ~ IWq(nu, psi) then E(A)= psiinv/(nu-q-1).
Note also that the LDDP model is a natural ans simple extension of the the ANOVA DDP model discussed in in De Iorio et al. (2004). The same model is used in Mueller et al. (2005) as the random effects distribution in a repeated measurements model.
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.
Each of the parameters of the baseline distribution, mub and sigmab can be considered as random or fixed at some particular value. In the first case, a Mixture of Dirichlet Process is considered as a prior for the distribution of the regression coefficients. To let sigmab to be fixed at a particular value, set nu to NULL in the prior specification. To let mu to be fixed at a particular value, set m to NULL in the prior specification.
The variance of the normal kernel, sigma2k can be considered as random or fixed at some particular value. To let sigma2k to be fixed at a particular value, set tau1 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).
An object of class LDDPdensity
representing the LDDP mixture of normals model fit.
Generic functions such as print
, plot
,
and summary
have methods to show the results of the fit. The results include
mub
, sigmab
, sigam2k
, 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. 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:
b |
a matrix of dimension number of subject 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). |
alpha |
giving the value of the precision parameter. |
mub |
giving the mean of the normal baseline distributions. |
sigmab |
giving the covariance matrix the normal baseline distributions. |
sigma2k |
giving the variance of the normal kernel. |
ncluster |
an integer giving the number of clusters. |
ss |
an interger vector defining to which of the ncluster clusters each subject belongs. |
Alejandro Jara <Alejandro.JaraVallejos@med.kuleuven.be>
Peter Mueller <pmueller@mdanderson.org>
Gary L. Rosner <glrosner@mdanderson.org>
De Iorio, M., Muller, P., Rosner, G.L., and MacEachern, S (2004) An ANOVA Model for Dependent Random Measures. Journal of the American Statistical Association, 99: 205-215
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. 23-44.
Mueller, P., Rosner, G., De Iorio, M., and MacEachern, S. (2005). A Nonparametric Bayesian Model for Inference in Related Studies. Applied Statistics, 54 (3), 611-626.
## Not run: ########################################################## # Simulate data from a mixture of two normal densities ########################################################## nobs <- 500 y1 <-rnorm(nobs, 3,.8) ## y2 = 0.6 y21 <- rnorm(nobs,1.5, 0.8) y22 <- rnorm(nobs,4.0, 0.6) u <- runif(nobs) y2 <- ifelse(u<0.6,y21,y22) y <- c(y1,y2) ## design matrix including a single factor trt <- c(rep(0,nobs),rep(1,nobs)) ## design matrix for posterior predictive xpred <- rbind(c(1,0),c(1,1)) # Prior information s <- diag(100,2) m <- rep(0,2) psiinv <- diag(1,2) prior <- list(a0=1,b0=1/5, nu=4, m=m, s=s, psiinv=psiinv, tau1=0.01, tau2=0.01) # Initial state state <- NULL # MCMC parameters nburn <- 500 nsave <- 1000 nskip <- 10 ndisplay <- 100 mcmc <- list(nburn=nburn, nsave=nsave, nskip=nskip, ndisplay=ndisplay) # Fit the model fit1 <- LDDPdensity(y~trt,prior=prior,mcmc=mcmc,state=state,status=TRUE, grid=seq(-1,7,length=200),xpred=xpred) # Get posterior predictive density for future observations # with design vector x0=(1,0) plot(fit1$grid,fit1$dens[1,],type="l",xlab="Y",ylab="p",bty="l") p1 <- dnorm(fit1$grid, 3.0, 0.8) lines(fit1$grid,p1, lty=2) # ... and x0=(1,1) plot(fit1$grid,fit1$dens[2,],type="l",xlab="Y",ylab="p",bty="l") p2 <- 0.6*dnorm(fit1$grid, 1.5, 0.8) + 0.4*dnorm(fit1$grid, 4.0, 0.6) lines(fit1$grid,p2, lty=2) ## End(Not run)