poissonness.plot01 <- function(ObsCounts){ # # Procedure to generate a Poissonnes plot from a # vector of observed counts (ObsCounts). # # Construct the Poissonness count metameter # ctab <- table(ObsCounts) k <- as.numeric(names(ctab)) nk <- as.numeric(ctab) N <- sum(nk) phik <- log(nk) - log(N) + lgamma(k+1) # # Generate the 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, ylab="Poisson count metameter") indx <- which(nk > 1) points(k[indx], phik[indx], pch=16) # # Generate a least squares reference line and return # the slope and intercept parameters # refmdl <- lm(phik ~ k) abline(refmdl, lty=3) lsvec <- refmdl\$coef names(lsvec) <- c("Intercept","Slope") lsvec # } poissonness.plot02 <- function(k, nk){ # # Procedure to generate a Poissonnes plot from vectors of # the number of times nk that k counts are observed. # # Construct the Poissonness count metameter # N <- sum(nk) phik <- log(nk) - log(N) + lgamma(k+1) # # Generate the 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, ylab="Poisson count metameter") indx <- which(nk > 1) points(k[indx], phik[indx], pch=16) # # Generate a least squares reference line and return # the slope and intercept parameters # refmdl <- lm(phik ~ k) abline(refmdl, lty=3) lsvec <- refmdl\$coef names(lsvec) <- c("Intercept","Slope") lsvec # }