## Not run:
# ## Simulate sample of size 100 from a refractory exponential distribution
# set.seed(1102006,"Mersenne-Twister")
# sampleSize <- 100
# rate.true <- 20
# rp.true <- 0.01
# sampRE <- rrexp(sampleSize,rate=rate.true,rp=rp.true)
# sampREmleRE <- rexpMLE(sampRE)
# rbind(est = sampREmleRE$estimate,se = sampREmleRE$se,true = c(rate.true,rp.true))
#
# ## make a parametric boostrap to check the distribution of the deviance
# nbReplicate <- 10000
# system.time(
# devianceRE100 <- replicate(nbReplicate,{
# sampRE <- rrexp(sampleSize,rate=rate.true,rp=rp.true)
# sampREmleRE <- rexpMLE(sampRE)
# -2*sampREmleRE$r(rate.true,rp.true)
# }
# )
# )[3]
#
# ## Get 95 and 99% confidence intervals for the QQ plot
# ci <- sapply(1:nbReplicate,
# function(idx) qchisq(qbeta(c(0.005,0.025,0.975,0.995),
# idx,
# nbReplicate-idx+1),
# df=2)
# )
# ## make QQ plot
# X <- qchisq(ppoints(nbReplicate),df=2)
# Y <- sort(devianceRE100)
# X11()
# plot(X,Y,type="n",
# xlab=expression(paste(chi[2]^2," quantiles")),
# ylab="MC quantiles",
# main="Deviance with true parameters after ML fit of refractory Poisson data",
# sub=paste("sample size:", sampleSize,"MC replicates:", nbReplicate)
# )
# abline(a=0,b=1)
# lines(X,ci[1,],lty=2)
# lines(X,ci[2,],lty=2)
# lines(X,ci[3,],lty=2)
# lines(X,ci[4,],lty=2)
# lines(X,Y,col=2)
# ## End(Not run)
Run the code above in your browser using DataLab