## Not run:
# ## ================================================================================ ##
# ## generate a simulated dataset from the negative binomial mixed-effect
# ## independent model:
# ## Y_ij | G_i = g_i ~ NB(r_ij,p_i) where r_ij = exp(X^T beta)/a , p_i =1/(a*g_i+1)
# ## with G_i ~ log-normal(E(G_i)=1,var(G_i)=th)
# set.seed(1)
# sn <- 5 # the number of repeated measures of each patient
# n <- 80 ## the number of patients
# loga <- - 0.5
# a <- exp(loga) ## dispersion parameter
# logtheta <- 1.3
# th <- exp(logtheta) ## the variance of the gamma distributed random effect g_i
#
#
# ## No difference between the means of groups
# ## The model only has an intercept term beta0 <- 0.5
# b0 <- 0.5
# u1 <- rep(exp(b0),sn) ## the mean vector for group 1 at time point 1,...,sn
# u2 <- rep(exp(b0),sn) ## the mean vector for group 2 at time point 1,...,sn
#
# ## DT.ind is generated from the IND model
# DT.ind<- rNBME.R(gdist="N", n=n, a=a, th=th, u1=u1, u2=u2, sn=sn)
# ## DT.ar is generated from AR(1) model with delta=0.4
# DT.ar<- rNBME.R(gdist="N", n=n, a=a, th=th, u1=u1, u2=u2, sn=sn, d=0.4)
#
# dt.ind<-data.frame(CEL=DT.ind$y,Vcode=DT.ind$vn-2,ID=DT.ind$id)
# dt.ar<-data.frame(CEL=DT.ar$y,Vcode=DT.ar$vn-2,ID=DT.ar$id)
# ## ================================================================================ ##
# #### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####
# #### Fit various parametric independent models ####
# #### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####
# tst1 <- lmeNB(CEL~1, data=dt.ind, ID=dt.ind$ID, IPRT=TRUE) ## gamma Gi
# tst2 <- lmeNB(CEL~1, data=dt.ar, ID=dt.ar$ID, IPRT=TRUE) ## gamma Gi
# tst3 <- lmeNB(CEL~1, data=dt.ind, ID=dt.ind$ID, IPRT=TRUE, RE="N") ## log-normal Gi
# tst4 <- lmeNB(CEL~1, data=dt.ar, ID=dt.ar$ID, IPRT=TRUE, RE="N") ## log-normal Gi
# tst5 <- lmeNB(CEL~Vcode, data=dt.ind, ID=dt.ind$ID, IPRT=TRUE, RE="N")## log-normal Gi
# ## conditional probability index with the fitted results of tst5
# Psum5 <- index.batch(olmeNB=tst5, labelnp=dt.ind$Vcode >= 1, data=dt.ind, ID=dt.ind$ID)
#
#
# #### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####
# #### Fit the semi-parametric independent model ####
# #### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####
# tst6 <- lmeNB(CEL~1, data=dt.ind, ID=dt.ind$ID, IPRT=TRUE, RE="NoN")
# tst7 <- lmeNB(CEL~Vcode, data=dt.ind, ID=dt.ind$ID, IPRT=TRUE, RE="NoN",
# semi.boot=100,labelnp=dt.ind$Vcode >= 1)
# ## semi.boot = 100 option computes bootstrap SE and 95
# ## conditional probability index with fitting result of tst7
# Psum7 <- index.batch(olmeNB=tst7,labelnp=dt.ind$Vcode >= 1, data=dt.ind,
# ID=dt.ind$ID, Vcode=Vcode)
#
# #### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####
# #### Fit the parametric AR1 models ####
# #### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ####
# tst8 <- lmeNB(CEL~1, data=dt.ind, ID=dt.ind$ID, IPRT=TRUE,AR=TRUE,Vcode=dt.ind$Vcode)
# tst9 <- lmeNB(CEL~1, data=dt.ar, ID=dt.ar$ID, IPRT=TRUE,AR=TRUE,Vcode=dt.ar$Vcode)
# ## conditional probability index
# Psum9 <- index.batch(olmeNB=tst9, labelnp=dt.ind$Vcode >= 1, data=dt.ind,
# ID=dt.ind$ID,Vcode=dt.ind$Vcode)
#
#
# ## End(Not run)
Run the code above in your browser using DataLab