diff options
author | Ken Kellner <ken@kenkellner.com> | 2019-02-21 10:22:06 -0500 |
---|---|---|
committer | Ken Kellner <ken@kenkellner.com> | 2019-02-21 10:22:06 -0500 |
commit | 39354068f9de38c6b0614bdeab9e46babbf45dbd (patch) | |
tree | 92b4c769af72594910c98607a2d3d20a6e7a5a2e | |
parent | b6b231039d09bd7cbfffc50b2282999460548133 (diff) |
Put pval in plot area by default
-rw-r--r-- | NAMESPACE | 2 | ||||
-rw-r--r-- | R/ppcheck.R | 12 |
2 files changed, 5 insertions, 9 deletions
@@ -7,7 +7,7 @@ importFrom(parallel, "detectCores", "makeCluster", "clusterExport", "clusterSetRNGStream", "clusterApply", "stopCluster", "clusterEvalQ") importFrom(stats, "runif", "time", "start", "end", "quantile", "var", "sd") importFrom(grDevices, "devAskNewPage", "rainbow") -importFrom(graphics, "plot", "abline", "axis", "box", "segments", "lines", "par") +importFrom(graphics, "plot", "abline", "axis", "box", "segments", "lines", "par", "legend") importFrom(utils, "capture.output") export("jags", "jagsUI","jags.basic","autojags","pp.check", "traceplot", diff --git a/R/ppcheck.R b/R/ppcheck.R index 16ff4cf..4ecfbe4 100644 --- a/R/ppcheck.R +++ b/R/ppcheck.R @@ -7,7 +7,7 @@ pp.check <- function(x, observed, simulated, xlab=NULL, ylab=NULL, main=NULL, .. stop("MCMC chain ", deparse(substitute(observed)), " not found.", call.=FALSE) sim <- eval(parse(text=paste('x$sims.list$',simulated,sep=""))) if(is.null(sim)) - stop("MCMC chain ", deparse(substitute(siomulated)), " not found.", call.=FALSE) + stop("MCMC chain ", deparse(substitute(simulated)), " not found.", call.=FALSE) bpval <- mean(sim > obs) @@ -17,10 +17,8 @@ pp.check <- function(x, observed, simulated, xlab=NULL, ylab=NULL, main=NULL, .. if(is.null(ylab)){ ylab <- 'Simulated Data' } - usermain <- main if(is.null(main)){ - main <- paste('Posterior Predictive Check','\n', - 'Bayesian P-value =',round(bpval,2)) + main <- paste('Posterior Predictive Check') } # minval <- min(c(observed,simulated)) @@ -32,10 +30,8 @@ pp.check <- function(x, observed, simulated, xlab=NULL, ylab=NULL, main=NULL, .. xlim=plotrange,ylim=plotrange, ...) # abline(1,1) abline(0,1, lwd=2) - if(!is.null(usermain)) { - where <- if(bpval < 0.5) 'topleft' else 'bottomright' - graphics::legend(where, paste("P =", round(bpval,2)), bty='n', cex=1.5) - } + where <- if(bpval < 0.5) 'topleft' else 'bottomright' + graphics::legend(where, paste("P =", round(bpval,2)), bty='n', cex=1.5) return(bpval) } |