R/print_ztpreg.R

Defines functions print.summary.ztpreg

#' @author Chel Hee Lee <\email{gnustats@@gmail.com}>
#' @method print summary.ztpreg
#' @S3method print summary.ztpreg
print.summary.ztpreg <- function(x, ...){

  obj <- x
  
  dist <- obj$dist
  model <- switch(dist, "poisson"="Poisson",
  "nbinom"="Negative Binomial") 
  method <- obj$method
  tab <- obj$tab
  converged <- switch(as.character(obj$converged),
  "TRUE"="successfully converged", "FALSE"="not converged")
  niters <- obj$niters
  llk <- obj$llk
  aic <- obj$aic
  df <- obj$df
  alpha <- obj$alpha
  
  LM.test <- obj$LM.test
  if(LM.test) LM.chisq <- obj$LM.chisq

  HT.est <- obj$HT.est
  if(HT.est){
    N <- obj$N
    se.N <- sqrt(obj$VarN)
    ci <- c(obj$cil, obj$ciu)  
  }
      
  cat("The model is ", converged, "\n")
  cat("Optimization method", method, "is used\n")
  cat("Number of iterations in optimization is ", niters, "\n\n") 
  cat("Coefficients for zero-truncated ", model,
  " model with log link\n\n")
  
  printCoefmat(tab, digits=max(3, getOption("digits")-2), cs.ind=1:2,
  tst.ind=3, P.values=TRUE, ...)

  cat("\nLog-likelihood = ", llk, " on ", df, "\n")
  cat("AIC = ", aic, "\n")

  if(HT.est){
    cat("\nHorvitz-Thompson Estimator for N\n")
    cat("N =", N, "(se =", se.N, ")\n")
    cat((1-alpha)*100, "% CI of N = [", ci[1], ",", ci[2], "]\n")
  }
  
  if(LM.test){
    cat("\nLagrange multiplier Test for over-dispersion \n")
    cat("Chi-square test-statistic = ", LM.chisq, "with df=1\n")
    cat("Pr(chi2 >= 0.05)=", qchisq(0.05, df=1, lower.tail=FALSE), "\n") 
  }
  
  invisible(obj)
}
NULL

Try the ipeglim package in your browser

Any scripts or data that you put into this service are public.

ipeglim documentation built on May 2, 2019, 4:31 p.m.