aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Kellner <ken@kenkellner.com>2019-07-30 18:46:00 -0400
committerKen Kellner <ken@kenkellner.com>2019-07-30 18:46:00 -0400
commit275108c25c922c17110730e3d1efcd6a4ee51c62 (patch)
tree0df373ded84b32efd4dc75da6883c6f925dd310e
parentd49dd0cbb66c817e7b3669ae430ef6125cd8054c (diff)
Final adjustments for CRAN; 1.5.1 uploaded
-rw-r--r--DESCRIPTION6
-rw-r--r--NAMESPACE2
-rw-r--r--NEWS8
-rw-r--r--R/View.R5
-rw-r--r--R/geninits.R2
-rw-r--r--R/processinput.R6
-rw-r--r--man/View.Rd6
-rw-r--r--man/autojags.Rd8
-rw-r--r--man/jags.Rd30
-rw-r--r--man/jagsbasic.Rd8
-rw-r--r--man/ppcheck.Rd11
-rw-r--r--man/whiskerplot.Rd12
12 files changed, 59 insertions, 45 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index ee524be..3e850c5 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: jagsUI
-Version: 1.5.0.9000
-Date: 2019-07-26
+Version: 1.5.1
+Date: 2019-07-30
Title: A Wrapper Around 'rjags' to Streamline 'JAGS' Analyses
Author: Ken Kellner <contact@kenkellner.com>
Maintainer: Ken Kellner <contact@kenkellner.com>
@@ -17,6 +17,6 @@ Imports:
utils
SystemRequirements: JAGS (http://mcmc-jags.sourceforge.net)
Description: A set of wrappers around 'rjags' functions to run Bayesian analyses in 'JAGS' (specifically, via 'libjags'). A single function call can control adaptive, burn-in, and sampling MCMC phases, with MCMC chains run in sequence or in parallel. Posterior distributions are automatically summarized (with the ability to exclude some monitored nodes if desired) and functions are available to generate figures based on the posteriors (e.g., predictive check plots, traceplots). Function inputs, argument syntax, and output format are nearly identical to the 'R2WinBUGS'/'R2OpenBUGS' packages to allow easy switching between MCMC samplers.
-License: GPL-2
+License: GPL-3
URL: https://github.com/kenkellner/jagsUI
NeedsCompilation: no
diff --git a/NAMESPACE b/NAMESPACE
index 9fd6769..4b52685 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -11,7 +11,7 @@ importFrom(graphics, "plot", "abline", "axis", "box", "segments", "lines", "par"
importFrom(utils, "capture.output")
export("jags", "jagsUI","jags.basic","autojags","pp.check", "traceplot",
- "whiskerplot", "View")
+ "whiskerplot", "View", "jags.View")
S3method("plot", "jagsUI")
S3method("xyplot", "jagsUI")
diff --git a/NEWS b/NEWS
index de53b52..7d99733 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+# Changes from Version 1.5.0 to 1.5.1 [30 July 2019] #
+
+Fix issue when chains adapted for different numbers of iterations
+Fix crash when DIC was requested but JAGS couldn't calculate it
+Stop auto-converting 1 row/1 col matrices into vectors
+Improve pp.check plotting function
+Add some warnings about functions and arguments that will be deprecated soon
+
# Changes from Version 1.4.9 to 1.5.0 [9 September 2018] #
Fix issues with NAs in parameters.
diff --git a/R/View.R b/R/View.R
index 90b6c3e..0a49435 100644
--- a/R/View.R
+++ b/R/View.R
@@ -11,6 +11,11 @@ View.default <- function(x, title, ...){
}
View.jagsUI <- function(x,title,digits=3, ...){
+ .Deprecated("jags.View")
+ jags.View(x, title, digits=3, ...)
+}
+
+jags.View <- function(x,title,digits=3, ...){
# grab object name
if(missing(title)){
title <- paste("jagsUI:", deparse(substitute(x)))
diff --git a/R/geninits.R b/R/geninits.R
index c6da0e6..e82253d 100644
--- a/R/geninits.R
+++ b/R/geninits.R
@@ -2,7 +2,7 @@
gen.inits <- function(inits,n.chains,seed,parallel){
if(!is.null(seed)){
-
+ warning("The 'seed' argument will be deprecated in the next version. You can set it yourself with set.seed() instead.")
#Save old seed if it exists
if(exists('.Random.seed')){
old.seed <- .Random.seed
diff --git a/R/processinput.R b/R/processinput.R
index 748b23c..4eeeb23 100644
--- a/R/processinput.R
+++ b/R/processinput.R
@@ -70,6 +70,7 @@ process.input = function(x,y,inits,n.chains,n.iter,n.burnin,n.thin,n.cores,DIC=F
} else{stop('Input data must be a list of data objects OR a vector of data object names (as strings)\n')}
if(is.list(x)&&all(sapply(x,is.character))){
+ warning("Suppling a list of character strings to the data argument will be deprecated in the next version")
x = unlist(x)
}
@@ -78,7 +79,8 @@ process.input = function(x,y,inits,n.chains,n.iter,n.burnin,n.thin,n.cores,DIC=F
}
#Convert a supplied vector of characters to a list of data objects
- if((is.character(x)&is.vector(x))){
+ if((is.character(x)&is.vector(x))){
+ warning("Suppling a character vector to the data argument will be deprecated in the next version")
temp = lapply(x,get,envir = parent.frame(2))
names(temp) = x
x = temp
@@ -105,4 +107,4 @@ process.input = function(x,y,inits,n.chains,n.iter,n.burnin,n.thin,n.cores,DIC=F
if(verbose){cat('\nDone.','\n','\n')}
return(list(data=x,params=params,inits=init.vals,n.cores=n.cores))
-} \ No newline at end of file
+}
diff --git a/man/View.Rd b/man/View.Rd
index 60abd0b..7246a87 100644
--- a/man/View.Rd
+++ b/man/View.Rd
@@ -2,6 +2,7 @@
% functions
\alias{View}
\alias{View.jagsUI}
+\alias{jags.View}
\title{View a jagsUI output object in a separate window}
@@ -21,8 +22,11 @@
\description{
Show an R object in a separate, spreadsheet-style window. This is an S3 generic version of \code{\link[utils]{View}}.
+
+The method will be deprecated in the next version due to constant issues with IDEs especially RStudio.
+It will be replacted with a standalone function \code{jags.View()}, which you can use now.
}
\author{
Ken Kellner \email{contact@kenkellner.com} and Mike Meredith.
-} \ No newline at end of file
+}
diff --git a/man/autojags.Rd b/man/autojags.Rd
index d86320a..a2d4e41 100644
--- a/man/autojags.Rd
+++ b/man/autojags.Rd
@@ -16,7 +16,8 @@ autojags(data, inits, parameters.to.save, model.file,
bugs.format=FALSE, Rhat.limit=1.1, max.iter=100000, verbose=TRUE)}
\arguments{
- \item{data}{A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model.}
+ \item{data}{A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model.
+ Use of a character vector will be deprecated in the next version - switch to using named lists.}
\item{inits}{A list with \code{n.chains} elements; each element of the
list is itself a list of starting values for the \code{BUGS} model,
\emph{or} a function creating (possibly random) initial values. If inits is
@@ -37,7 +38,8 @@ autojags(data, inits, parameters.to.save, model.file,
\item{DIC}{Option to report DIC and the estimated number of parameters (pD). Defaults to TRUE.}
\item{store.data}{Option to store the input dataset and initial values in the output object for future use. Defaults to FALSE.}
\item{codaOnly}{Optional character vector of parameter names for which you do NOT want to calculate detailed statistics. This may be helpful when you have many output parameters (e.g., predicted values) and you want to save time. For these parameters, only the mean value will be calculated but the mcmc output will still be found in $sims.list and $samples.}
- \item{seed}{Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer.}
+ \item{seed}{Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer.
+ This argument will be deprecated in the next version, but you can always set the outside the function yourself.}
\item{bugs.format}{Option to print JAGS output in classic R2WinBUGS format. Default is FALSE.}
\item{Rhat.limit}{Set the desired cutoff point for convergence; when all Rhat values are less than this value the model assumes convergence has been reached and will stop auto-updating.}
\item{max.iter}{Maximum number of total iterations allowed via auto-update (including burn-in).}
@@ -50,4 +52,4 @@ Usage and output is otherwise identical to the \code{jags} function.
\author{
Ken Kellner \email{contact@kenkellner.com}.
-} \ No newline at end of file
+}
diff --git a/man/jags.Rd b/man/jags.Rd
index fc2bcd1..f121c06 100644
--- a/man/jags.Rd
+++ b/man/jags.Rd
@@ -21,7 +21,8 @@ jags(data, inits, parameters.to.save, model.file,
codaOnly=FALSE,seed=NULL, bugs.format=FALSE, verbose=TRUE)}
\arguments{
- \item{data}{A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model.}
+ \item{data}{A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model.
+ Use of a character vector will be deprecated in the next version - switch to using named lists.}
\item{inits}{A list with \code{n.chains} elements; each element of the
list is itself a list of starting values for the \code{BUGS} model,
\emph{or} a function creating (possibly random) initial values. If inits is
@@ -41,7 +42,8 @@ jags(data, inits, parameters.to.save, model.file,
\item{DIC}{Option to report DIC and the estimated number of parameters (pD). Defaults to TRUE.}
\item{store.data}{Option to store the input dataset and initial values in the output object for future use. Defaults to FALSE.}
\item{codaOnly}{Optional character vector of parameter names for which you do NOT want to calculate detailed statistics. This may be helpful when you have many output parameters (e.g., predicted values) and you want to save time. For these parameters, only the mean value will be calculated but the mcmc output will still be found in $sims.list and $samples.}
- \item{seed}{Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer.}
+ \item{seed}{Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer.
+ This argument will be deprecated in the next version, but you can always set the outside the function yourself.}
\item{bugs.format}{Option to print JAGS output in classic R2WinBUGS format. Default is FALSE.}
\item{verbose}{If set to FALSE, all text output in the console will be suppressed as the function runs (including most warnings).}
}
@@ -101,17 +103,9 @@ n <- length(employed)
#Input data objects must be numeric, and must be
#scalars, vectors, matrices, or arrays.
-#Package together: several possible ways
-
-#1. A named list of the objects
+#Package together
data <- list(gnp=gnp,employed=employed,n=n)
-
-#2. A character vector of the names of the objects
-data <- c('gnp','employed','n')
-
-#3. A list of names of the objects
-data <- list('gnp','employed','n')
-
+
######################################
## 2. Write model file ##
######################################
@@ -121,6 +115,10 @@ data <- list('gnp','employed','n')
#Generate model file directly in R
#(could also read in existing model file)
+#Identify filepath of model file
+modfile <- tempfile()
+
+#Write model to file
writeLines("
model{
@@ -139,11 +137,7 @@ model{
tau <- pow(sigma,-2)
}
-", con="model.txt")
-
-#Identify filepath of model file;
-#in this case in the working directory
-modfile <- 'model.txt'
+", con=modfile)
######################################
## 3. Initialize Parameters ##
@@ -206,4 +200,4 @@ traceplot(out)
#Update model another 1000 iterations
out <- update(out,n.iter = 1000)
-} \ No newline at end of file
+}
diff --git a/man/jagsbasic.Rd b/man/jagsbasic.Rd
index 0d9d1be..20d3bd9 100644
--- a/man/jagsbasic.Rd
+++ b/man/jagsbasic.Rd
@@ -18,7 +18,8 @@ jags.basic(data, inits, parameters.to.save, model.file,
seed=NULL, save.model=FALSE, verbose=TRUE)}
\arguments{
- \item{data}{A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model.}
+ \item{data}{A named list of the data objects required by the model, or a character vector containing the names of the data objects required by the model.
+ Use of a character vector will be deprecated in the next version - switch to using named lists.}
\item{inits}{A list with \code{n.chains} elements; each element of the
list is itself a list of starting values for the \code{BUGS} model,
\emph{or} a function creating (possibly random) initial values. If inits is
@@ -36,7 +37,8 @@ jags.basic(data, inits, parameters.to.save, model.file,
\item{parallel}{If TRUE, run MCMC chains in parallel on multiple CPU cores}
\item{n.cores}{If parallel=TRUE, specify the number of CPU cores used. Defaults to total available cores or the number of chains, whichever is smaller.}
\item{DIC}{Option to report deviance values. Defaults to TRUE.}
- \item{seed}{Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer.}
+ \item{seed}{Option to set a custom seed to initialize JAGS chains, for reproducibility. Should be an integer.
+ This argument will be deprecated in the next version, but you can always set the outside the function yourself.}
\item{save.model}{Returns the JAGS model as part of the output object to allow updating the model later. If TRUE, the output object will instead be a list of class \code{jagsUIbasic}. Default is false.}
\item{verbose}{If set to FALSE, all text output in the console will be suppressed as the function runs (including most warnings).}
}
@@ -54,4 +56,4 @@ An object of class \code{mcmc.list}, if \code{save.model=FALSE}; if \code{save.m
\author{
Ken Kellner \email{contact@kenkellner.com}.
-} \ No newline at end of file
+}
diff --git a/man/ppcheck.Rd b/man/ppcheck.Rd
index 6c317fc..cb64938 100644
--- a/man/ppcheck.Rd
+++ b/man/ppcheck.Rd
@@ -37,7 +37,10 @@ employed <- longley$Employed
n <- length(employed)
data <- list(gnp=gnp,employed=employed,n=n)
-#Read in BUGS model file
+#Identify filepath of model file
+modfile <- tempfile()
+
+#Write model
#Note calculation of discrepancy stats fit and fit.new
#(sums of residuals)
writeLines("
@@ -66,12 +69,8 @@ model{
fit.new <- sum(res.new[])
}
-", con="model.txt")
+", con=modfile)
-#Identify filepath of model file;
-#in this case in the working directory
-modfile <- 'model.txt'
-
#Set parameters to monitor
params <- c('alpha','beta','sigma','fit','fit.new')
diff --git a/man/whiskerplot.Rd b/man/whiskerplot.Rd
index d61b1e0..fef0cc8 100644
--- a/man/whiskerplot.Rd
+++ b/man/whiskerplot.Rd
@@ -35,7 +35,9 @@ employed <- longley$Employed
n <- length(employed)
data <- list(gnp=gnp,employed=employed,n=n)
-#Read in BUGS model file
+#Identify filepath of model file
+modfile <- tempfile()
+
writeLines("
model{
@@ -54,12 +56,8 @@ model{
tau <- pow(sigma,-2)
}
-", con="model.txt")
+", con=modfile)
-#Identify filepath of model file;
-#in this case in the working directory
-modfile <- 'model.txt'
-
#Set parameters to monitor
params <- c('alpha','beta','sigma','mu')
@@ -97,4 +95,4 @@ whiskerplot(out,parameters='mu[c(1:3,7)]')
whiskerplot(out,parameters=c('mu','alpha'))
-} \ No newline at end of file
+}