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)
        cat("\n")
        
        cat("\n#################\n")
        cat("#### MCMC details\n")
        cat("#################\n")
        cat("Total number of post burnin and thinned MCMC samples generated - ")
        cat(x$mcmc.info[1])
        cat("\n")
        cat("Number of MCMC chains used - ")
        cat(x$mcmc.info[5])
        cat("\n")        
        cat("Length of the burnin period used for each chain - ")
        cat(x$mcmc.info[3])
        cat("\n")
        cat("Amount of thinning used - ")
        cat(x$mcmc.info[4])        
        cat("\n")
        
        #### 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")
    }else if(is.numeric(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)
        cat("\n")
                
        cat("\n#################\n")
        cat("#### MCMC details\n")
        cat("#################\n")
        cat("Total number of post burnin and thinned MCMC samples generated - ")
        cat(x$mcmc.info[1])
        cat("\n")
        cat("Number of MCMC chains used - ")
        cat(x$mcmc.info[5])
        cat("\n")        
        cat("Length of the burnin period used for each chain - ")
        cat(x$mcmc.info[3])
        cat("\n")
        cat("Amount of thinning used - ")
        cat(x$mcmc.info[4])        
        cat("\n")
        
        #### 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]]))
        }else if(is.list(x$localised.structure) & 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)
        cat("\n")
                
        cat("\n#################\n")
        cat("#### MCMC details\n")
        cat("#################\n")
        cat("Total number of post burnin and thinned MCMC samples generated - ")
        cat(x$mcmc.info[1])
        cat("\n")
        cat("Number of MCMC chains used - ")
        cat(x$mcmc.info[5])
        cat("\n")        
        cat("Length of the burnin period used for each chain - ")
        cat(x$mcmc.info[3])
        cat("\n")
        cat("Amount of thinning used - ")
        cat(x$mcmc.info[4])        
        cat("\n")
        
        #### 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(is.list(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)
        cat("\n")
                
        cat("\n#################\n")
        cat("#### MCMC details\n")
        cat("#################\n")
        cat("Total number of post burnin and thinned MCMC samples generated - ")
        cat(x$mcmc.info[1])
        cat("\n")
        cat("Number of MCMC chains used - ")
        cat(x$mcmc.info[5])
        cat("\n")        
        cat("Length of the burnin period used for each chain - ")
        cat(x$mcmc.info[3])
        cat("\n")
        cat("Amount of thinning used - ")
        cat(x$mcmc.info[4])        
        cat("\n")
        
        #### 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))
}

Try the CARBayesST package in your browser

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

CARBayesST documentation built on Nov. 2, 2023, 6:23 p.m.