Description Usage Arguments Details Value Author(s) References See Also Examples
This function generates a posterior density sample for a semiparametric Rasch model, using a LDDP mixture of normals prior for the distribution of the random effects.
1 2 3 4 5 |
formula |
a two-sided linear formula object describing the
model fit, with the response on the
left of a |
prior |
a list giving the prior information. The list includes the following
parameter: |
mcmc |
a list giving the MCMC parameters. The list must include
the following integers: |
offset |
this can be used to specify an a priori known component to be included in the linear predictor during the fitting. |
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 ( |
grid |
grid points where the density estimate is evaluated. The default is seq(-10,10,length=1000). |
zpred |
a matrix giving the covariate values where the predictive density is evaluated. |
data |
data frame. |
compute.band |
logical variable indicating whether the confidence band for the density and CDF must be computed. |
This generic function fits a linear dependent semiparametric Rasch model as in Farina et al. (2009), where
etaij = thetai - betaj, i=1,…,n, j=1,…,k
beta | beta0, Sbeta0 ~ N(beta0,Sbeta0)
thetai | fXi ~ fXi
fXi = \int N(Xi alphac, sigma2) G(d alphac d sigma2)
G | alpha, G0 ~ DP(alpha G0)
where, G0 = N(alphac| mub, sb)Gamma(sigma^-2|tau1/2,tau2/2). To complete the model specification, the following independent hyperpriors are assumed,
alpha | a0, b0 ~ Gamma(a0,b0)
mub | m0, S0 ~ N(m0,S0)
sb | nu, psi ~ IW(nu,psi)
tau2 ~ Gamma(tau2 | taus1, taus2 ~ Gamma(taus1/2,taus2/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 and 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.
The computational implementation of the model is based on the marginalization of
the DP
and on the use of MCMC methods for non-conjugate DPM models (see, e.g,
MacEachern and Muller, 1998; Neal, 2000).
An object of class LDDPrasch
representing the LDDP mixture of normals Rasch model.
Generic functions such as print
, plot
,
and summary
have methods to show the results of the fit. The results include
beta
, mub
, sb
, tau2
, 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 vector of dimension nsubjects giving the value of the random effects for each subject. |
beta |
giving the value of the difficulty parameters. |
alphaclus |
a matrix of dimension (number of subject + 100) times the
number of columns in the design matrix, giving the
regression coefficients for each cluster (only the first |
sigmaclus |
a vector of dimension (number of subjects + 100) giving the variance of the normal kernel for
each cluster (only the first |
alpha |
giving the value of the precision parameter. |
mub |
giving the mean of the normal baseline distributions. |
sb |
giving the covariance matrix the normal baseline distributions. |
ncluster |
an integer giving the number of clusters. |
ss |
an interger vector defining to which of the |
tau2 |
giving the value of the tau2 parameter. |
Alejandro Jara <atjara@uc.cl>
De Iorio, M., Muller, P., Rosner, G., and MacEachern, S. (2004), An ANOVA model for dependent random measures," Journal of the American Statistical Association, 99(465): 205-215.
De Iorio, M., Johnson, W., Muller, P., and Rosner, G.L. (2009) Bayesian Nonparametric Nonproportional Hazards Survival Modeling. Biometrics, To Appear.
Escobar, M.D. and West, M. (1995) Bayesian Density Estimation and Inference Using Mixtures. Journal of the American Statistical Association, 90: 577-588.
Farina, P., Quintana, E., San Martin, E., Jara, A. (2009). A Dependent Semiparametric Rasch Model for the Analysis of Chilean Educational Data. In preparation.
MacEachern, S. N. and Muller, P. (1998) Estimating mixture of Dirichlet Process Models. Journal of Computational and Graphical Statistics, 7 (2): 223-338.
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.
Neal, R. M. (2000). Markov Chain sampling methods for Dirichlet process mixture models. Journal of Computational and Graphical Statistics, 9: 249-265.
DPrandom
, DPMrasch
, DPrasch
, FPTrasch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | ## Not run:
####################################
# A simulated Data Set
####################################
grid <- seq(-4,4,0.01)
dtrue1 <- function(grid)
{
0.6*dnorm(grid,-1,0.4)+
0.3*dnorm(grid,0,0.5)+
0.1*dnorm(grid,1,0.5)
}
dtrue2 <- function(grid)
{
0.5*dnorm(grid,-1,0.5)+
0.5*dnorm(grid,1,0.5)
}
dtrue3 <- function(grid)
{
0.1*dnorm(grid,-1,0.5)+
0.3*dnorm(grid,0,0.5)+
0.6*dnorm(grid,1,0.4)
}
rtrue1 <- function(n)
{
ind <- sample(x=c(1,2,3),
size=n,replace =TRUE,
prob =c(0.6,0.3,0.1))
x1 <- rnorm(n,-1,0.4)
x2 <- rnorm(n, 0,0.5)
x3 <- rnorm(n, 1,0.5)
x <- rep(0,n)
x[ind==1] <- x1[ind==1]
x[ind==2] <- x2[ind==2]
x[ind==3] <- x3[ind==3]
return(x)
}
rtrue2 <- function(n)
{
ind <- sample(x=c(1,2),
size=n,replace=TRUE,
prob =c(0.5,0.5))
x1 <- rnorm(n,-1,0.5)
x2 <- rnorm(n, 1,0.5)
x <- rep(0,n)
x[ind==1] <- x1[ind==1]
x[ind==2] <- x2[ind==2]
return(x)
}
rtrue3 <- function(n)
{
ind <- sample(x=c(1,2,3),
size=n,replace=TRUE,
prob =c(0.1,0.3,0.6))
x1 <- rnorm(n,-1,0.5)
x2 <- rnorm(n, 0,0.5)
x3 <- rnorm(n, 1,0.4)
x <- rep(0,n)
x[ind==1] <- x1[ind==1]
x[ind==2] <- x2[ind==2]
x[ind==3] <- x3[ind==3]
return(x)
}
b1 <- rtrue1(n=200)
hist(b1,prob=TRUE,xlim=c(-4,4),ylim=c(0,0.7))
lines(grid,dtrue1(grid))
b2 <- rtrue2(n=200)
hist(b2,prob=TRUE,xlim=c(-4,4),ylim=c(0,0.7))
lines(grid,dtrue2(grid))
b3 <- rtrue3(n=200)
hist(b3,prob=TRUE,xlim=c(-4,4),ylim=c(0,0.7))
lines(grid,dtrue3(grid))
nsubject <- 600
theta <- c(b1,b2,b3)
trt <- as.factor(c(rep(1,200),rep(2,200),rep(3,200)))
nitem <- 40
y <- matrix(0,nrow=nsubject,ncol=nitem)
dimnames(y)<-list(paste("id",seq(1:nsubject)),
paste("item",seq(1,nitem)))
beta <- c(0,seq(-4,4,length=nitem-1))
for(i in 1:nsubject)
{
for(j in 1:nitem)
{
eta <- theta[i]-beta[j]
prob <- exp(eta)/(1+exp(eta))
y[i,j] <- rbinom(1,1,prob)
}
}
##############################
# design's prediction matrix
##############################
zpred <- matrix(c(1,0,0,
1,1,0,
1,0,1),nrow=3,ncol=3,byrow=TRUE)
###########################
# prior
###########################
prior <- list(alpha=1,
beta0=rep(0,nitem-1),
Sbeta0=diag(1000,nitem-1),
mu0=rep(0,3),
S0=diag(100,3),
tau1=6.01,
taus1=6.01,
taus2=2.01,
nu=5,
psiinv=diag(1,3))
###########################
# mcmc
###########################
mcmc <- list(nburn=5000,
nskip=3,
ndisplay=100,
nsave=5000)
###########################
# fitting the model
###########################
fitLDDP <- LDDPrasch(formula=y ~ trt,
prior=prior,
mcmc=mcmc,
state=NULL,
status=TRUE,
zpred=zpred,
grid=grid,compute.band=TRUE)
fitLDDP
summary(fitLDDP)
#########################################
# plots
#########################################
plot(fitLDDP)
plot(fitLDDP,param="prediction")
#########################################
# plot the estimated and true densities
#########################################
par(cex=1.5,mar=c(4.1, 4.1, 1, 1))
plot(fitLDDP$grid,fitLDDP$dens.m[1,],xlim=c(-4,4),ylim=c(0,0.8),
type="l",lty=1,lwd=3,xlab="Ability",ylab="density",col=1)
lines(fitLDDP$grid,fitLDDP$dens.u[1,],lty=2,lwd=3,col=1)
lines(fitLDDP$grid,fitLDDP$dens.l[1,],lty=2,lwd=3,col=1)
lines(grid,dtrue1(grid),lwd=3,col="red",lty=3)
par(cex=1.5,mar=c(4.1, 4.1, 1, 1))
plot(fitLDDP$grid,fitLDDP$dens.m[2,],xlim=c(-4,4),ylim=c(0,0.8),
type="l",lty=1,lwd=3,xlab="Ability",ylab="density",col=1)
lines(fitLDDP$grid,fitLDDP$dens.u[2,],lty=2,lwd=3,col=1)
lines(fitLDDP$grid,fitLDDP$dens.l[2,],lty=2,lwd=3,col=1)
lines(grid,dtrue2(grid),lwd=3,col="red",lty=3)
par(cex=1.5,mar=c(4.1, 4.1, 1, 1))
plot(fitLDDP$grid,fitLDDP$dens.m[3,],xlim=c(-4,4),ylim=c(0,0.8),
type="l",lty=1,lwd=3,xlab="Ability",ylab="density",col=1)
lines(fitLDDP$grid,fitLDDP$dens.u[3,],lty=2,lwd=3,col=1)
lines(fitLDDP$grid,fitLDDP$dens.l[3,],lty=2,lwd=3,col=1)
lines(grid,dtrue3(grid),lwd=3,col="red",lty=3)
#########################################
# Extract random effects
#########################################
DPrandom(fitLDDP)
plot(DPrandom(fitLDDP))
DPcaterpillar(DPrandom(fitLDDP))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.