modpoissonness.plot01 <- function(ObsCounts){ # # Procedure to generate a modified Poissonnes plot from a # vector of observed counts (ObsCounts). # # Compute the modified count value nkstar # ctab <- table(ObsCounts) k <- as.numeric(names(ctab)) nk <- as.numeric(ctab) N <- sum(nk) lngth <- length(nk) nkstar <- rep(NA, lngth) indx <- which(nk > 1) nkstar[indx] <- nk[indx] - 0.67 - 0.8*nk[indx]/N indx <- which(nk == 1) nkstar[indx] <- exp(-1) # # Construct the modified Poissonness count metameter # phik <- log(nkstar) - log(N) + lgamma(k+1) # # Construct confidence intervals, first for nk > 1 # upCI <- phik loCI <- phik pk <- nk/N num <- 1.96 * sqrt(1 - pk) denom <- nk - (0.47 + 0.25*pk) * sqrt(nk) wk <- num/denom indx <- which(nk > 1) upCI[indx] <- upCI[indx] + wk[indx] loCI[indx] <- loCI[indx] - wk[indx] # # Next, construct CIs for the case nk = 1 # indx <- which(nk == 1) loCI[indx] <- loCI[indx] - 3.67 upCI[indx] <- upCI[indx] + 1.717 - 2.3/N # # Determine the total range for the plot # ymax <- max(upCI) ymin <- min(loCI) # # Generate the modified Poissonness plot of metameter (phik) vs. k, # with points where nk = 1 marked as open circles and points # where nk > 1 marked as solid circles # par(mfrow=c(1,1)) par(adj = 0.5) # plot(k, phik, xlab="k", pch = 1, ylim=c(ymin, ymax), ylab="Modified Poisson count metameter") indx <- which(nk > 1) points(k[indx], phik[indx], pch=16) # # Add CI's to plot # points(k, upCI, pch = 6) points(k, loCI, pch = 2) # # Add vertical lines connecting upper and lower CI limits # for (i in 1:lngth){ lines(c(k[i],k[i]),c(loCI[i],upCI[i])) } } modpoissonness.plot02 <- function(k,nk){ # # Procedure to generate a modified Poissonnes plot from vectors # k of counts and nk of the number of times count k is observed. # # Compute the modified count value nkstar # N <- sum(nk) lngth <- length(nk) nkstar <- rep(NA, lngth) indx <- which(nk > 1) nkstar[indx] <- nk[indx] - 0.67 - 0.8*nk[indx]/N indx <- which(nk == 1) nkstar[indx] <- exp(-1) # # Construct the modified Poissonness count metameter # phik <- log(nkstar) - log(N) + lgamma(k+1) # # Construct confidence intervals, first for nk > 1 # upCI <- phik loCI <- phik pk <- nk/N num <- 1.96 * sqrt(1 - pk) denom <- nk - (0.47 + 0.25*pk) * sqrt(nk) wk <- num/denom indx <- which(nk > 1) upCI[indx] <- upCI[indx] + wk[indx] loCI[indx] <- loCI[indx] - wk[indx] # # Next, construct CIs for the case nk = 1 # indx <- which(nk == 1) loCI[indx] <- loCI[indx] - 3.67 upCI[indx] <- upCI[indx] + 1.717 - 2.3/N # # Determine the total range for the plot # ymax <- max(upCI) ymin <- min(loCI) # # Generate the modified Poissonness plot of metameter (phik) vs. k, # with points where nk = 1 marked as open circles and points # where nk > 1 marked as solid circles # par(mfrow=c(1,1)) par(adj = 0.5) # plot(k, phik, xlab="k", pch = 1, ylim=c(ymin, ymax), ylab="Modified Poisson count metameter") indx <- which(nk > 1) points(k[indx], phik[indx], pch=16) # # Add CI's to plot # points(k, upCI, pch = 6) points(k, loCI, pch = 2) # # Add vertical lines connecting upper and lower CI limits # for (i in 1:lngth){ lines(c(k[i],k[i]),c(loCI[i],upCI[i])) } }