ch6fourcase.genproc <- function(nrep = 200, nsamp = 100, iseed = 123){ # # This procedure generates a data frame with "nrep" rows and 4 columns, # one for each of the four distribution cases considered: binary, # uniform, Gaussian, and Student's t with 4 degrees of freedom. All # are scaled so they have zero mean and unit variance. # binvec <- vector("numeric",nrep) univec <- vector("numeric",nrep) gauvec <- vector("numeric",nrep) stuvec <- vector("numeric",nrep) # uniscl <- sqrt(3) tscl <- 1/sqrt(2) for (i in 1:nrep){ xbin <- 2*rbinom(n = nsamp, size=1, prob = 0.5) - 1 binvec[i] <- var(xbin) xunif <- runif(nsamp, min = -uniscl, max = uniscl) univec[i] <- var(xunif) xnorm <- rnorm(nsamp) gauvec[i] <- var(xnorm) xt <- tscl * rt(nsamp, df=4) stuvec[i] <- var(xt) } # oframe <- data.frame(Bin = binvec, Unif = univec, Gauss = gauvec, Studt = stuvec) oframe } ch6fig8.proc <- function(){ # figframe <- ch6fourcase.genproc() # par(mfrow=c(2,2)) par(adj = 0.5) # x <- figframe\$Bin qqnorm(x, ylab="Estimated variance", main="") qqline(x) title("Binary data") # x <- figframe\$Unif qqnorm(x, ylab="Estimated variance", main = "") qqline(x) title("Uniform data") # x <- figframe\$Gauss qqnorm(x, ylab="Estimated variance", main="") qqline(x) title("Gaussian data") # x <- figframe\$Studt qqnorm(x, ylab="Estimated variance", main = "") qqline(x) title("Student's t data") # }