################################################################## ### Section 9.4.1: Misconceptions of correlation and dependence ################################################################## # Generate Fig 9.11 # Note that the scale parameter of the Gamma distribution in R corresponds to 1/scale as defined in the book  # Functions rclcop<-function(n,d,theta) { gammavals<-rgamma(n,1/theta)  result<-matrix(1,d,n) for(i in (1:n)) { result[,i]<--log(runif(d))/gammavals[i] result[,i]<-(result[,i]+1)^(-1/theta) } result } # Program library(MASS) N<-2000 # Upper left ULvals<-mvrnorm(N,c(0,0),matrix(c(1,0.5,0.5,1),2,2)) # Lower left Uvals<-pnorm(ULvals) LLvals<-qgamma(Uvals,3,1) # Upper right Uvals<-rclcop(2000,2,1) URvals<-qnorm(Uvals) # Lower right LRvals<-qgamma(1-Uvals,3,1) plot(ULvals,xlab="",ylab="") plot(t(URvals),xlab="",ylab="") plot(LLvals,xlab="",ylab="") plot(LRvals,xlab="",ylab="")