negbiness.plot01 <- function(ObsCounts, r){ # # Procedure to generate a negative binomialness plot from a # vector of observed counts (ObsCounts) for the negative # binomial distribution parameter r. # # Construct the negative binomialness count metameter # ctab <- table(ObsCounts) k <- as.numeric(names(ctab)) nk <- as.numeric(ctab) N <- sum(nk) phik <- log(nk) - log(N) + lgamma(k+r) - lgamma(r) - lgamma(k+1) # # Generate the negative binomialness 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="Negative binomialness 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 # } negbiness.plot02 <- function(k, nk, r){ # # Procedure to generate a negative binomialness plot from # vectors of the number of times nk that k counts are observed, # for the negative binomial distribution parameter r. # # Construct the negative binomialness count metameter # N <- sum(nk) phik <- log(nk) - log(N) + lgamma(k+r) - lgamma(r) - lgamma(k+1) # # Generate the negative binomialness 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="Negative binomialness 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 # }