PTlmm {DPpackage} | R Documentation |
This function generates a posterior density sample for a semiparametric linear mixed model, using a Mixture of Multivariate Polya Trees prior for the distribution of the random effects.
PTlmm(fixed,random,prior,mcmc,state,status,data=sys.frame(sys.parent()), na.action=na.fail)
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. |
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 (PT)
prior, alpha giving the value of the precision parameter (it
must be specified if a0 and b0 are 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),
tau1 and tau2 giving the hyperparameters for the prior
distribution of the error variance, M giving the finite level
of the PT prior to be considered, frstlprob a logical variable
indicating whether the first level probabilities of the PT are fixed
or not (the default is FALSE), and
typepr indicating whether the type of decomposition of the centering
covariance matrix is random (1) or not (0). |
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), nbase giving the number scans to be performed before the
parameters of the centering distribution and the precision parameter are
updated (i.e., the update of this parameters is invoked only once in every
nbase scans) (the default value is 1), tune1 , tune2 , and tune3 ,
giving the Metropolis tuning parameter for the baseline mean,
variance, and precision parameter, respectively. If tune1 , tune2 ,
or tune3 are not specified or negative, an adpative Metropolis algorithm is performed.
Finally, the integer samplef indicates whether
the functional parameters must be sample (1) or not (0). |
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
PTlmm to print an error message and terminate if there are any
incomplete observations. |
This generic function fits a 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):
yi ~ N(Xi betaF + Zi betaR + Zi bi, sigma2e Ini), i=1,...,n
thetai | G ~ G
G | alpha,mu,Sigma,O ~ PT^M(Pi^{mu,Sigma,O},A)
sigma2e^-1 | tau1, tau2 ~ Gamma(tau1/2,tau2/2)
where, thetai = betaR + bi, beta = betaF, and O is an orthogonal matrix defining the decomposition of the centering covariance matrix. As in Hanson (2006), the PT prior is centered around a 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 A={alphae: e in E*}, where E*=U_{m=0}^{M} E_d^m, with E_d and E_m the d-fold product of E={0,1} and the the m-fold product of E_d, respectively. The family A was specified as alpha{e1 ... em}=α m^2.
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)
O ~ Haar(q)
Note that the inverted-Wishart prior is parametrized such that E(Sigma)= T^{-1}/(nu0-q-1).
The precision or total mass parameter, α, of the DP
prior
can be considered as random, having a gamma
distribution, Gamma(a0,b0),
or fixed at some particular value.
The computational implementation of the model is based on the marginalization of
the PT
as descried in Jara, Hanson and Lesaffre (2009).
An object of class PTlmm
representing the 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
, sigma2e
,
mu
, the elements of Sigma
, alpha
, 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:
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. |
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. |
sigma2e |
giving the error variance. |
ortho |
giving the orthogonal matrix H , used in the decomposition of the covariance matrix. |
Alejandro Jara <ajarav@udec.cl>
Tim Hanson <hanson@biostat.umn.edu>
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. Technical Report, Department of Statistics, Universidad de Concepcion, Chile.
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.
PTrandom
,
PTglmm
, PTolmm
,
DPMglmm
, DPMlmm
, DPMolmm
,
DPlmm
, DPglmm
, DPolmm
## Not run: # School Girls Data Example data(schoolgirls) attach(schoolgirls) # Prior information prior <- list(a0=5,b0=1, M=4, typepr=1, frstlprob=FALSE, tau1=0.01,tau2=0.01, nu0=4.01, tinv=diag(10,2), mub=rep(0,2), Sb=diag(1000,2)) # Initial state state <- NULL # MCMC parameters nburn <- 10000 nsave <- 10000 nskip <- 20 ndisplay <- 1000 mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip,ndisplay=ndisplay, tune1=1.5,tune2=1.1,samplef=1) # Fitting the model fit1 <- PTlmm(fixed=height~1,random=~age|child,prior=prior,mcmc=mcmc, state=state,status=TRUE) fit1 # Summary with HPD and Credibility intervals summary(fit1) summary(fit1,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="sigma-(Intercept)") # Random effects information PTrandom(fit1) # Predictive marginal and joint distributions plot(PTrandom(fit1,predictive=TRUE)) ## End(Not run)