R/print.CARBayesST.R

Defines functions print.CARBayesST

Documented in print.CARBayesST

print.CARBayesST <- function(x,...)
{
    if(is.null(x$localised.structure))
    {
        #### Print out the model fitted
        cat("\n#################\n")
        cat("#### Model fitted\n")
        cat("#################\n")
        cat(x$model)
        cat("Regression equation - ")
        print(x$formula)
        
        #### Print out the results
        cat("\n############\n")
        cat("#### Results\n")
        cat("############\n")
        cat("Posterior quantities for selected parameters and DIC\n\n")
        print(x$summary.results[ ,c(1:3,6:7)])
        cat("\nDIC = ", x$modelfit[1], "     ", "p.d = ", x$modelfit[2], "     ", "LMPL = ", x$modelfit[5], "\n")
    }else if(class(x$localised.structure)=="numeric")
    {
        #### Print out the model fitted
        cat("\n#################\n")
        cat("#### Model fitted\n")
        cat("#################\n")
        cat(x$model)
        cat("Regression equation - ")
        print(x$formula)
        
        #### Print out the results
        cat("\n############\n")
        cat("#### Results\n")
        cat("############\n")
        cat("Posterior quantities for selected parameters and DIC\n\n")
        print(x$summary.results[ ,c(1:3,6:7)])
        cat("\nDIC = ", x$modelfit[1], "     ", "p.d = ", x$modelfit[2], "     ", "LMPL = ", x$modelfit[5], "\n")
        cat("\nNumber of clusters with the number of data points in each one\n")
        print(table(paste("group", x$localised.structure, sep="")))
        }else if(class(x$localised.structure)=="list" & nrow(x$localised.structure[[2]])==ncol(x$localised.structure[[2]]))
    {
        #### Print out the model fitted
        cat("\n#################\n")
        cat("#### Model fitted\n")
        cat("#################\n")
        cat(x$model)
        cat("Regression equation - ")
        print(x$formula)
        
        #### Print out the results
        cat("\n############\n")
        cat("#### Results\n")
        cat("############\n")
        cat("Posterior quantities for selected parameters and DIC\n\n")
        print(x$summary.results[ ,c(1:3,6:7)])
        cat("\nDIC = ", x$modelfit[1], "     ", "p.d = ", x$modelfit[2], "     ", "LMPL = ", x$modelfit[5], "\n")
        cat("\nThe number of stepchanges identified in the random effect surface")
        cat("\nthat satisfy Prob(w_ij < 0.5|data) > 0.99 is \n")
        temp <- x$localised.structure[[2]][!is.na(x$localised.structure[[2]])]
        tab <- array(NA, c(1,2))
        tab[1, ] <- c(sum(temp)/2, (length(temp)- sum(temp))/2)
        colnames(tab) <- c("stepchange", "no stepchange")
        print(tab)
    }else if(class(x$localised.structure)=="list")
    {
        #### Print out the model fitted
        cat("\n#################\n")
        cat("#### Model fitted\n")
        cat("#################\n")
        cat(x$model)
        cat("Regression equation - ")
        print(x$formula)
        
        #### Print out the results
        cat("\n############\n")
        cat("#### Results\n")
        cat("############\n")
        cat("Posterior quantities for selected parameters and DIC\n\n")
        print(x$summary.results[ ,c(1:3,6:7)])
        cat("\nDIC = ", x$modelfit[1], "     ", "p.d = ", x$modelfit[2], "     ", "LMPL = ", x$modelfit[5], "\n")
        cat("\nThe allocation of areas to temporal trends was")
        print(table(x$localised.structure[[1]]))
    }else
    {
    }
    
    return(invisible(x))
}
duncanplee/CARBayesST documentation built on May 29, 2021, 7:35 a.m.