DPMrandom             package:DPpackage             R Documentation

_E_x_t_r_a_c_t_s _R_a_n_d_o_m _E_f_f_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Extracts random effects from DPpackage objects: DPMlmm, DPMolmm,
     and DPMglmm.

_U_s_a_g_e:

     DPMrandom(object,centered=FALSE,predictive=FALSE,ngrid=1000,gridl=NULL)

_A_r_g_u_m_e_n_t_s:

  object: DPM fitted model object from which random effects estimates
          can be extracted.

centered: logical variable indicating whether the random effects should
          be extracted centered, 'bi', or  uncentered 'thetai'.

predictive: logical variable indicating whether actual or predictive
          information of the random effects should be extracted.

   ngrid: number of grid points where the density estimate is 
          evaluated. This is only used if dimension of the random
          effects is lower or equal than 2. The default value is 1000.

   gridl: The limits of the interval or rectangle covered by the grid
          as  c(xl,xu) or c(xl, xu, yl, yu), respectively. If not
          specified the grid is defined automatically. This is only
          used if dimension of the random effects is lower or equal
          than 2 and if predictive=TRUE.

_E_x_a_m_p_l_e_s:

     ## Not run: 

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

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

         # Extract random effects
         
           DPMrandom(fit1)
           DPMrandom(fit1,centered=TRUE)
           
           plot(DPMrandom(fit1))
           plot(DPMrandom(fit1,centered=TRUE))

         # Extract predictive information of random effects
         
           DPMrandom(fit1,predictive=TRUE)
           plot(DPMrandom(fit1,predictive=TRUE,gridl=c(75,89,3.8,7.5)))

     ## End(Not run)

