aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Kellner <ken@kenkellner.com>2023-12-04 20:58:45 -0500
committerKen Kellner <ken@kenkellner.com>2023-12-04 20:58:45 -0500
commit263dc822dfaa45e0f6629e363c2cd913a57386de (patch)
tree15dc4fecdee8922b172134b2d562d93dfb1a5a52
parent6a464e84c06e7fd185d43135dfa233f5b17c1591 (diff)
The summary method now more sensibly returns the summary matrix
-rw-r--r--R/summary.R27
-rw-r--r--inst/tinytest/test_jags.R3
2 files changed, 5 insertions, 25 deletions
diff --git a/R/summary.R b/R/summary.R
index dec9df3..4cdeffd 100644
--- a/R/summary.R
+++ b/R/summary.R
@@ -1,26 +1,3 @@
-
-summary.jagsUI <- function(object,digits=3,...){
-
- cat('Summary for model \'',object$modfile,'\'','\n',sep="")
- cat('Saved parameters:',object$parameters,'\n')
- if(!object$parallel){cat('MCMC ran for ',object$mcmc.info$elapsed.mins,' minutes at time ',paste(object$run.date),'.\n','\n',sep="")
- } else{cat('MCMC ran in parallel for ',object$mcmc.info$elapsed.mins,' minutes at time ',paste(object$run.date),'.\n','\n',sep="")}
-
- cat('For each of',object$mcmc.info$n.chains,'chains:\n')
- if(all(object$mcmc.info$sufficient.adapt)){cat('Adaptation: ',mean(object$mcmc.info$n.adapt),'iterations (sufficient)\n')
- }else{cat('Adaptation: ',mean(object$mcmc.info$n.adapt),'iterations (possibly insufficient)\n')}
- cat('Burn-in: ',object$mcmc.info$n.burnin,'iterations\n')
- cat('Thin rate: ',object$mcmc.info$n.thin,'iterations\n')
- cat('Total chain length: ',object$mcmc.info$n.iter+mean(object$mcmc.info$n.adapt),'iterations\n')
- cat('Posterior sample size:',object$mcmc.info$n.samples/object$mcmc.info$n.chains,'draws\n\n')
-
- if(object$mcmc.info$n.chains>1){
- if(max(unlist(object$Rhat),na.rm=TRUE)>1.1){cat('**WARNING** Rhat values indicate convergence failure.','\n')
- }else{cat('Successful convergence based on Rhat values (all < 1.1).','\n')}
- }
-
- if(object$calc.DIC){
- cat('\nDIC info: (pD = var(deviance)/2)','\npD =',round(object$pD,1),'and DIC =',round(object$DIC,digits),'\n')
- }
-
+summary.jagsUI <- function(object, ...){
+ object$summary
}
diff --git a/inst/tinytest/test_jags.R b/inst/tinytest/test_jags.R
index 9937f1e..1b30505 100644
--- a/inst/tinytest/test_jags.R
+++ b/inst/tinytest/test_jags.R
@@ -55,6 +55,9 @@ pp <- pp.check(out, "alpha", "beta")
dev.off()
expect_equal(pp, 0)
+# Other methods
+expect_identical(out$summary, summary(out))
+
# codaOnly---------------------------------------------------------------------
out <- jags(data = data, inits = inits, parameters.to.save = params,
model.file = modfile, n.chains = 3, n.adapt = 100, n.iter = 100,