R: Bayesian analysis for a Finite Polya Tree Rasch model

FPTrasch {DPpackage} | R Documentation

## Bayesian analysis for a Finite Polya Tree Rasch model

### Description

This function generates a posterior density sample for a Rasch model, using a Finite Polya Tree or a Mixture of Finite Polya Trees prior for the distribution of the abilities.

### Usage

    FPTrasch(y,prior,mcmc,offset,state,status,
             grid=seq(-10,10,length=1000),
             data=sys.frame(sys.parent()),compute.band=FALSE)

### Arguments

`y` | a matrix giving the data for which the Rasch Model is to be fitted.
`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 Finite Polya tree prior, `alpha` giving the value of the precision parameter (it must be specified if `a0` is missing), `mub` and `Sb` giving the hyperparameters of the normal prior distribution for the mean of the normal baseline distribution, `tau1` and `tau2` giving the hyperparameters for the prior distribution of variance of the normal baseline distribution, `sigma` giving the standard deviation of the normal baseline distribution (is must be specified if `tau1` and `tau2` are missing), `beta0` and `Sbeta0` giving the hyperparameters of the normal prior distribution for the difficulty parameters, and `M` giving the finite level to be considered for the Finite 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 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).
`offset` | this can be used to specify an a priori known component to the linear predictor.
`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).
`data` | data frame.
`compute.band` | logical variable indicating whether the confidence band for the density and CDF must be computed.

### Details

This generic function fits a Finite Polya Tree Rasch model as in San Martin et al. (2011), where the linear predictor is modeled as follows:

etaij = thetai - betaj, i=1,…,n, j=1,…,k

thetai | G ~ G

G | alpha,mu,sigma2 ~ FPT^M(Pi^{mu,sigma2},\textit{A})

where, the the PT is centered around a N(mu,sigma2) distribution, by taking each m level of the partition Pi^{mu,sigma2} to coincide with the k/2^m, k=0,…,2^m quantile of the N(mu,sigma2) distribution. The family \textit{A}={alphae: e \in E^{*}}, where E^{*}=\bigcup_{m=0}^{+infty} E^m and E^m is the m-fold product of E=\{0,1\}, 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^-2 | tau1, tau2 ~ Gamma(tau1/2,tau2/2)

Each of the parameters of the baseline distribution, mu and sigma can be considered as random or fixed at some particular value. In the first case, a Mixture of Polya Trees Process is considered as a prior for the distribution of the random effects. To let sigma to be fixed at a particular value, set tau1 to NULL in the prior specification. To let mu to be fixed at a particular value, set mub to NULL in the prior specification.

In the computational implementation of the model, a Metropolis-Hastings step is used to sample the full conditional of the difficulty parameters. The full conditionals for abilities and PT parameters are sampled using slice sampling. We refer to Jara, Hanson and Lesaffre (2009) for more details and for the description regarding sampling functionals of PTs.

### Value

An object of class `FPTrasch` representing the Rasch model fit. Generic functions such as `print`, `plot`, and `summary` have methods to show the results of the fit. The results include `beta`, `mu`, `sigma2`, and the precision parameter `alpha`.

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:

`alpha` | giving the value of the precision parameter.
`b` | a vector of dimension nsubjects giving the value of the random effects for each subject.
`beta` | giving the value of the difficulty parameters.
`mu` | giving the mean of the normal baseline distributions.
`sigma2` | giving the variance of the normal baseline distributions.

### Author(s)

Alejandro Jara <atjara@uc.cl>

### References

Hanson, T., Johnson, W. (2002) Modeling regression error with a Mixture of Polya Trees. Journal of the American Statistical Association, 97: 1020 - 1033.

Jara, A., Hanson, T., Lesaffre, E. (2009) Robustifying Generalized Linear Mixed Models using a New Class of Mixture of Multivariate Polya Trees. Journal of Computational and Graphical Statistics, 18(4): 838-860.

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.

San Martin, E., Jara, A., Rolin, J.-M., and Mouchart, M. (2011) On the Bayesian nonparametric generalization of IRT-type models. Psychometrika (To appear).

### See Also

`DPrandom`, `DPrasch`

### Examples

    ## Not run:
        ####################################
        # A simulated Data Set
        ####################################
          nsubject <- 200
          nitem <- 40

          y <- matrix(0,nrow=nsubject,ncol=nitem)
          dimnames(y) <- list(paste("id",seq(1:nsubject)),
                              paste("item",seq(1,nitem)))

          ind <- rbinom(nsubject,1,0.5)
          theta <- ind*rnorm(nsubject,1,0.25)+(1-ind)*rnorm(nsubject,3,0.25)
          beta <- c(0,seq(-1,3,length=nitem-1))
          true.density <- function(grid)
          {
             0.5*dnorm(grid,1,0.25)+0.5*dnorm(grid,3,0.25)
          }

          for(i in 1:nsubject)
          {
             for(j in 1:nitem)
             {
                eta<-theta[i]-beta[j]
                mean<-exp(eta)/(1+exp(eta))
                y[i,j]<-rbinom(1,1,mean)
             }
          }

        # Prior information

          beta0 <- rep(0,nitem-1)
          Sbeta0 <- diag(1000,nitem-1)

          prior <- list(alpha=1,
                        tau1=6.01,
                        tau2=2.01,
                        mub=0,
                        Sb=100,
                        beta0=beta0,
                        Sbeta0=Sbeta0,
                        M=5)

        # Initial state
          state <- NULL

        # MCMC parameters

          nburn <- 5000
          nsave <- 5000
          nskip <- 0
          ndisplay <- 100
          mcmc <- list(nburn=nburn,
                       nsave=nsave,
                       nskip=nskip,
                       ndisplay=ndisplay)

        # Fit the model
          fit1 <- FPTrasch(y=y,prior=prior,mcmc=mcmc,
                           state=state,status=TRUE,grid=seq(-1,5,0.01),
                           compute.band=TRUE)

        # Density estimate (along with HPD band) and truth
          plot(fit1$grid,fit1$dens.u,lwd=2,col="blue",type="l",lty=2,
               xlab=expression(theta),ylab="density")
          lines(fit1$grid,fit1$dens,lwd=2,col="blue")
          lines(fit1$grid,fit1$dens.l,lwd=2,col="blue",lty=2)
          lines(fit1$grid,true.density(fit1$grid),col="red")

        # 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)

        # Extract random effects

          DPrandom(fit1)
          plot(DPrandom(fit1))
          DPcaterpillar(DPrandom(fit1))

    ## End(Not run)

[Package DPpackage version 1.1-7.4 Index]