# NOT RUN {
#generate data. The weights are taken from uniform distribution and the
#values of x are generated from a multinomial distribution with success
#rate (0.2,0.2,0.3,0.15,0.15) for the five different status.The reference
#variable is chosen from a bernoulli distribution with success rate 0.8.
ref<-sample(1:0,1000,replace=TRUE,prob=c(0.2,0.8))
erg<-unlist(lapply(1:1000,function(z){
w<-runif(1000)
x<-sample(0:4,1000,replace=TRUE,prob=c(0.2,0.2,0.3,0.15,0.15))
zdifference_nominal(x,ref,w,norma=TRUE)
}))
hist(erg,breaks=50,main="z-difference for nominal data")
plot(seq(0.005,0.97,0.01),quantile(erg,seq(0.005,0.97,0.01)),type="l",lwd=3)
points(seq(0.005,0.97,0.01),qnorm(seq(0.005,0.97,0.01)),col="red",type="l",lwd=2,lty="dashed")
# }
Run the code above in your browser using DataLab