diff --git a/DESCRIPTION b/DESCRIPTION index b3fc1cd..1a27239 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,14 @@ -Package: SimTools -Version: 1.0-0 -Date: 2021-02-24 -Title: Toolkit for Simulation Output Including Monte Carlo and MCMC -Author: Dootika Vats , - James M. Flegal , - Galin Jones , - Gunjan Jalori. -Maintainer: Dootika Vats -Imports: mcmcse, mvtnorm -Description: Toolkit for simulation output including Monte Carlo and Markov chain Monte Carlo. Tools for reliable visualisations are available, and support for multiple chain MCMC is integrated. -License: GPL (>= 2) -Encoding: UTF-8 -RoxygenNote: 7.1.1 +Package: SimTools +Version: 1.0-0 +Date: 2021-02-24 +Title: Toolkit for Simulation Output Including Monte Carlo and MCMC +Author: Dootika Vats , + James M. Flegal , + Galin Jones , + Gunjan Jalori. +Maintainer: Dootika Vats +Imports: mcmcse +Description: Toolkit for simulation output including Monte Carlo and Markov chain Monte Carlo. Tools for reliable visualisations are available, and support for multiple chain MCMC is integrated. +License: GPL (>= 2) +Encoding: UTF-8 +RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index 8899cb0..0a2a46f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,30 +1,45 @@ -# Generated by roxygen2: do not edit by hand - -S3method(as.Siid,default) -S3method(as.Smcmc,default) -S3method(boxplot,Siid) -S3method(plot,Siid) -S3method(plot,Smcmc) -export(ACF) -export(Siid) -export(Smcmc) -export(addCI) -export(as.Siid) -export(as.Smcmc) -export(boxCI) -export(getCI) -importFrom(grDevices,adjustcolor) -importFrom(grDevices,dev.interactive) -importFrom(graphics,boxplot) -importFrom(graphics,boxplot.matrix) -importFrom(graphics,par) -importFrom(graphics,polygon) -importFrom(graphics,segments) -importFrom(mcmcse,batchSize) -importFrom(mcmcse,mcse.multi) -importFrom(mvtnorm,pmvnorm) -importFrom(stats,cov) -importFrom(stats,density) -importFrom(stats,qnorm) -importFrom(stats,quantile) -importFrom(stats,ts) +# Generated by roxygen2: do not edit by hand + +S3method(as.Siid,default) +S3method(as.Smcmc,default) +S3method(boxplot,Siid) +S3method(plot,Siid) +S3method(plot,Smcmc) +S3method(print,summary.Smcmc) +S3method(summary,Smcmc) +export(Siid) +export(Smcmc) +export(acfplot) +export(addCI) +export(as.Siid) +export(as.Smcmc) +export(boxCI) +export(convert2Smcmc) +export(densityplot) +export(getCI) +export(traceplot) +importFrom(grDevices,adjustcolor) +importFrom(grDevices,dev.interactive) +importFrom(graphics,abline) +importFrom(graphics,boxplot) +importFrom(graphics,boxplot.matrix) +importFrom(graphics,lines) +importFrom(graphics,mtext) +importFrom(graphics,par) +importFrom(graphics,points) +importFrom(graphics,polygon) +importFrom(graphics,segments) +importFrom(mcmcse,batchSize) +importFrom(mcmcse,mcse.multi) +importFrom(stats,IQR) +importFrom(stats,acf) +importFrom(stats,cov) +importFrom(stats,density) +importFrom(stats,na.fail) +importFrom(stats,qchisq) +importFrom(stats,qnorm) +importFrom(stats,quantile) +importFrom(stats,rnorm) +importFrom(stats,sd) +importFrom(stats,ts) +importFrom(stats,var) diff --git a/R/Siidclass.R b/R/Siidclass.R index 0475477..e7a91f3 100644 --- a/R/Siidclass.R +++ b/R/Siidclass.R @@ -1,167 +1,169 @@ -#' @title Siid class -#' -#' @description Class for independent and identically distributed (iid) samples -#' -#' @name Siid -#' @aliases Siid as.Siid as.Siid.default is.iid -#' @usage Siid(data, varnames = colnames(data)) -#' @param data : an iid output matrix with nsim rows and p columns -#' @param varnames : a character string equal to the number of columns in \code{data} -#' -#' @return an Siid class object -#' @examples -#' # Generating iid data -#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' siid.obj <- Siid(chain) -#' -#' @export -"Siid" <- function(data, - varnames = colnames(data)) # make Siid object -{ - if(missing(data)) - stop("Data must be provided.") - - if(is.vector(data)) - data <- as.matrix(data, ncol = 1) - - nsim <- dim(data)[1] - out <- list( data = data, - nsim = nsim, - varnames = varnames ) - - class(out) <- "Siid" - return(out) -} - -"is.Siid" <- function(x) -{ - if (inherits(x, "Siid")) - return(TRUE) - return(FALSE) -} - -#' @export -"as.Siid" <- function (x, ...) - UseMethod("as.Siid") - -#' @export -"as.Siid.default" <- function (x, ...) - if (is.Siid(x)) x else Siid(x) - - -#' @title Boxplot for Siid -#' @name boxplot.Siid -#' @description Boxplots with simultaenous error bars around all quantiles for iid data. -#' @usage \method{boxplot}{Siid}(x, ..., alpha = 0.05, thresh = 0.001, -#' quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, -#' width = NULL, varwidth = FALSE, outline = TRUE, plot = TRUE, -#' border = par("fg"), col = 'white', ann = !add, -#' horizontal = FALSE, add = FALSE) -#' -#' @param x : a `Siid' class object -#' @param ... : arguments sent to boxplot -#' @param alpha : confidence level of simultaneous confidence intervals -#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure -#' @param quan.col : color for the quantile confidence intervals -#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param range : as defined for base \code{boxplot} -#' @param width : as defined for base \code{boxplot} -#' @param varwidth : as defined for base \code{boxplot} -#' @param outline : as defined for base \code{boxplot} -#' @param plot : logical indicating whether the plot is to be constructed -#' @param border : as defined for base \code{boxplot} -#' @param col : as defined for base \code{boxplot} -#' @param ann : as defined for base \code{boxplot} -#' @param horizontal : as defined for base \code{boxplot} -#' @param add : as defined for base \code{boxplot} -#' @return returns the base \code{boxplot} with simultaneous confidence intervals around -#' all quantiles -#' @examples -#' # Generating iid data -#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' siid.obj <- Siid(chain) -#' boxplot(siid.obj) -#' -#' @references -#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -#' “Assessing and Visualizing Simultaneous Simulation Error”, -#' Journal of Computational and Graphical Statistics, 2020. -#' -#' @export -"boxplot.Siid" <- function(x, ...,alpha = 0.05, thresh = 0.001, - quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, width = NULL, varwidth = FALSE, - outline = TRUE, plot = TRUE, border = par("fg"), col = 'white', - ann = !add, horizontal = FALSE, add = FALSE) -{ - x <- as.Siid(x) - Q <- c(0.25, 0.50, 0.75) - notch <- FALSE - foo3 <- getCI(x, Q, alpha = alpha, thresh = thresh, mean = FALSE, iid = TRUE) - plot.boxx(x, dimn = length(x$data[1,]), CIs = foo3, - quan.color = adjustcolor(quan.col, alpha.f = opaq), - range = range, width = width, varwidth = varwidth, notch = notch, - outline = outline,plot = plot, border = border, col = col, - ann = ann, horizontal = horizontal, add = add,...) -} - - -#' @title Plot Siid -#' -#' @description Density plots with simultaenous error bars around means and quantiles -#' for iid data. -#' -#' -#' @name plot.Siid -#' @usage \method{plot}{Siid}(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, -#' rug = TRUE, plot = TRUE, mean = TRUE, border = NA, -#' mean.col = 'plum4', quan.col = 'lightsteelblue3', -#' opaq = 0.7, auto.layout = TRUE, -#' ask = dev.interactive(), ...) -#' @param x : a `Siid' class object -#' @param Q : vector of quantiles -#' @param alpha : confidence level of simultaneous confidence intervals -#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure -#' @param rug : logical indicating whether a rug plot is desired -#' @param plot : logical argument for is plots are to be returned -#' @param mean : logical argument whether the mean is to be plotted -#' @param border : whether a border is required for the simultaneous confidence intervals -#' @param mean.col : color for the mean confidence interval -#' @param quan.col : color for the quantile confidence intervals -#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param auto.layout : logical argument for an automatic layout of plots -#' @param ask : activating interactive plots -#' @param ... : arguments passed on to the \code{density} plot in base R -#' @return returns a plot of the univariate density estimates with simultaneous -#' confidence intervals wherever asked. If \code{plot == FALSE} a list of -#' estimates and simultaneous confidence intervals. -#' @examples -#' # Generating iid data -#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' siid.obj <- Siid(chain) -#' plot(siid.obj) -#' -#' @references -#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -#' “Assessing and Visualizing Simultaneous Simulation Error”, -#' Journal of Computational and Graphical Statistics, 2020. -#' -#' @export -"plot.Siid" <- function(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, rug = TRUE, - plot = TRUE, mean = TRUE, border = NA, mean.col = 'plum4', quan.col = 'lightsteelblue3', - opaq = 0.7, auto.layout = TRUE, ask = dev.interactive(), ...) -{ - x <- as.Siid(x) - out <- getCI(x, Q, alpha, thresh = thresh, iid = TRUE, mean = mean) - if(plot == TRUE) - { - plot.CIs(x, dimn = length(x$data[1,]), CIs = out, rug = rug, bord = border, - mean.color = adjustcolor(mean.col, alpha.f = opaq), - quan.color = adjustcolor(quan.col, alpha.f = opaq), - mean = mean, auto.layout = auto.layout, - ask = ask, ...) - } - invisible(out) -} - - - +#' @title Siid class +#' +#' @description Class for independent and identically distributed (iid) samples +#' +#' @name Siid +#' @aliases Siid as.Siid as.Siid.default is.iid +#' @usage Siid(data, varnames = colnames(data)) +#' @param data : an iid output matrix with nsim rows and p columns +#' @param varnames : a character string equal to the number of columns in \code{data} +#' +#' @return an Siid class object +#' @examples +#' # Generating iid data +#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) +#' siid.obj <- Siid(chain) +#' +#' @export +"Siid" <- function(data, + varnames = colnames(data)) # make Siid object +{ + if(missing(data)) + stop("Data must be provided.") + + if(is.vector(data)) + data <- as.matrix(data, ncol = 1) + + nsim <- dim(data)[1] + out <- list( data = data, + nsim = nsim, + varnames = varnames ) + + class(out) <- "Siid" + return(out) +} + +"is.Siid" <- function(x) +{ + if (inherits(x, "Siid")) + return(TRUE) + return(FALSE) +} + +#' @export +"as.Siid" <- function (x, ...) + UseMethod("as.Siid") + +#' @export +"as.Siid.default" <- function (x, ...) + if (is.Siid(x)) x else Siid(x) + + +#' @title Boxplot for Siid +#' @name boxplot.Siid +#' @description Boxplots with simultaenous error bars around all quantiles for iid data. +#' @usage \method{boxplot}{Siid}(x, ..., alpha = 0.05, thresh = 0.001, +#' quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, +#' width = NULL, varwidth = FALSE, outline = TRUE, plot = TRUE, +#' border = par("fg"), col = 'white', ann = !add, +#' horizontal = FALSE, add = FALSE) +#' +#' @param x : a `Siid' class object +#' @param ... : arguments sent to boxplot +#' @param alpha : confidence level of simultaneous confidence intervals +#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure +#' @param quan.col : color for the quantile confidence intervals +#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. +#' @param range : as defined for base \code{boxplot} +#' @param width : as defined for base \code{boxplot} +#' @param varwidth : as defined for base \code{boxplot} +#' @param outline : as defined for base \code{boxplot} +#' @param plot : logical indicating whether the plot is to be constructed +#' @param border : as defined for base \code{boxplot} +#' @param col : as defined for base \code{boxplot} +#' @param ann : as defined for base \code{boxplot} +#' @param horizontal : as defined for base \code{boxplot} +#' @param add : as defined for base \code{boxplot} +#' @return returns the base \code{boxplot} with simultaneous confidence intervals around +#' all quantiles +#' @examples +#' # Generating iid data +#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) +#' siid.obj <- Siid(chain) +#' boxplot(siid.obj) +#' +#' @references +#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., +#' “Assessing and Visualizing Simultaneous Simulation Error”, +#' Journal of Computational and Graphical Statistics, 2020. +#' +#' @export +"boxplot.Siid" <- function(x, ...,alpha = 0.05, thresh = 0.001, + quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, width = NULL, varwidth = FALSE, + outline = TRUE, plot = TRUE, border = par("fg"), col = 'white', + ann = !add, horizontal = FALSE, add = FALSE) +{ + x <- as.Siid(x) + Q <- c(0.25, 0.50, 0.75) + notch <- FALSE + foo3 <- getCI(x, Q, alpha = alpha, thresh = thresh, mean = FALSE, iid = TRUE) + plot.boxx(x, dimn = length(x$data[1,]), CIs = foo3, + quan.color = adjustcolor(quan.col, alpha.f = opaq), + range = range, width = width, varwidth = varwidth, notch = notch, + outline = outline,plot = plot, border = border, col = col, + ann = ann, horizontal = horizontal, add = add,...) +} + + +#' @title Plot Siid +#' +#' @description Density plots with simultaenous error bars around means and quantiles +#' for iid data. +#' +#' +#' @name plot.Siid +#' @usage \method{plot}{Siid}(x, which = NULL, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, +#' rug = TRUE, plot = TRUE, mean = TRUE, border = NA, +#' mean.col = 'plum4', quan.col = 'lightsteelblue3', +#' opaq = 0.7, auto.layout = TRUE, +#' ask = dev.interactive(),main = NA,...) +#' @param x : a `Siid' class object +#' @param Q : vector of quantiles +#' @param alpha : confidence level of simultaneous confidence intervals +#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure +#' @param rug : logical indicating whether a rug plot is desired +#' @param plot : logical argument for is plots are to be returned +#' @param mean : logical argument whether the mean is to be plotted +#' @param border : whether a border is required for the simultaneous confidence intervals +#' @param mean.col : color for the mean confidence interval +#' @param quan.col : color for the quantile confidence intervals +#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. +#' @param auto.layout : logical argument for an automatic layout of plots +#' @param ask : activating interactive plots +#' @param which : if one want to plots specific components +#' @param main : for main heading +#' @param ... : arguments passed on to the \code{density} plot in base R +#' @return returns a plot of the univariate density estimates with simultaneous +#' confidence intervals wherever asked. If \code{plot == FALSE} a list of +#' estimates and simultaneous confidence intervals. +#' @examples +#' # Generating iid data +#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) +#' siid.obj <- Siid(chain) +#' plot(siid.obj) +#' +#' @references +#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., +#' “Assessing and Visualizing Simultaneous Simulation Error”, +#' Journal of Computational and Graphical Statistics, 2020. +#' +#' @export +"plot.Siid" <- function(x, which = NULL, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, rug = TRUE, + plot = TRUE, mean = TRUE, border = NA, mean.col = 'plum4', quan.col = 'lightsteelblue3', + opaq = 0.7, auto.layout = TRUE, ask = dev.interactive(),main = NA, ...) +{ + x <- as.Siid(x) + out <- getCI(x, Q, alpha, thresh = thresh, iid = TRUE, mean = mean) + if(plot == TRUE) + { + plot.CIs(x, which = which, CIs = out, rug = rug, bord = border, + mean.color = adjustcolor(mean.col, alpha.f = opaq), + quan.color = adjustcolor(quan.col, alpha.f = opaq), + mean = mean, auto.layout = auto.layout, + ask = ask,main = main, ...) + } + invisible(out) +} + + + diff --git a/R/Smcmcclass.R b/R/Smcmcclass.R index 3d67810..2fcd6f8 100644 --- a/R/Smcmcclass.R +++ b/R/Smcmcclass.R @@ -1,9 +1,8 @@ ## usethis namespace: start #' @importFrom grDevices adjustcolor dev.interactive -#' @importFrom graphics boxplot par polygon segments boxplot.matrix -#' @importFrom stats cov density qnorm quantile ts +#' @importFrom graphics boxplot par polygon segments boxplot.matrix mtext lines abline points +#' @importFrom stats cov density qnorm quantile ts var qchisq rnorm sd IQR acf na.fail #' @importFrom mcmcse mcse.multi batchSize -#' @importFrom mvtnorm pmvnorm ## usethis namespace: end #' @title Smcmc class @@ -12,7 +11,7 @@ #' #' @name Smcmc #' @aliases Smcmc as.Smcmc as.Smcmc.default is.mcmc -#' @usage Smcmc(data, batch.size = TRUE, stacked = TRUE, varnames = colnames(data)) +#' @usage Smcmc(data, batch.size = TRUE, stacked = TRUE, varnames = NULL) #' @param data : a list of MCMC output matrices each with `nsim` rows and `p` columns #' @param batch.size : logical argument, if true, calculates the batch size appropriate for this Markov chain. Setting to TRUE saves time in future steps. #' @param stacked : recommended to be `TRUE`. logical argument, if true, stores a carefully stacked version of the MCMC output for use later. @@ -38,11 +37,24 @@ Smcmc <- function(data, if(missing(data)) stop("Data must be provided.") + if(!is.list(data)) + { + data = as.matrix(data) data <- list(data) - + }else + { + for(i in 1:length(data)) + { + data[[i]] = as.matrix(data[[i]]) + } + } + nsim <- dim(data[[1]])[1] - if(is.null(varnames)) varnames <- colnames(data[[1]]) + if(is.null(varnames)) + { + for(i in 1:length(data)){if(!is.null(colnames(data[[i]]))){varnames = colnames(data[[i]]);break }} + } if(stacked == TRUE) { @@ -86,31 +98,29 @@ Smcmc <- function(data, -#' @title Plot Smcmc +#' @title density plot form Smcmc class #' #' @description Density plots with simultaenous error bars around means and quantiles #' for MCMC data. The error bars account for the correlated nature of the process. #' #' -#' @name plot.Smcmc -#' @usage \method{plot}{Smcmc}(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, iid = FALSE, -#' plot = TRUE, mean = TRUE, border = NA, mean.col = 'plum4', -#' quan.col = 'lightsteelblue3',rug = TRUE, opaq = 0.7, -#' auto.layout = TRUE, ask = dev.interactive(),...) +#' @name densityplot +#' @usage densityplot(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, main = NA, iid = FALSE, +#' mean = TRUE, which = NULL, border = NA, mean.col = 'plum4', +#' quan.col = 'lightsteelblue3',rug = FALSE, opaq = 0.7, ...) #' @param x : a `Smcmc' class object #' @param Q : vector of quantiles #' @param alpha : confidence level of simultaneous confidence intervals #' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure +#' @param main : To add main heading #' @param iid : logical argument for constructing density plot for iid samples. Defaults to \code{FALSE} -#' @param plot : logical argument for is plots are to be returned #' @param mean : logical argument whether the mean is to be plotted +#' @param which : A vector of components, if you want plots of specific components. #' @param border : whether a border is required for the simultaneous confidence intervals #' @param mean.col : color for the mean confidence interval #' @param quan.col : color for the quantile confidence intervals #' @param rug : logical indicating whether a rug plot is desired #' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param auto.layout : logical argument for an automatic layout of plots -#' @param ask : activating interactive plots #' @param ... : arguments passed on to the \code{density} plot in base R #' @return returns a plot of the univariate density estimates with simultaneous #' confidence intervals wherever asked. If \code{plot == FALSE} a list of @@ -125,7 +135,7 @@ Smcmc <- function(data, #' chain[i,] <- .3*chain[i-1,] + err[i] #' } #' chain <- Smcmc(list(chain)) -#' plot(chain) +#' densityplot(chain) #' #' @references #' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., @@ -133,34 +143,308 @@ Smcmc <- function(data, #' Journal of Computational and Graphical Statistics, 2020. #' #' @export -"plot.Smcmc" <- function(x, - Q = c(0.1, 0.9), - alpha = 0.05, - thresh = 0.001, - iid = FALSE, - plot = TRUE, - mean = TRUE, - border = NA, - mean.col = 'plum4', - quan.col = 'lightsteelblue3', - rug = TRUE, - opaq = 0.7, - auto.layout = TRUE, - ask = dev.interactive(), ...) + + +"densityplot" <- function(x, + Q = c(0.1, 0.9), + alpha = 0.05, + thresh = 0.001, + main = NA, + iid = FALSE, + mean = TRUE, + which = NULL, + border = NA, + mean.col = 'plum4', + quan.col = 'lightsteelblue3', + rug = FALSE, + opaq = 0.7, ...) { x <- as.Smcmc(x) out <- getCI(x, Q, alpha, thresh = thresh, iid = iid, mean = mean) - if(plot == TRUE) + plot.CIs(x, CIs = out, bord = border, + mean.color = adjustcolor(mean.col, alpha.f = opaq), + quan.color = adjustcolor(quan.col, alpha.f = opaq), + mean = mean, rug = rug, main = main, which= which, ...) + invisible(out) +} + + +#' @title Summary plot function for Smcmc objects +#' +#' @description Plots traceplot, acfplot and densityplot of all the dimensions of +#' chains in Smcmc object +#' @usage \method{plot}{Smcmc}(x, which = NULL, ...) +#' @name plot.Smcmc +#' @param x : a `Smcmc' class object +#' @param which : If you are intresetd in few components only +#' @param ... : Other arguments +#' @return return plot(s) of the all the dimensions of Smcmc object +#' @examples +#' # Producing Markov chain +#' chain <- matrix(0, ncol = 1, nrow = 1e3) +#' chain[1,] <- 0 +#' err <- rnorm(1e3) +#' for(i in 2:1e3) +#' { +#' chain[i,] <- .3*chain[i-1,] + err[i] +#' } +#' chain <- Smcmc(list(chain)) +#' plot(chain) +#' +#'@export + +"plot.Smcmc" <- function(x, which = NULL, ...) +{ + if(!("Smcmc"%in%class(x))){stop("Argument must be Smcmc object")} + y = x$chains + dimn <- dim(y[[1]]) + n <- dimn[1] + p <- dimn[2] + m <- length(x) + p2 <- 0 + p3 <- 0 + if(!is.null(which)){p = length(which)}else{which = 1:p} + if(p>12){stop("Maximum allowed dimension is 12")} + if(p>4){p2 = p-4;p = 4} + if(p2 >4) { - plot.CIs(x, dimn = length(x$stacked[1,]), CIs = out, bord = border, - mean.color = adjustcolor(mean.col, alpha.f = opaq), - quan.color = adjustcolor(quan.col, alpha.f = opaq), - mean = mean, auto.layout = auto.layout, rug = rug, - ask = ask, ...) + p3 <- p2-4 + p2 <- 4 } - invisible(out) + par(mfrow = c(3,p),oma = c(0,0,0,0),mar = c(2.2,4,1,1)) + traceplot(x,which = which[1:p],legend = F,xlab = NA,...) + acfplot(x,which = which[1:p],xlab = NA,...) + densityplot(x,which = which[1:p],...) + + if(p2>0) + { + par(mfrow = c(3,p2),mar = c(2,4,1,2)) + traceplot(x,which = which[5:(4+p2)],legend = F,xlab = NA) + acfplot(x,which = which[5:(4+p2)],xlab = NA) + densityplot(x,which = which[5:(4+p2)]) + } + + if(p3>0) + { + par(mfrow = c(3,p3),mar = c(2,4,1,2)) + traceplot(x,which = which[9:(8+p3)],legend = F,xlab = NA) + acfplot(x,which = which[9:(8+p3)],xlab = NA) + densityplot(x,which = which[9:(8+p3)]) + } + on.exit(par(ask = FALSE,mfrow=c(1,1))) + par(mar = c(5.1, 4.1, 4.1, 2.1)) + par(fig = c(0, 1, 0 , 1)) + par(oma = c(0, 0, 0, 0)) } +#' @title Summary function for Smcmc objects +#' @name summary.Smcmc +#' @description To show different statistics of the Smcmc object +#' @usage \method{summary}{Smcmc}(object, eps = 0.10, alpha = 0.05, Q = c(0.10, 0.90), ...) +#' @param object : a `Smcmc' class object +#' @param eps : desired volume of the confidence region +#' @param alpha : Type one error/threshold percentage error +#' @param Q : desired quantiles (vector of 2) +#' @param ... : Other arguments +#' @return return statistics of the all the dimensions(& chains) in Smcmc object +#' @examples +#' # Producing Markov chain +#' chain <- matrix(0, ncol = 1, nrow = 1e3) +#' chain[1,] <- 0 +#' err <- rnorm(1e3) +#' for(i in 2:1e3) +#' { +#' chain[i,] <- .3*chain[i-1,] + err[i] +#' } +#' chain <- Smcmc(list(chain)) +#' summary(chain) +#' +#'@export + +"summary.Smcmc" <- function (object, + eps = 0.10, + alpha = 0.05, + Q = c(0.10, 0.90), ...) +{ + object <- as.Smcmc(object) + object.class <- class(object) + Batch_Size <- object$b.size + Smcmc_output <- object$chains[[1]] + stacked <- as.matrix(object$stacked) + + chains <- object$chains + n <- dim(chains[[1]])[1] + p <- dim(chains[[1]])[2] + m <- length(chains) + dimen <- vector(length = p) + if(!is.null(object$varnames)){dimen <- object$varnames }else{for(i in 1:p){dimen[i] <- paste("Component",i)}} + colname <- c("Mean","MCSE","SD",paste("Q-",Q[1],sep=""),paste("Q-",Q[2],sep=""), "ESS","G-R"," ") + c_batch = dim(stacked)[1]/m + std = 0 + for(i in 1:m) + { + a = 1+(i-1)*c_batch + b = i*c_batch + std = std + apply(as.matrix(stacked[a:b, ]),2,var) + } + std = std/m + mini_ess = floor(4*pi*qchisq(1-alpha, df = 1)/((gamma(0.5))^2*eps*eps)) + mini_multi_ess = floor(2^(2/p)*pi*qchisq(1-alpha, df = p)/((p*gamma(0.5*p))^(2/p)*eps*eps)) + statistics <- matrix(0,ncol = 7, nrow = p) + statistics[ ,1] <- round(apply(stacked,2,mean),4) + statistics[ ,3] <- round(sqrt(std),4) + statistics[ ,2] <- (round(mcmcse::mcse.mat(stacked,size = Batch_Size), 5))[ ,2] + mp_ess <- mcmcse::multiESS(stacked, size = Batch_Size) + foo <- p*log(mp_ess/n) + ms <- cov(chains[[1]]) + if(m>1) + { + for(i in 2:m) + { + ms <- ms + cov(chains[[i]]) + } + } + ms <- ms/m + correction <- sum(log(eigen(ms, symmetric = TRUE, + only.values = TRUE)$values)) - sum(log(eigen(cov(stacked), symmetric = TRUE, + only.values = TRUE)$values)) + foo <- (foo + correction)/p + n_ess <- n*exp(foo) + multiess <- floor(n_ess) + multigelmann <- round(sqrt((n-1)/n + m/n_ess),5) + + s <- vector(length = p) + for(i in 1:p) + { + ms <- var(chains[[1]][,i]) + if(m>1) + { + for(j in 2:m) + { + ms <- ms + var(chains[[j]][,i]) + } + } + s[i] <- ms + } + varquant <- round(rbind(t(apply(stacked, 2, quantile, Q))), 3) + + s <- s/m + statistics[ ,4] <- varquant[ ,1] + statistics[ ,5] <- varquant[ ,2] + statistics[ ,6] <- s/(statistics[ ,2]^2) + statistics[ ,7] <- round(sqrt(1 + m/statistics[ ,6]),5) + statistics[ ,6] <- floor(statistics[ ,6]) + statistics <- as.data.frame(statistics) + Signif.= ifelse( test = statistics[,6] >= mini_ess, yes = '*', no = '') + statistics = cbind(statistics, Signif.) + stacked_rows <- dim(stacked)[1] + colnames(statistics) <- colname + rownames(statistics) <- dimen + statistics <- drop(statistics) + summary_list <- list(nsim = n, + Dimensions = p, + no.chains = m, + Batch_Size = Batch_Size, + stacked_rows = stacked_rows, + nbatch = stacked_rows/Batch_Size, + nbatch_per_chain = stacked_rows/(Batch_Size*m), + Statistics = statistics, + MultiESS = multiess, + MultiGelmann = multigelmann, + mini_ESS = mini_ess, + mini_multi_ESS = mini_multi_ess) + class(summary_list) <- "summary.Smcmc" + return(summary_list) +} + + + + +#'@rdname summary.Smcmc +#' @param x : summary.Smcmc output +#' @param ... : Other arguments +#'@export + +"print.summary.Smcmc" <-function (x, ...) +{ + cat("\n", "No. of Iterations = ",x$nsim,"\n", sep = "") + cat("No. of Components = ",x$Dimensions,"\n", sep = "") + cat("No. of Chains = ",x$no.chains,"\n", sep = "") + cat("Number of Iterations Considered =",x$stacked_rows, "\n" ) + cat("\nNote : ESS calculations are based on estimation of means.","\n",sep = "") + cat(" There is a one-to-one relationship between ESS and Gelman-Rubin.","\n",sep = "") + cat(" Reporting either is equivalent to the other, we recommend ESS.", "\n", sep = "") + cat("\nSummary for Each Variable :\n") + print(x$Statistics, ...) + cat("\n") + cat("Multivariate ESS =", x$MultiESS) + a = x$mini_multi_ESS + b = x$MultiESS + if(b >= a){cat(" ***\n")}else{cat("\n")} + cat("Multivariate Gelman-Rubin =", x$MultiGelmann) + cat("\nNote : * indicates desired quality for this component has been achieved\n") + cat(" *** indicates desired multivariate quality has been achieved.\n") + cat("\n") + cat("For Given alpha & epsilon :","\n",sep="") + cat("Minimum ESS for Each Component =",x$mini_ESS) + cat("\nMinimum Mutltivariate ESS =",x$mini_multi_ESS) + cat("\n") + invisible(x) +} + + + + + +#' @title Covert to Smcmc Object +#' +#' @description To covert different MCMC objects to Smcmc object +#' +#' @name convert2Smcmc +#' @usage convert2Smcmc(x) +#' @param x : a object belongs from any of "mcmc.list", "stanfit", "rstan", "array", "matrix" classes. +#' @return return Smcmc object having same chain(s) +#' +#'@export + +convert2Smcmc <- function(x) +{ + if("mcmc.list"%in%class(x)) + { + temp = list(as.matrix(x[[1]])) + + for(i in 2:length(x)) + { + append(temp,as.matrix(x[[i]])) + } + return(as.Smcmc(temp)) + } + + else if("stanfit"%in%class(x) || "rstan"%in%class(x)) + { + foo <- x@sim$samples + f1 <- foo[[1]] + s <- length(f1) + f1 <- f1[-s] + samp <- Reduce('cbind', f1) + dim(foo[[1]])[1] + n = dim(Reduce('cbind',(foo[[1]])))[1] + perm = x@sim$permutation + chains = list() + for(i in 1:length(perm)) + { + chain = as.matrix(Reduce('cbind',(foo[[i]]))[(n-length(perm[[i]])):n, ]) + chains[[i]] = chain + } + return(as.Smcmc(chains)) + } + + else if("array"%in%class(x) || "matrix"%in%class(x) ||"list"%in%class(x)) + { + return(as.Smcmc(x)) + } +} + diff --git a/R/export.R b/R/export.R index 680cdbd..2dbcd61 100644 --- a/R/export.R +++ b/R/export.R @@ -37,10 +37,10 @@ addCI <- function(x, mean = TRUE, mean.color = 'plum4', quan.color = 'lightsteelblue3', - opaq = 0.7, ...) + opaq = 0.7,...) { - if(class(x) == "Smcmc") obj <- ts(x$stacked[, component]) - if(class(x) == "Siid") obj <- ts(x$data[, component]) + if("Smcmc"%in%class(x)) obj <- ts(x$stacked[, component]) + if("Siid"%in%class(x)) obj <- ts(x$data[, component]) mean.color = adjustcolor(mean.color, alpha.f = opaq) quan.color = adjustcolor(quan.color, alpha.f = opaq) mn <- CIs$mean.est[component] @@ -104,6 +104,7 @@ addCI <- function(x, #' Journal of Computational and Graphical Statistics, 2020. #' #' @export + getCI <- function(x, Q = c(0.1, 0.9), alpha = 0.05, @@ -112,7 +113,7 @@ getCI <- function(x, mean = TRUE) { - if(class(x) == "Smcmc") + if("Smcmc"%in%class(x)) { if(is.null(x$size)) { b.size <- 0 @@ -125,7 +126,7 @@ getCI <- function(x, x <- x$stacked }else{ - if(class(x) == "Siid") + if("Siid"%in%class(x)) { b.size <- 1 x <- x$data @@ -143,7 +144,7 @@ getCI <- function(x, xi.q <- apply(x, 2, quantile, Q) xi.q <- as.matrix(xi.q) if(mq==1) xi.q <- t(xi.q) - #phi is the vector of all quantiles + # phi is the vector of all quantiles phi <- rep(0, p2) for(i in 1:mq) { @@ -161,7 +162,7 @@ getCI <- function(x, I.flat <- rep(1, p1) - #since p2 was m*dim(h(x)) + # since p2 was m*dim(h(x)) lower.ci.mat <- matrix(0, nrow = mq, ncol = p2/mq) upper.ci.mat <- matrix(0, nrow = mq, ncol = p2/mq) indis <- matrix(0,nrow = n,ncol = p2) @@ -182,40 +183,65 @@ getCI <- function(x, if(mean == FALSE) lambda <- 1/fs else (lambda <- 1/c(I.flat, fs)) ci.sigma.mat <- (t(t(sigma.mat)*lambda))*lambda + p <- p1 + p2 if(mean == FALSE) p = p2 + # + # if(fast == FALSE) + # { + # z1 <- qnorm(1 - alpha/2) + # z2 <- qnorm(1 - alpha/(2*p)) + # foo1 <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) + # foo2 <- CIz(z2, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) + # if(mean == FALSE) v <- phi else v <- c(theta.hat, phi) + # + # count <- 0 + # prob1 <- pmvnorm(lower = foo1$lower.ci, upper = foo1$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] + # prob2 <- pmvnorm(lower = foo2$lower.ci, upper = foo2$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] + # + # while(prob2 - prob1 > thresh) + # { + # count <- count + 1 + # z.star <- (z1 + z2)/2 + # foo.star <- CIz(z.star, p1, p2, theta.hat, phi, ci.sigma.mat, n, mean) + # prob.star <- pmvnorm(lower = foo.star$lower.ci, upper = foo.star$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] + # if(prob.star > 1- alpha) + # { + # z2 <- z.star + # prob2 <- prob.star + # }else + # { + # z1 <- z.star + # prob1 <- prob.star + # } + # if(abs(prob1 - (1 - alpha)) < thresh) + # { + # temp <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) + # break + # } + # } + # } + # + # else + # { - z1 <- qnorm(1 - alpha/2) - z2 <- qnorm(1 - alpha/(2*p)) - foo1 <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - foo2 <- CIz(z2, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - if(mean == FALSE) v <- phi else v <- c(theta.hat, phi) - - count <- 0 - prob1 <- pmvnorm(lower = foo1$lower.ci, upper = foo1$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] - prob2 <- pmvnorm(lower = foo2$lower.ci, upper = foo2$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] - - while(prob2 - prob1 > thresh) + ## efficient algorithm to get confidence interval, by Bootstrapping + sigma.n <- (t(t(sigma.mat)*lambda))*lambda + diag.sds <- sqrt(diag(sigma.n)) + rho.matrix <- t(t(sigma.n)/diag.sds)/diag.sds + ## N is the number of Bootstrap samples + N = 20000 + Zt.mat <- matrix(0,ncol = dim(rho.matrix)[1],nrow = N) + A = t(chol(rho.matrix)) + ## Drawing RV from multivariate Normal distribution + for(i in 1:N) { - count <- count + 1 - z.star <- (z1 + z2)/2 - foo.star <- CIz(z.star, p1, p2, theta.hat, phi, ci.sigma.mat, n, mean) - prob.star <- pmvnorm(lower = foo.star$lower.ci, upper = foo.star$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] - if(prob.star > 1- alpha) - { - z2 <- z.star - prob2 <- prob.star - }else - { - z1 <- z.star - prob1 <- prob.star - } - if(abs(prob1 - (1 - alpha)) < thresh) - { - temp <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - break - } + Z = rnorm(dim(rho.matrix)[1]) + Zt.mat[i, ] <- A%*%Z } + sup.Zt <- apply(abs(Zt.mat), 1, max) + z1 <- quantile(sup.Zt, probs = 1-alpha) + #} temp <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) for(i in 1:mq) @@ -240,10 +266,11 @@ getCI <- function(x, foo3 <- list("lower.ci.mean" = lower.mean, "upper.ci.mean" = upper.mean, "lower.ci.mat" = lower.ci.mat, "upper.ci.mat" = upper.ci.mat, "mean.est" = theta.hat, "xi.q" = xi.q) } else foo3 <- list("lower.ci.mat" = lower.ci.mat, "upper.ci.mat" = upper.ci.mat, "mean.est" = theta.hat, "xi.q" = xi.q) - return(foo3) } + + ##### @@ -270,7 +297,7 @@ getCI <- function(x, #' @export boxCI <- function(x, CI, - component = 1, + component = c(1), dimn = 1, quan.color = 'lightsteelblue3', horizontal = FALSE) @@ -312,22 +339,23 @@ boxCI <- function(x, #' @description Autocorrelation function plots for MCMC data (including multiple chains) #' #' -#' @name ACF -#' @usage ACF(x,component = NULL, type = c("correlation", "covariance"), -#' plot= TRUE, lag.max = NULL, avg.col = "blue", chain.col = "red", -#' na.action = na.fail, auto.layout = TRUE, ask = dev.interactive()) +#' @name acfplot +#' @usage acfplot(x,which = NULL, type = c("correlation"), +#' plot = TRUE, main = NA, xlab = "Lag", +#' lag.max = NULL, avg.col = "blue", chain.col = "red", +#' na.action = na.fail, ...) #' #' @param x : an `Smcmc' class object or a list of Markov chains or a Markov chain matrix -#' @param component : a vector of integers indicating which components' ACF plots are needed. By default all components are drawn. -#' @param type : the kind of ACF plot: "correlation" or "covariance" +#' @param which : a vector of integers indicating which components' ACF plots are needed. By default all components are drawn. +#' @param type : the kind of ACF plot: "correlation" or "covariance". By default it is "correlation" #' @param plot : TRUE if plots are required. If FALSE, raw values are returned +#' @param main : main heading of plot +#' @param xlab : By default "Lag", pass another value, if you want to change. #' @param lag.max : Maximum lag for the ACF plot #' @param avg.col : color for the overall ACF of each component #' @param chain.col : color for the ACF of the individual chains. #' @param na.action : function to be called to handle missing values. ‘na.pass’ can be used. -#' @param auto.layout : logical argument for an automatic layout of plots -#' @param ask : activating interactive plots - +#' @param ... : Other arguments #' @return returns the autocorrelation function plots of the Markov chains. Uses the #' more accurate globally-centered ACFs. @@ -341,7 +369,7 @@ boxCI <- function(x, #' chain[i,] <- .3*chain[i-1,] + err[i] #' } #' chain <- Smcmc(list(chain)) -#' ACF(chain) +#' acfplot(chain) #' #' @references #' Agarwal, M., and Vats, D., “Globally-centered autocovariances in MCMC”, @@ -349,85 +377,370 @@ boxCI <- function(x, #' #' @export -ACF <- function(x, - component = NULL, - type = c("correlation", "covariance", "partial"), - plot = TRUE, - lag.max = NULL, - avgcol = "blue", - chain.col = "red", - na.action = na.fail, - auto.layout = TRUE, - ask = dev.interactive()) + + + +acfplot <- function(x, + which = NULL, + type = c("correlation"), + plot = TRUE, + main = NA, + xlab = "Lag", + lag.max = NULL, + avg.col = "blue", + chain.col = "red", + na.action = na.fail, ...) { - - if(is.matrix(x)) + if("partial"%in%type){stop("Partial ACFs are not supported by this function")} + varname = NULL + if(TRUE %in% (class(x) == "Smcmc")){varname = x$varnames;x <- x$chains}else if(is.list(x)) { + for(i in 1:length(x)) { x[[i]] = as.matrix(x[[i]]) } + }else if(is.vector(x)) + {2 + x <- as.matrix(x) x <- list(x) - } - if(class(x) == "Smcmc") - { - x <- x$chains - } - else if(!is.list(x)) - { - stop("x must be a matrix, list or an Smcmc object") - } + }else if(is.matrix(x)) + {x <- list(x)}else + {stop("x must be a matrix, list or an Smcmc object")} + dimn <- dim(x[[1]]) n <- dimn[1] p <- dimn[2] - - which <- as.numeric(component) - if(is.null(component)) which <- 1:p - - varnames <- colnames(x[[1]]) - if (is.null(lag.max)) lag.max <- floor(10 * (log10(n)) ) - - lag.max <- as.integer(min(lag.max, n - 1L)) m <- length(x) - - - if(plot) + if(is.null(varname)) { - setLayout(length(which)) + flag = 1 + varname <- vector(length = p) + for(i in 1:m){if(!is.null(colnames(x[[i]]))){varname = colnames(x[[i]]); flag = 0;break }} + if(flag){for(i in 1:p){varname[i] = paste("ACF",i)}} } + if(m>10){stop("Maximum 10 chains are allowed")} + if (is.null(lag.max)) lag.max <- floor(10 * (log10(n)) ) + lag.max <- as.integer(min(lag.max, n - 1L)) - for(i in which) + lay <- par() + leg <- lay$mfrow[1]*lay$mfrow[2] + if(is.null(which)) + {np = p}else + {np = length(which)} + space = 0 + if(is.null(which) && !is.null(main)){par(oma = c(4,0,3,0))} + else if(is.null(which) && is.null(main)){par(oma = c(4,0,1,0))} + axs = np-1 + t = NA + if(np <= 4){axs = np-1}else if(np<=10){axs = np-2}else{axs = 8} + if(!is.null(which)){axs = 0;t = main} + if(is.null(which)){setLayout_trace(np);dimen = 1:p;t = NA} + else{dimen = which} + if(!is.null(which) && leg == 1){par(mar = c(4,4,3,1))} + for(i in dimen) { + xi <- matrix(data = 0, nrow = n, ncol = m) - - for (j in 1:m) { + for (j in 1:m) + { xi[,j] <- x[[j]][,i] } xi <- xi - mean(xi) # global mean chain.acf <- list(length = m) - - for(j in 1:m) { + for(j in 1:m) + { chain.acf[[j]] <- acf(xi[,j], type = type, plot = FALSE, demean = FALSE, lag.max = lag.max) } - + avgf <- chain.acf[[1]] + k = 100 + l = -100 avgf$acf <- 0 for(j in 1:m) { avgf$acf <- avgf$acf + chain.acf[[j]]$acf + k = min(k,min(chain.acf[[j]]$acf)) + l = max(l,max(chain.acf[[j]]$acf)) } - avgf$acf <- avgf$acf/m + avgf$acf <- (avgf$acf)/m if(plot) { - plot(avgf, ci = 0, main = varnames[i], lwd = .2, ylim = c( - 1.96/sqrt(n), max(avgf$acf))) + if(is.null(which)){par(mar = c(0, 4.1,0, 2.1));if((i-1)%%10 == 0 && i!=1){np = np-10;if(np<=10){axs = axs + np}else{axs = axs+10}}} + plot(avgf, ci = 0, lwd = .2, ylim = c( min(- 1.96/sqrt(n),min(avgf$acf),k), max(max(avgf$acf),l)), ylab = varname[i], + lty = 1, xaxt = if(i>axs) 's' else 'n',main = t, xlab = if(i>axs) xlab else NA) for(j in 1:m) { lines(0:lag.max, as.matrix(chain.acf[[j]]$acf), type = "l", col = adjustcolor(chain.col, alpha.f = .5), lwd = 1, lty = 1, yaxt = 'n', xaxt = 'n') } - lines(0:lag.max, as.matrix(avgf$acf), type = "l", col = adjustcolor(avgcol, alpha.f = .6), lwd = 1, lty = 1, yaxt = 'n', xaxt = 'n') + lines(0:lag.max, as.matrix(avgf$acf), type = "l", col = adjustcolor(avg.col, alpha.f = .6), lwd = 1, lty = 1, yaxt = 'n', xaxt = 'n') + + if(is.null(which)){if((np%%2 != 0 && i == np-1 && np>4)||(length(dimen)>10 && i>axs && i>10)){mtext(xlab, side = 1, line = 2.3,cex = 0.8)}} } + if(plot){ + if(is.null(which) && !is.null(main)){mtext(main, side = 3, line = 1.3,outer = TRUE, cex = 1.3)} + if(is.null(which)) + { + if(np <= 4 && length(dimen)<=4){mtext(xlab, side = 1, line = 2.3,at =0.52, outer = TRUE, cex= 1)} + else if(i<=10 && i>axs){mtext(xlab, side = 1, line = 2.3,at = 0.3,outer = TRUE,cex = 0.8) + if(i %%10 == 0){mtext(xlab, side = 1, line = 2.3,at = 0.8,outer = TRUE,cex = 0.8)}} + } + } + } + if(plot && is.null(which)) + { + par(mfrow= c(1,1)) + par(mar = c(5.1, 4.1, 4.1, 2.1)) + par(fig = c(0, 1, 0 , 1)) + par(oma = c(0, 0, 0, 0)) + } + invisible(list("combined" = avgf, "individual" = chain.acf)) +} + + + + + + + + +#' @title Trace Plot for Markov chain Monte Carlo +#' @description traceplot is a graphical tool commonly used in Bayesian statistics and Markov Chain Monte Carlo(MCMC) methods to diagnose the convergence and mixing properties of a chain. +#' @name traceplot +#' @usage traceplot(x, fast = TRUE, which = NULL, +#' col = c("palevioletred3","steelblue3","tan3","dimgrey","palegreen3"), +#' xlim = NULL, ylim = NULL, main = NULL, xlab = "Iteration", +#' ylab = NULL, opaq = 0.9, legend = TRUE, ...) +#' +#'@param x : an `Smcmc' class object or a list of Markov chains or a Markov chain matrix or a vector. +#'@param fast : a Boolean argument that will be set to TRUE by default, to make plots faster. +#'@param which : if we want full size trace plots of specific dimensions of chain, we can pass a vector of respective dimension/components. +#'@param col : color vector for multiple chains +#'@param xlim : range of x-axis +#'@param ylim : range of y-axis +#'@param main : usual heading for plot +#'@param xlab : labels of x-axis +#'@param ylab : labels of y-axis,it should be a vector of length equal to dimension of chain. +#'@param opaq : To fix the opacity of lines as per user convenience, by default it is 0.9. +#'@param legend : Boolean argument, for making legend or not. +#'@param ... : Other arguments +#' @return Returns the Trace Plots of Markov Chain(s) +#' @examples +#' # example code +#' # Defining a function to produce Markov chain with dimension p and size n +#' MakeChain <- function(p, n , h = .5) +#' { +#' chain <- matrix(0, nrow = n,ncol = p) +#' for (i in 2:n) +#' { +#' prop <- chain[i-1, ] + rnorm(p, mean = 0, sd = h) +#' log.ratio <- sum(dnorm(prop, log = TRUE) - dnorm(chain[i-1, ], log = TRUE)) +#' if(log(runif(1)) < log.ratio) +#' {chain[i, ] <- prop} +#' else{chain[i, ] <- chain[i - 1, ]} +#' } +#' v = vector(length = p) +#' for(i in 1:p){v[i] = paste("Comp ",i)} +#' colnames(chain) = v +#' return(chain) +#' } +#' +#' chain1 <- MakeChain(p=4,n=1000) +#' chain2 <- MakeChain(p=4,n=1000) +#' chain3 <- MakeChain(p=4,n=1000) +#' out <- Smcmc(list(chain1,chain2,chain3)) +#' traceplot(out) +#' +#' +#' chain1 <- MakeChain(p=6,n=1000) +#' chain2 <- MakeChain(p=6,n=1000) +#' chain3 <- MakeChain(p=6,n=1000) +#' out <- Smcmc(list(chain1,chain2,chain3)) +#' traceplot(out) +#' +#' @export + +traceplot <- function(x, + fast = TRUE, + which = NULL, + col = c("palevioletred3","steelblue3","tan3","dimgrey","palegreen3"), + xlim = NULL, + ylim = NULL, + main = NULL, + xlab = "Iteration", + ylab = NULL, + opaq = 0.9, + legend = TRUE, ...) +{ + ## Check for the Data Type + varnames = NULL + if(TRUE %in% (class(x) == "Smcmc")){ varnames = x$varnames;x <- x$chains}else if(is.list(x)) + { + for(i in 1:length(x)) { x[[i]] = as.matrix(x[[i]]) } + }else if(is.vector(x)) + { + x <- as.matrix(x) + x <- list(x) + }else if(is.matrix(x)) + {x <- list(x)}else + {stop("x must be a matrix, list or an Smcmc object")} + + ## extracting the information about size & number of chains + dimn <- dim(x[[1]]) + n <- dimn[1] + p <- dimn[2] + m <- length(x) + if(p==1){which=1} + if(m==1){legend = FALSE} + if(m>5){stop("Maximum 5 chains are allowed")} + + ## Fixing y lables + if(is.null(ylab) || !is.vector(ylab) || length(ylab)!=p) + { + if(!is.null(ylab) && (!is.vector(ylab) | length(ylab) != p )) + {message("ylab should be NULL, or vector of length no. of dimension. Default value of ylab applied.")} + if(!is.null(varnames)){ylab = varnames} + + else + { + ylab <- vector(length = p) + flag = 1 + for(i in 1:m) + {if(!is.null(colnames(x[[i]]))){ylab <- colnames(x[[i]]);flag = 0;break}} + if(flag){for(i in 1:p) { ylab[i] <- paste("Comp ",i) }} + } + } + + ## fixing xlim , indexes based on xlim values + if (is.null(xlim)){xlim = c(1,n)} + if(isTRUE(fast)) + { + if(xlim[2]- xlim[1] + 1 <= 1e3){index = xlim[1]:xlim[2]} + else + { + index <- c(xlim[1], xlim[2]) + index <- c(index, sample(xlim[1] + 1:xlim[2] - 1,998,replace = FALSE)) + index <- sort(index) + } + }else{index = xlim[1]:xlim[2]} + if(isFALSE(fast) && length(index) > 10000){message("Chain size is very large and you choose to wait.")} + + ## Fixing ylim + maxi <- rep(-1e9,p) + mini <- rep(1e9,p) + vec <- vector(length = m) + for(j in 1:m) + { + if(is.null(ylim)){ + mat <- as.matrix(x[[j]][index, ]) + tempx <- rbind(apply(mat,2,max), maxi) + tempn <- rbind(apply(mat,2,min),mini) + maxi <- as.numeric(apply(tempx,2,max)) + mini <- as.numeric(apply(tempn,2, min)) + } + else{mini = rep(ylim[1],p) + maxi = rep(ylim[2],p)} + vec[j] <- paste("Chain",j) + } + + ## this if condition is for plotting trace plots of chains, + ## when which not equal to NULL and Dimension of chain exceeds 12. + if(!is.null(which)| p > 10) + { + if(p > 10 && is.null(which) ) + { + which <- 1:p + message("Number of dimension of chain(s) is more than 10. Series of plot returned.") + } + lay <- par() + leg <- lay$mfrow[1]*lay$mfrow[2] + space = 0 + l = 0.8 + if(leg != 1){legend = F} + else if(leg == 1) + { + if(is.null(main) && legend){par(oma = c(0,0,0,0),mar = c(5.1,4.1,4.1,2.1));space = 1} + else if(legend && !is.null(main)){par(oma = c(0,0,0,0),mar = c(5.1,4.1,4.1,2.1));space = 1.5;l = 2.5} + else if(!legend && !is.null(main)){par(oma = c(0,0,0,0),mar = c(5.1,4.1,4.1,2.1));l = 2} + } + + for(i in which) + { + j <- 1 + ylim <- c(mini[i],maxi[i]) + plot(x = index, y = x[[1]][index,i], xlab = xlab, ylab = ylab[i], + type = "n", ylim = ylim, xlim = xlim, col = adjustcolor(col[1], alpha.f = opaq),main = if(leg!=1){main} else{NA}, ...) + while(j <= m) + { + lines(x= index, y=x[[j]][index,i], type = "l", col = adjustcolor(col[j], + alpha.f = opaq), ylim = ylim, xlim = xlim, yaxt = 'n', xaxt = 'n', ...) + j <- j + 1 + } + + ##Setting of main + if(leg == 1) + { + if(!is.null(main)){mtext(main, side = 3, line = l,outer = F, cex = 1.5)} + ##Setting of legend + if(legend) + { + par(fig = c(0, 1, 0, 1), oma = c(0, 0, space, 0), mar = c(0, 0, 0, 0), new = TRUE) + plot(0, 0, type = 'l', bty = 'n', xaxt = 'n', yaxt = 'n') + legend("top",legend = vec, col = col[1:m],lwd = 2.2, xpd = TRUE, + horiz = TRUE,cex = 1 , seg.len= 1, bty = 'n',...) + } + } + if(leg ==1){par(mar = c(5.1, 4.1, 4.1, 2.1));par(fig = c(0, 1, 0 , 1));par(oma = c(0, 0, 0, 0))} + } + } + else + { + lay <- par() + space = 0 + l =2.2 + if(is.null(main) && legend){par(oma = c(3.5,0,3,0))} + else if(legend && !is.null(main)){par(oma = c(3.5,0,4,0)) + space = 1.1} + else if(!legend && !is.null(main)){par(oma = c(3.5,0,2.5,0)) + l = 1} + else{par(oma = c(3.5,0,0.5,0))} + axs = p-1 + if(p <= 4){axs = p-1} + else {axs = p-2} + setLayout_trace(p) + for(i in 1:p) + { + j = 2 + par(mar = c(0, 4.1,0, 2.1)) + ylim <- c(mini[i],maxi[i]) + plot(x = index, y = x[[1]][index,i], ylab =ylab[i], type = "l", ylim = ylim, xlim = xlim, + col = adjustcolor(col[1],alpha.f = opaq), xaxt = if(i>axs) 's' else 'n', ...) + while(j<=m) + { + lines(x= index, y=x[[j]][index,i], type = "l", col = adjustcolor(col[j],alpha.f = opaq), + ylim = ylim, xlim = xlim, yaxt = 'n', xaxt = 'n', ...) + j = j + 1 + } + if(p%%2 != 0 && i == p-1 && p>4){mtext("Iteration", side = 1, line = 2.3,cex = 0.7)} + } + + ## Setting of main + if(!is.null(main)){mtext(main, side = 3, line = l ,outer = TRUE, cex = 1)} + if(p<=4){mtext("Iteration", side = 1, line = 2.3,at =0.52,cex = 0.7, outer = TRUE)} + else{mtext("Iteration", side = 1, line = 2.3,at = 0.3,cex = 0.7,outer = TRUE) + if(p%%2 == 0){mtext("Iteration", side = 1, line = 2.3,at = 0.8,cex = 0.7,outer = TRUE)}} + ##Setting of legend + if(legend) + { + par(fig = c(0, 1, 0, 1), oma = c(0, 0, space, 0), mar = c(0, 0, 0, 0), new = TRUE) + plot(0, 0, type = 'l', bty = 'n', xaxt = 'n', yaxt = 'n') + legend("top",legend = vec[1:m], col = col[1:m],lwd = 2.2, xpd = TRUE, + horiz = TRUE,cex = 1.25, seg.len= 1, bty = 'n', ...) + } + on.exit(par(ask = FALSE, mfrow = lay$mfrow)) + par(mar = c(5.1, 4.1, 4.1, 2.1)) + par(fig = c(0, 1, 0 , 1)) + par(oma = c(0, 0, 0, 0)) } -on.exit( par (ask = FALSE,mfrow=c(1,1))) -invisible(list("combined" = avgf, "individual" = chain.acf)) } diff --git a/R/supp.R b/R/supp.R index 85ca2bc..957679e 100644 --- a/R/supp.R +++ b/R/supp.R @@ -4,8 +4,8 @@ Indicator <- function(x, ...) return(as.numeric(x > ... )) } -#since our goal is to optimize z, this function returns the Confidence interval -#for a particular z +# since our goal is to optimize z, this function returns the Confidence interval +# for a particular z CIz <- function(z, p1 , p2, theta.hat, phi, ci.sigma.mat, n, mean = TRUE) { @@ -27,56 +27,29 @@ CIz <- function(z, p1 , p2, theta.hat, phi, ci.sigma.mat, n, mean = TRUE) return (list("lower.ci" = c(lower.ci.p1, lower.ci.p2), "upper.ci" = c(upper.ci.p1, upper.ci.p2))) } -"set.mfrow" <-function (Nparms = 1) -{ - ## Set up dimensions of graphics window: - ## 1 x 1 if Nparms = 1 - ## 1 X 2 if Nparms = 2 - ## 2 X 2 if Nparms = 3 or 4 - ## 3 X 2 if Nparmss = 5 or 6 or 10 - 12 - ## 3 X 3 if Nparms = 7 - 9 or >= 13 - ## One plot per variable - mfrow <- switch(min(Nparms,13), - c(1,1), - c(1,2), - c(2,2), - c(2,2), - c(3,2), - c(3,2), - c(3,3), - c(3,3), - c(3,3), - c(3,2), - c(3,2), - c(3,2), - c(3,3)) - return(mfrow) -} - - +## for density plot plot.CIs <- function(x, - dimn, - CIs, - bord = NULL, - mean.color, - quan.color, - rug, - mean = TRUE, - auto.layout, - ask, ...) + CIs, + bord = NULL, + mean.color = 'plum4' , + quan.color = 'lightsteelblue3', + rug, + mean = TRUE, + main, + which, ...) { - if(class(x) == "Smcmc") + if("Smcmc"%in%class(x)) { if(is.null(x$varnames)) { - varnames <- as.character(1:dim(x$stacked)[2]) + varnames <- paste("Desity of",as.character(1:dim(x$stacked)[2])) }else{ varnames <- x$varnames } data <- x$stacked }else{ - if(class(x) == "Siid") + if("Siid"%in%class(x)) { if(is.null(x$varnames)) { @@ -87,26 +60,52 @@ plot.CIs <- function(x, data <- x$data } } - - setLayout(dimn) - for(i in 1:dimn) + p = length(data[1,]) + dimn = 1:p + if(!is.null(which)){dimn = which} + lay = par() + leg = lay$mfrow[1]*lay$mfrow[2] + if(is.null(which)) + { + setLayout_trace(p) + if(is.na(main)){par(oma = c(1,0,1,0))}else{par(oma = c(1,0,2,0))} + } + for(i in dimn) { - beta = ts(data[, i]) + if(is.null(which)){par(mar = c(1.2, 4.1,1.2, 2.1))} + else if(!is.null(which) && leg == 1){par(mar = c(4,4,2,2))} + beta = data[, i] + if ( max(abs(beta - floor(beta))) == 0 || bndw(beta) == 0 || length(unique(beta)) == 1) + { + beta = as.vector(beta) + q = unique(beta) + tab = table(beta) + p = as.vector(tab)/sum(tab) + plot_pmf(q,p,varnames[i],main,which) + } + + else + { + beta = ts(beta) + plot(density(beta, ...), main = if(is.null(which)){NA} else{main}, xlab = NA, ylab = varnames[i], lwd =1.5) + if(rug == TRUE) rug(beta, ticksize = 0.03, side = 1, lwd = 0.5) + addCI(x, CIs, component = i, bord = bord, + mean.color = mean.color, quan.color = quan.color, + mean = mean) + } - main1 = paste("Density of ",varnames[i]) - plot(density(beta), main = main1, ...) - if(rug == TRUE) rug(beta, ticksize=0.03, side=1, lwd=0.5) - main1 = paste("Density of ",varnames[i]) - addCI(x, CIs, component = i, bord = bord, - mean.color = mean.color, quan.color = quan.color, - mean = mean, ...) + if(!is.na(main) && is.null(which) && (i-1)%%10==0){mtext(main, side = 3, line = 0.05,outer = TRUE, cex = 1.5)} + } + if(leg == 1 || is.null(which)) + { + on.exit(par(mfrow=lay$mfrow)) + par(mar = c(5.1, 4.1, 4.1, 2.1)) + par(fig = c(0, 1, 0 , 1)) + par(oma = c(0, 0, 0, 0)) } - on.exit(par(ask = FALSE,mfrow=c(1,1))) - } - ## For boxplots plot.boxx <- function(x, dimn, CIs, quan.color, range, width, varwidth, notch, outline, plot, border, col, ann, horizontal, add,...) @@ -125,10 +124,11 @@ plot.boxx <- function(x, dimn, CIs, quan.color, range, width, varwidth, notch, o } } +## used in Smcmc chain_stacker <- function(x) { m <- length(x) - if(class(x) != "list") + if(!("list"%in%class(x))) stop("must be list of chains") if(is.null(x)) @@ -138,7 +138,7 @@ chain_stacker <- function(x) { p <- as.integer(ncol(x[[1]])) b.final <- floor(mean(sapply(x, batchSize))) # mean batch size - + a <- floor(n/b.final) ab <- a*b.final trash <- n-ab @@ -155,24 +155,49 @@ chain_stacker <- function(x) { return(list("b.size" = b.final, "stacked.data" = big.chain)) } -setLayout <- function(p=1, auto.layout = TRUE,pars = NULL) +## Layout for all 3 plotting function +setLayout_trace <- function(p, ask = FALSE) { - if(p < 4) { - par(mfrow = c(p,1)) + + if(p <= 4) + { + mfrow <- c(p,1) } - else if(p == 4) { - par(mfrow = c(2,2)) + + else if(p>10) + { + mfrow = c(5,2) } - else if(p == 5||p == 6){ - par(mfrow = c(3,2)) + else if(p%%2 != 0) + { + mfrow = c((p+1)/2,2) } - else { - on.exit(par(pars)) - - if (auto.layout) { - mfrow <- set.mfrow(Nparms = 6) - pars <- par(ask=FALSE,mfrow = mfrow) - } - } + else + { + mfrow = c(p/2,2) + } + par(ask = FALSE, mfrow = mfrow) + k = list(ask,mfrow) + names(k) = c("ask","mfrow") + return(k) +} + +## Bandwidth +bndw <- function(x) { + x <- x[!is.na(as.vector(x))] + return(1.06 * min(sd(x), IQR(x)/1.34) * length(x)^-0.2) } + + +## plotting PMF in discrete chain case +plot_pmf <- function(q, p, ylab, main= NA, which= NULL) { + + plot(q, p, type = "h", xlab = "x", ylab = ylab, ylim = c(-0.003,max(p)+0.01),main = if(is.null(which)){NA} else{main}) + points(q, p, pch = 16, cex = 1.2, col = "palevioletred3") + abline(a = 0,b=0,h=T,lwd =0.1,lty=1) + mp = max(p) + mq = q[which(p == mp)] + mp = rep(mp,length(mq)) + points(mq, mp, pch = 16, cex = 1.2, col = "steelblue") +} \ No newline at end of file diff --git a/README.md b/README.md index b4ce278..32a9418 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,31 @@ Leadership: [Dootika Vats](http://dvats.github.io/), [James Flegal](https://faculty.ucr.edu/~jflegal/), [Galin Jones](http://users.stat.umn.edu/~galin/) Contributors: -Gunjan Jalori +Gunjan Jalori, Siddharth Pathak Updates will be described in this README. For communication regarding issues in the code and other suggestions, please employ the issues feature on GitHub. **Run**: `runme.R` +--------------------- +Install from this branch using: +`devtools::install_github("dvats/SimTools", ref = "Siddharth-Pathak")` + +--------------------- + --------------------- Next update goal: + +--------------------- + August 25, 2023 + +The following were accomplished - multiple chain compatibility - summary function for output - compatibility for discrete state space - make efficient trace plots +- New functions to use are: `densityplot()`, `acfplot()`, `traceplot()`, `plot()`, `summary()`. --------------------- October 3, 2021 diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/DESCRIPTION b/SimTools.Rcheck/00_pkg_src/SimTools/DESCRIPTION deleted file mode 100644 index 532bb4f..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/DESCRIPTION +++ /dev/null @@ -1,16 +0,0 @@ -Package: SimTools -Version: 1.0-0 -Date: 2021-02-24 -Title: Toolkit for Simulation Output Including Monte Carlo and MCMC -Author: Dootika Vats , - James M. Flegal , - Galin Jones , - Gunjan Jalori. -Maintainer: Dootika Vats -Imports: mcmcse, mvtnorm -Description: Toolkit for simulation output including Monte Carlo and Markov chain Monte Carlo. Tools for reliable visualisations are available, and support for multiple chain MCMC is integrated. -License: GPL (>= 2) -Encoding: UTF-8 -RoxygenNote: 7.1.1 -NeedsCompilation: no -Packaged: 2021-02-24 11:45:27 UTC; Dootika diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/NAMESPACE b/SimTools.Rcheck/00_pkg_src/SimTools/NAMESPACE deleted file mode 100644 index 4e12d24..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/NAMESPACE +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by roxygen2: do not edit by hand - -S3method(as.Siid,default) -S3method(as.Smcmc,default) -S3method(boxplot,Siid) -S3method(plot,Siid) -S3method(plot,Smcmc) -export(Siid) -export(Smcmc) -export(addCI) -export(as.Siid) -export(as.Smcmc) -export(boxCI) -export(getCI) -importFrom(grDevices,adjustcolor) -importFrom(grDevices,dev.interactive) -importFrom(graphics,boxplot) -importFrom(graphics,boxplot.matrix) -importFrom(graphics,par) -importFrom(graphics,polygon) -importFrom(graphics,segments) -importFrom(mcmcse,batchSize) -importFrom(mcmcse,mcse.multi) -importFrom(mvtnorm,pmvnorm) -importFrom(stats,cov) -importFrom(stats,density) -importFrom(stats,qnorm) -importFrom(stats,quantile) -importFrom(stats,ts) diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/R/Siidclass.R b/SimTools.Rcheck/00_pkg_src/SimTools/R/Siidclass.R deleted file mode 100644 index 0475477..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/R/Siidclass.R +++ /dev/null @@ -1,167 +0,0 @@ -#' @title Siid class -#' -#' @description Class for independent and identically distributed (iid) samples -#' -#' @name Siid -#' @aliases Siid as.Siid as.Siid.default is.iid -#' @usage Siid(data, varnames = colnames(data)) -#' @param data : an iid output matrix with nsim rows and p columns -#' @param varnames : a character string equal to the number of columns in \code{data} -#' -#' @return an Siid class object -#' @examples -#' # Generating iid data -#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' siid.obj <- Siid(chain) -#' -#' @export -"Siid" <- function(data, - varnames = colnames(data)) # make Siid object -{ - if(missing(data)) - stop("Data must be provided.") - - if(is.vector(data)) - data <- as.matrix(data, ncol = 1) - - nsim <- dim(data)[1] - out <- list( data = data, - nsim = nsim, - varnames = varnames ) - - class(out) <- "Siid" - return(out) -} - -"is.Siid" <- function(x) -{ - if (inherits(x, "Siid")) - return(TRUE) - return(FALSE) -} - -#' @export -"as.Siid" <- function (x, ...) - UseMethod("as.Siid") - -#' @export -"as.Siid.default" <- function (x, ...) - if (is.Siid(x)) x else Siid(x) - - -#' @title Boxplot for Siid -#' @name boxplot.Siid -#' @description Boxplots with simultaenous error bars around all quantiles for iid data. -#' @usage \method{boxplot}{Siid}(x, ..., alpha = 0.05, thresh = 0.001, -#' quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, -#' width = NULL, varwidth = FALSE, outline = TRUE, plot = TRUE, -#' border = par("fg"), col = 'white', ann = !add, -#' horizontal = FALSE, add = FALSE) -#' -#' @param x : a `Siid' class object -#' @param ... : arguments sent to boxplot -#' @param alpha : confidence level of simultaneous confidence intervals -#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure -#' @param quan.col : color for the quantile confidence intervals -#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param range : as defined for base \code{boxplot} -#' @param width : as defined for base \code{boxplot} -#' @param varwidth : as defined for base \code{boxplot} -#' @param outline : as defined for base \code{boxplot} -#' @param plot : logical indicating whether the plot is to be constructed -#' @param border : as defined for base \code{boxplot} -#' @param col : as defined for base \code{boxplot} -#' @param ann : as defined for base \code{boxplot} -#' @param horizontal : as defined for base \code{boxplot} -#' @param add : as defined for base \code{boxplot} -#' @return returns the base \code{boxplot} with simultaneous confidence intervals around -#' all quantiles -#' @examples -#' # Generating iid data -#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' siid.obj <- Siid(chain) -#' boxplot(siid.obj) -#' -#' @references -#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -#' “Assessing and Visualizing Simultaneous Simulation Error”, -#' Journal of Computational and Graphical Statistics, 2020. -#' -#' @export -"boxplot.Siid" <- function(x, ...,alpha = 0.05, thresh = 0.001, - quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, width = NULL, varwidth = FALSE, - outline = TRUE, plot = TRUE, border = par("fg"), col = 'white', - ann = !add, horizontal = FALSE, add = FALSE) -{ - x <- as.Siid(x) - Q <- c(0.25, 0.50, 0.75) - notch <- FALSE - foo3 <- getCI(x, Q, alpha = alpha, thresh = thresh, mean = FALSE, iid = TRUE) - plot.boxx(x, dimn = length(x$data[1,]), CIs = foo3, - quan.color = adjustcolor(quan.col, alpha.f = opaq), - range = range, width = width, varwidth = varwidth, notch = notch, - outline = outline,plot = plot, border = border, col = col, - ann = ann, horizontal = horizontal, add = add,...) -} - - -#' @title Plot Siid -#' -#' @description Density plots with simultaenous error bars around means and quantiles -#' for iid data. -#' -#' -#' @name plot.Siid -#' @usage \method{plot}{Siid}(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, -#' rug = TRUE, plot = TRUE, mean = TRUE, border = NA, -#' mean.col = 'plum4', quan.col = 'lightsteelblue3', -#' opaq = 0.7, auto.layout = TRUE, -#' ask = dev.interactive(), ...) -#' @param x : a `Siid' class object -#' @param Q : vector of quantiles -#' @param alpha : confidence level of simultaneous confidence intervals -#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure -#' @param rug : logical indicating whether a rug plot is desired -#' @param plot : logical argument for is plots are to be returned -#' @param mean : logical argument whether the mean is to be plotted -#' @param border : whether a border is required for the simultaneous confidence intervals -#' @param mean.col : color for the mean confidence interval -#' @param quan.col : color for the quantile confidence intervals -#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param auto.layout : logical argument for an automatic layout of plots -#' @param ask : activating interactive plots -#' @param ... : arguments passed on to the \code{density} plot in base R -#' @return returns a plot of the univariate density estimates with simultaneous -#' confidence intervals wherever asked. If \code{plot == FALSE} a list of -#' estimates and simultaneous confidence intervals. -#' @examples -#' # Generating iid data -#' chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' siid.obj <- Siid(chain) -#' plot(siid.obj) -#' -#' @references -#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -#' “Assessing and Visualizing Simultaneous Simulation Error”, -#' Journal of Computational and Graphical Statistics, 2020. -#' -#' @export -"plot.Siid" <- function(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, rug = TRUE, - plot = TRUE, mean = TRUE, border = NA, mean.col = 'plum4', quan.col = 'lightsteelblue3', - opaq = 0.7, auto.layout = TRUE, ask = dev.interactive(), ...) -{ - x <- as.Siid(x) - out <- getCI(x, Q, alpha, thresh = thresh, iid = TRUE, mean = mean) - if(plot == TRUE) - { - plot.CIs(x, dimn = length(x$data[1,]), CIs = out, rug = rug, bord = border, - mean.color = adjustcolor(mean.col, alpha.f = opaq), - quan.color = adjustcolor(quan.col, alpha.f = opaq), - mean = mean, auto.layout = auto.layout, - ask = ask, ...) - } - invisible(out) -} - - - diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/R/Smcmcclass.R b/SimTools.Rcheck/00_pkg_src/SimTools/R/Smcmcclass.R deleted file mode 100644 index 1410083..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/R/Smcmcclass.R +++ /dev/null @@ -1,165 +0,0 @@ -## usethis namespace: start -#' @importFrom grDevices adjustcolor dev.interactive -#' @importFrom graphics boxplot par polygon segments boxplot.matrix -#' @importFrom stats cov density qnorm quantile ts -#' @importFrom mcmcse mcse.multi batchSize -#' @importFrom mvtnorm pmvnorm -## usethis namespace: end - -#' @title Smcmc class -#' -#' @description Smcmc class for simulated data using Markov chain Monte Carlo -#' -#' @name Smcmc -#' @aliases Smcmc as.Smcmc as.Smcmc.default is.mcmc -#' @usage Smcmc(data, batch.size = TRUE, stacked = TRUE, varnames = colnames(data)) -#' @param data : a list of MCMC output matrices each with `nsim` rows and `p` columns -#' @param batch.size : logical argument, if true, calculates the batch size appropriate for this Markov chain. Setting to TRUE saves time in future steps. -#' @param stacked : recommended to be `TRUE`. logical argument, if true, stores a carefully stacked version of the MCMC output for use later. -#' @param varnames : a character string equal to the number of columns in \code{data} -#' -#' @return an Smcmc class object -#' @examples -#' # Producing Markov chain -#' chain <- matrix(0, nrow = 1e3, ncol = 1) -#' chain[1,] <- 0 -#' err <- rnorm(1e3) -#' for(i in 2:1e3) -#' { -#' chain[i,] <- .3*chain[i-1,] + err[i] -#' } -#' smcmc.obj <- Smcmc(chain) -#' @export -"Smcmc" <- function(data, - batch.size = TRUE, - stacked = TRUE, - varnames = colnames(data)) # make Smcmc object -{ - if(missing(data)) - stop("Data must be provided.") - - if(!is.list(data)) - data <- list(data) - - nsim <- dim(data[[1]])[1] - - if(stacked == TRUE) - { - foo <- chain_stacker(data) - stacked.chain <- foo$stacked.data - - if(batch.size) - { - size <- foo$b.size - }else{ - size <- NULL - } - } - - out <- list( chains = data, - stacked = stacked.chain, - b.size = size, - nsim = nsim, - varnames = varnames ) - - class(out) <- "Smcmc" - return(out) -} - -"is.Smcmc" <- function (x) -{ - if (inherits(x, "Smcmc")) - return(TRUE) - return(FALSE) -} - -#' @export -"as.Smcmc" <- function (x, ...) - UseMethod("as.Smcmc") - -#' @export -"as.Smcmc.default" <- function (x, ...) - if (is.Smcmc(x)) x else Smcmc(x) - - - - -#' @title Plot Smcmc -#' -#' @description Density plots with simultaenous error bars around means and quantiles -#' for MCMC data. The error bars account for the correlated nature of the process. -#' -#' -#' @name plot.Smcmc -#' @usage \method{plot}{Smcmc}(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, iid = FALSE, -#' plot = TRUE, mean = TRUE, border = NA, mean.col = 'plum4', -#' quan.col = 'lightsteelblue3',rug = TRUE, opaq = 0.7, -#' auto.layout = TRUE, ask = dev.interactive(),...) -#' @param x : a `Smcmc' class object -#' @param Q : vector of quantiles -#' @param alpha : confidence level of simultaneous confidence intervals -#' @param thresh : numeric typically less than .005 for the accuracy of the simulteaneous procedure -#' @param iid : logical argument for constructing density plot for iid samples. Defaults to \code{FALSE} -#' @param plot : logical argument for is plots are to be returned -#' @param mean : logical argument whether the mean is to be plotted -#' @param border : whether a border is required for the simultaneous confidence intervals -#' @param mean.col : color for the mean confidence interval -#' @param quan.col : color for the quantile confidence intervals -#' @param rug : logical indicating whether a rug plot is desired -#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param auto.layout : logical argument for an automatic layout of plots -#' @param ask : activating interactive plots -#' @param ... : arguments passed on to the \code{density} plot in base R -#' @return returns a plot of the univariate density estimates with simultaneous -#' confidence intervals wherever asked. If \code{plot == FALSE} a list of -#' estimates and simultaneous confidence intervals. -#' @examples -#' # Producing Markov chain -#' chain <- matrix(0, ncol = 1, nrow = 1e3) -#' chain[1,] <- 0 -#' err <- rnorm(1e3) -#' for(i in 2:1e3) -#' { -#' chain[i,] <- .3*chain[i-1,] + err[i] -#' } -#' chain <- Smcmc(list(chain)) -#' plot(chain) -#' -#' @references -#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -#' “Assessing and Visualizing Simultaneous Simulation Error”, -#' Journal of Computational and Graphical Statistics, 2020. -#' -#' @export -"plot.Smcmc" <- function(x, - Q = c(0.1, 0.9), - alpha = 0.05, - thresh = 0.001, - iid = FALSE, - plot = TRUE, - mean = TRUE, - border = NA, - mean.col = 'plum4', - quan.col = 'lightsteelblue3', - rug = TRUE, - opaq = 0.7, - auto.layout = TRUE, - ask = dev.interactive(), ...) -{ - - x <- as.Smcmc(x) - out <- getCI(x, Q, alpha, thresh = thresh, iid = iid, mean = mean) - dat <- x$stacked - if(plot == TRUE) - { - plot.CIs(x, dimn = length(dat[1,]), CIs = out, bord = border, - mean.color = adjustcolor(mean.col, alpha.f = opaq), - quan.color = adjustcolor(quan.col, alpha.f = opaq), - mean = mean, auto.layout = auto.layout, rug = rug, - ask = ask)# , ...) - } - invisible(out) -} - - - diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/R/export.R b/SimTools.Rcheck/00_pkg_src/SimTools/R/export.R deleted file mode 100644 index 69ee740..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/R/export.R +++ /dev/null @@ -1,296 +0,0 @@ -#' @title Add simultaneous confidence interval to existing plot. -#' -#' @description Adds simultaneous confidence intervals for quantiles and means to an existing plot. -#' -#' @name addCI -#' @aliases addCI -#' @usage addCI(x, CIs, component = 1, bord = NA, mean = TRUE, mean.color = 'plum4', -#' quan.color = 'lightsteelblue3', opaq = 0.7, ...) -#' @param x : a `Smcmc' class object -#' @param CIs : the output from the `getCI` function -#' @param component : numeric indicating which component to draw the confidence intervals for -#' @param bord : logical for whether a border is desired around the confidence intervals -#' @param mean : logical argument whether the mean is to be plotted -#' @param mean.color : color for the mean confidence interval -#' @param quan.color : color for the quantile confidence intervals -#' @param opaq : opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque. -#' @param ... : arguments passed on to the boundaries of the confidence intervals in `segments` -#' @return adds segments for confidence intervals into an already existing plot environment -#' -#' @examples -#' chain <- matrix(0, ncol = 1, nrow = 1e3) -#' chain[1,] <- 0 -#' err <- rnorm(1e3) -#' for(i in 2:1e3) -#' { -#' chain[i,] <- .3*chain[i-1,] + err[i] -#' } -#' chain <- Smcmc(list(chain)) -#' plot(density(chain$stacked[,1])) -#' CIs <- getCI(chain) -#' addCI(chain, CIs, component = 1) -#' @export -addCI <- function(x, - CIs, - component = 1, - bord = NA, - mean = TRUE, - mean.color = 'plum4', - quan.color = 'lightsteelblue3', - opaq = 0.7, ...) -{ - if(class(x) == "Smcmc") obj <- ts(x$stacked[, component]) - if(class(x) == "Siid") obj <- ts(x$data[, component]) - mean.color = adjustcolor(mean.color, alpha.f = opaq) - quan.color = adjustcolor(quan.color, alpha.f = opaq) - mn <- CIs$mean.est[component] - quans <- CIs$xi.q[ , component] - mcil = CIs$lower.ci.mean[component] - mciu = CIs$upper.ci.mean[component] - qcil = CIs$lower.ci.mat[, component] - qciu = CIs$upper.ci.mat[, component] - if(mean){ - dum1 <- density(obj, from = mcil, to = mciu) - polygon(c(mcil, dum1$x, mciu), c(0, dum1$y, 0), col = mean.color, border = bord ) - } - for(j in 1:length(quans)) - { - dum1 <- density(obj, from = qcil[j], to = qciu[j]) - polygon(c(qcil[j], dum1$x, qciu[j]), c(0, dum1$y, 0), col = quan.color, border = bord) - } - if(mean){ - segments(mn,0,mn, density(obj, from = mn, to = mn, n = 1 )$y,...) - } - for(j in 1:length(quans)) - { - segments(quans[j],0,quans[j], density(obj, from = quans[j], to = quans[j], n = 1 )$y,...) - } -} - - -#' @title Calculates simultaneous confidence intervals. -#' -#' @description Calculates simultaneous confidence intervals for means and -#' quantiles as indicated for the desired MCMC output -#' -#' @name getCI -#' @aliases getCI -#' @usage getCI(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, iid = FALSE, -#' mean = TRUE) -#' @param x : a `Smcmc' class object -#' @param Q : vector of quantiles -#' @param alpha : confidence levels of the simulatenous intervals -#' @param thresh : threshold for the optimization methodology that calculates the simultaneous CIs -#' @param iid : logical argument for constructing density plot for iid samples. Defaults to \code{FALSE} -#' @param mean : logical indicating whether mean is to be plotted -#' @return adds segments for confidence intervals into an already existing plot environment -#' -#' @examples -#' chain <- matrix(0, ncol = 1, nrow = 1e3) -#' chain[1,] <- 0 -#' err <- rnorm(1e3) -#' for(i in 2:1e3) -#' { -#' chain[i,] <- .3*chain[i-1,] + err[i] -#' } -#' chain <- Smcmc(list(chain)) -#' plot(density(chain$stacked[,1])) -#' CIs <- getCI(chain) -#' addCI(chain, CIs, component = 1) -#' -#' @references -#' Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -#' “Assessing and Visualizing Simultaneous Simulation Error”, -#' Journal of Computational and Graphical Statistics, 2020. -#' -#' @export -getCI <- function(x, - Q = c(0.1, 0.9), - alpha = 0.05, - thresh = 0.001, - iid = FALSE, - mean = TRUE) -{ - - if(class(x) == "Smcmc") - { - if(is.null(x$size)) - b.size <- batchSize(x$stacked) # error here, fix this - else b.size <- x$size - - x <- x$stacked - }else{ - if(class(x) == "Siid") - { - b.size <- 1 - x <- x$data - } - } - mq <- length(Q) - n <- dim(x)[1] - - # p1 is the dimension of g(x) - # p2 is defined this because p1+p2 will ncols in lambda and sigma - # v is the vector of all means and quantiles to be estimated - p1 <- length(x[1,]) - p2 <- mq*length(x[1,]) - theta.hat <- colMeans(x) #g bar - xi.q <- apply(x, 2, quantile, Q) - xi.q <- as.matrix(xi.q) - if(mq==1) xi.q <- t(xi.q) - #phi is the vector of all quantiles - phi <- rep(0, p2) - for(i in 1:mq) - { - phi[((i-1)*(p2/mq) + 1):(i*(p2/mq))] = xi.q[i,] - } - - fs <- rep(0, p2) - for(j in 1:mq) - { - for(i in 1:(p2/mq)) - { - fs[(j-1)*(p2/mq) + i] <- density(x[, i], from = xi.q[j, i], to = xi.q[j, i], n = 1 )$y - } - } - - I.flat <- rep(1, p1) - - #since p2 was m*dim(h(x)) - lower.ci.mat <- matrix(0, nrow = mq, ncol = p2/mq) - upper.ci.mat <- matrix(0, nrow = mq, ncol = p2/mq) - indis <- matrix(0,nrow = n,ncol = p2) - for(i in 1:mq) - { - - indi <- (apply(x, 1, Indicator, xi.q[i,])) - if(p2 > 1) - { - indi <- t(indi) - } - indis[,((i-1)*(p2/mq) + 1):(i*(p2/mq))] <- indi - } - if(mean == FALSE) Y <- indis else Y <- cbind(x, indis) - - if(iid == FALSE)sigma.mat <- mcse.multi(Y, size = b.size)$cov else sigma.mat <- cov(Y) - - if(mean == FALSE) lambda <- 1/fs else (lambda <- 1/c(I.flat, fs)) - - ci.sigma.mat <- (t(t(sigma.mat)*lambda))*lambda - p <- p1 + p2 - if(mean == FALSE) p = p2 - - z1 <- qnorm(1 - alpha/2) - z2 <- qnorm(1 - alpha/(2*p)) - foo1 <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - foo2 <- CIz(z2, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - if(mean == FALSE) v <- phi else v <- c(theta.hat, phi) - - count <- 0 - prob1 <- pmvnorm(lower = foo1$lower.ci, upper = foo1$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] - prob2 <- pmvnorm(lower = foo2$lower.ci, upper = foo2$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] - - while(prob2 - prob1 > thresh) - { - count <- count + 1 - z.star <- (z1 + z2)/2 - foo.star <- CIz(z.star, p1, p2, theta.hat, phi, ci.sigma.mat, n, mean) - prob.star <- pmvnorm(lower = foo.star$lower.ci, upper = foo.star$upper.ci, mean = v, sigma = (ci.sigma.mat/n))[1] - if(prob.star > 1- alpha) - { - z2 <- z.star - prob2 <- prob.star - }else - { - z1 <- z.star - prob1 <- prob.star - } - if(abs(prob1 - (1 - alpha)) < thresh) - { - temp <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - break - } - } - temp <- CIz(z1, p1, p2, theta.hat, phi,ci.sigma.mat, n, mean) - - for(i in 1:mq) - { - if(mean == FALSE) - { - lower.ci.mat[i, ] <- temp$lower.ci[((i-1)*(p2/mq)+1):(i*(p2/mq) )] - upper.ci.mat[i, ] <- temp$upper.ci[((i-1)*(p2/mq) +1):(i*(p2/mq) )] - } - else{ - lower.ci.mat[i, ] <- temp$lower.ci[((i-1)*(p2/mq) + p1 + 1):(i*(p2/mq) + p1)] - upper.ci.mat[i, ] <- temp$upper.ci[((i-1)*(p2/mq) + p1 + 1):(i*(p2/mq) + p1)] - } - } - - row.names(lower.ci.mat) <- Q - row.names(upper.ci.mat) <- Q - if(mean) - { - lower.mean <- temp$lower.ci[1:p1] - upper.mean <- temp$upper.ci[1:p1] - - foo3 <- list("lower.ci.mean" = lower.mean, "upper.ci.mean" = upper.mean, "lower.ci.mat" = lower.ci.mat, "upper.ci.mat" = upper.ci.mat, "mean.est" = theta.hat, "xi.q" = xi.q) - } else foo3 <- list("lower.ci.mat" = lower.ci.mat, "upper.ci.mat" = upper.ci.mat, "mean.est" = theta.hat, "xi.q" = xi.q) - - return(foo3) - -} -##### - - - -#' @title Add simultaneous confidence interval to existing boxplot -#' -#' @description Adds simultaneous confidence intervals for quantiles to an existing boxplot. -#' -#' @name boxCI -#' @aliases boxCI -#' @usage boxCI(x, CI, component = c(1), dimn = 1, -#' quan.color = 'lightsteelblue3', horizontal = FALSE) -#' @param x : a `Smcmc' class object -#' @param CI : the output from the `getCI` function with `iid = TRUE` -#' @param component : vector indicating which components to draw the confidence intervals for -#' @param dimn : numeric for how many components are being plotted -#' @param quan.color : color for the quantile confidence intervals -#' @param horizontal : logical for whether boxplots are horizontal -#' @return adds segments for confidence intervals into an already existing plot environment -#' -#' @examples -#' output <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -#' -#' @export -boxCI <- function(x, - CI, - component = c(1), - dimn = 1, - quan.color = 'lightsteelblue3', - horizontal = FALSE) -{ - quans = CI$xi.q - mn = CI$mean.est - quansi <- quans[, component] - qcil = CI$lower.ci.mat[, component] - qciu = CI$upper.ci.mat[, component] - i <- component - for(j in 1:length(quansi)) - { - if(horizontal==TRUE) { - polygon(c(qcil[j],qcil[j],qciu[j],qciu[j]), c(i-(0.2*min(dimn,2)),i+(0.2*min(dimn,2)),i+(0.2*min(dimn,2)), i-(0.2*min(dimn,2))), col = quan.color, border = FALSE) - }else { - polygon(c(i-(0.2*min(dimn,2)),i+(0.2*min(dimn,2)),i+(0.2*min(dimn,2)), i-(0.2*min(dimn,2))), c(qcil[j],qcil[j],qciu[j],qciu[j]), col = quan.color, border = FALSE) - } - } - for(j in 1:length(quansi)) - { - if(horizontal==TRUE) { - segments(quansi[j],i-(0.2*min(dimn,2)), quansi[j], i+(0.2*min(dimn,2))) - }else { - segments(i-(0.2*min(dimn,2)), quansi[j], i+(0.2*min(dimn,2)), quansi[j]) - } - - } -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/R/supp.R b/SimTools.Rcheck/00_pkg_src/SimTools/R/supp.R deleted file mode 100644 index f4da5a1..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/R/supp.R +++ /dev/null @@ -1,207 +0,0 @@ -## For simultaneous confidence intervals -Indicator <- function(x, ...) -{ - return(as.numeric(x > ... )) -} - -#since our goal is to optimize z, this function returns the Confidence interval -#for a particular z - -CIz <- function(z, p1 , p2, theta.hat, phi, ci.sigma.mat, n, mean = TRUE) -{ - se_ests <- sqrt(diag(ci.sigma.mat)/n) - - if (mean == FALSE) - { - lower.ci.p2 <- phi - z * se_ests - upper.ci.p2 <- phi + z * se_ests - return (list("lower.ci" = lower.ci.p2, "upper.ci" = upper.ci.p2)) - } - p <- p1 + p2 - - lower.ci.p1 <- theta.hat - z * se_ests[1:p1] - upper.ci.p1 <- theta.hat + z * se_ests[1:p1] - lower.ci.p2 <- phi - z * se_ests[(p1+1):p] - upper.ci.p2 <- phi + z * se_ests[(p1+1):p] - - return (list("lower.ci" = c(lower.ci.p1, lower.ci.p2), "upper.ci" = c(upper.ci.p1, upper.ci.p2))) -} - -"set.mfrow" <-function (Nparms = 1) -{ - ## Set up dimensions of graphics window: - ## 1 x 1 if Nparms = 1 - ## 1 X 2 if Nparms = 2 - ## 2 X 2 if Nparms = 3 or 4 - ## 3 X 2 if Nparmss = 5 or 6 or 10 - 12 - ## 3 X 3 if Nparms = 7 - 9 or >= 13 - ## One plot per variable - mfrow <- switch(min(Nparms,13), - c(1,1), - c(1,2), - c(2,2), - c(2,2), - c(3,2), - c(3,2), - c(3,3), - c(3,3), - c(3,3), - c(3,2), - c(3,2), - c(3,2), - c(3,3)) - return(mfrow) -} - - - -plot.CIs <- function(x, - dimn, - CIs, - bord = NULL, - mean.color, - quan.color, - rug, - mean = TRUE, - auto.layout, - ask, ...) -{ - - pars <- NULL - if(class(x) == "Smcmc") - { - if(is.null(x$varnames)) - { - varnames <- as.character(1:dim(x$stacked)[2]) - }else{ - varnames <- x$varnames - } - data <- x$stacked - } else{ - if(class(x) == "Siid") - { - if(is.null(x$varnames)) - { - varnames <- as.character(1:dim(x$data)[2]) - }else{ - varnames <- x$varnames - } - data <- x$data - } - } - - if(dimn < 4) { - par(mfrow = c(dimn,1)) - for(i in 1:dimn) - { - beta = ts(data[, i]) - main1 = paste("Density of ",varnames[i]) - plot(density(beta), main = main1, ...) - if(rug == TRUE) rug(beta, ticksize = 0.03, side=1, lwd=0.5) - addCI(x, CIs, component = i, bord = bord, - mean.color = mean.color, quan.color = quan.color, - mean = mean, ...) - } - } - else if(dimn == 4) { - par(mfrow = c(2,2)) - for(i in 1:4) - { - beta = ts(data[, i]) - main1 = paste("Density of ",varnames[i]) - plot(density(beta), main = main1, ...) - if(rug == TRUE) rug(beta, ticksize=0.03, side=1, lwd=0.5) - addCI(x, CIs, component = i, bord = bord, - mean.color = mean.color, quan.color = quan.color, - mean = mean, ...) - } - }else if(dimn == 5||dimn == 6){ - par(mfrow = c(3,2)) - for(i in 1:dimn) - { - beta = ts(data[, i]) - main1 = paste("Density of ",varnames[i]) - plot(density(beta), main = main1, ...) - if(rug == TRUE) rug(beta, ticksize=0.03, side=1, lwd=0.5) - addCI(x, CIs,component = i, bord = bord, - mean.color = mean.color, quan.color = quan.color, - mean = mean, ...) - } - }else { - on.exit(par(pars)) - - if (auto.layout) { - mfrow <- set.mfrow(Nparms = 6) - pars <- par(mfrow = mfrow) - } - - for(i in 1:dimn) - { - beta = ts(data[, i]) - - main1 = paste("Density of ",varnames[i]) - plot(density(beta), main = main1, ...) - if(rug == TRUE) rug(beta, ticksize=0.03, side=1, lwd=0.5) - main1 = paste("Density of ",varnames[i]) - addCI(x, CIs, component = i, bord = bord, - mean.color = mean.color, quan.color = quan.color, - mean = mean, ...) - if (i == 1) - pars <- c(pars, par(ask=ask)) - } - } - on.exit(par(pars, ask=FALSE,mfrow=c(1,1))) - -} - - - -## For boxplots -plot.boxx <- function(x, dimn, CIs, quan.color, range, width, varwidth, notch, outline, plot, border, - col, ann, horizontal, add,...) -{ - if(is.null(x$varnames)) - { - varnames <- as.character(1:dim(x$data)[2]) - }else{ - varnames <- x$varnames - } - boxplot.matrix(x$data, ..., range = range, width = width, varwidth = varwidth, notch = notch, outline = outline, - names=varnames, plot = plot, border = border, col = col, ann = ann, horizontal = horizontal, add = add) - for(i in 1:dimn) { - boxCI(x, CI = CIs, component = i,dimn = dimn, - quan.color = quan.color, horizontal = horizontal) - } -} - -chain_stacker <- function(x) { - m <- length(x) - - if(class(x) != "list") - stop("must be list of chains") - - if(is.null(x)) - stop("Chains are null") - - n <- as.integer(nrow(x[[1]])) - p <- as.integer(ncol(x[[1]])) - - b <- 0 - for(i in 1:m) { - b <- b + batchSize(x[[i]]) - } - b.final <- floor(b/m) - a <- floor(n/b.final) - ab <- a*b.final - trash <- n-ab - big.chain <- matrix(0,ncol = p, nrow = ab*m) - if(ab != n) - { - for (i in 1:m) { - big.chain[((i-1)*ab+1):(i*ab),] <- x[[i]][-(1:trash),] - } - }else{ - big.chain <- Reduce("rbind", x) - } - return(list("b.size" = b.final, "stacked.data" = big.chain)) -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/README.md b/SimTools.Rcheck/00_pkg_src/SimTools/README.md deleted file mode 100644 index f2cce11..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# SimTools: Variability assessment for simulation methods in R - -Leadership: -[Dootika Vats](http://dvats.github.io/), [James Flegal](https://faculty.ucr.edu/~jflegal/), [Galin Jones](http://users.stat.umn.edu/~galin/) - -Contributors: -Gunjan Jalori - -The development of this package has begun. Updates will be described in this README. For communication regarding issues in the code and other suggestions, we can try and use the GitHub Issues interface. - - -**Run**: `runme.R` - - ---------------------- - December 7, 2020 - -`Siid` class created. This corresponds to "IID simulation objects". The `boxplot` and `plot` commands work directly on this and produces boxplots and density plots. - ---------------------- - December 4, 2020 - -`Smcmc` class created. This corresponds to "MCMC simulation objects". The `plot` command works directly on this and produces density plots with the desired quantiles and means indicated. - ---------------------- - - diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/SimTools_1.0-0.tar.gz b/SimTools.Rcheck/00_pkg_src/SimTools/SimTools_1.0-0.tar.gz deleted file mode 100644 index 501b88d..0000000 Binary files a/SimTools.Rcheck/00_pkg_src/SimTools/SimTools_1.0-0.tar.gz and /dev/null differ diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/Siid.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/Siid.Rd deleted file mode 100644 index 20f4bed..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/Siid.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/Siidclass.R -\name{Siid} -\alias{Siid} -\alias{as.Siid} -\alias{as.Siid.default} -\alias{is.iid} -\title{Siid class} -\usage{ -Siid(data, varnames = colnames(data)) -} -\arguments{ -\item{data}{: an iid output matrix with nsim rows and p columns} - -\item{varnames}{: a character string equal to the number of columns in \code{data}} -} -\value{ -an Siid class object -} -\description{ -Class for independent and identically distributed (iid) samples -} -\examples{ -# Generating iid data -chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -siid.obj <- Siid(chain) - -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/Smcmc.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/Smcmc.Rd deleted file mode 100644 index b50f8ab..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/Smcmc.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/Smcmcclass.R -\name{Smcmc} -\alias{Smcmc} -\alias{as.Smcmc} -\alias{as.Smcmc.default} -\alias{is.mcmc} -\title{Smcmc class} -\usage{ -Smcmc(data, batch.size = TRUE, stacked = TRUE, varnames = colnames(data)) -} -\arguments{ -\item{data}{: a list of MCMC output matrices each with `nsim` rows and `p` columns} - -\item{batch.size}{: logical argument, if true, calculates the batch size appropriate for this Markov chain. Setting to TRUE saves time in future steps.} - -\item{stacked}{: recommended to be `TRUE`. logical argument, if true, stores a carefully stacked version of the MCMC output for use later.} - -\item{varnames}{: a character string equal to the number of columns in \code{data}} -} -\value{ -an Smcmc class object -} -\description{ -Smcmc class for simulated data using Markov chain Monte Carlo -} -\examples{ -# Producing Markov chain -chain <- matrix(0, nrow = 1e3, ncol = 1) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -smcmc.obj <- Smcmc(chain) -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/addCI.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/addCI.Rd deleted file mode 100644 index 25744b7..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/addCI.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/export.R -\name{addCI} -\alias{addCI} -\title{Add simultaneous confidence interval to existing plot.} -\usage{ -addCI(x, CIs, component = 1, bord = NA, mean = TRUE, mean.color = 'plum4', - quan.color = 'lightsteelblue3', opaq = 0.7, ...) -} -\arguments{ -\item{x}{: a `Smcmc' class object} - -\item{CIs}{: the output from the `getCI` function} - -\item{component}{: numeric indicating which component to draw the confidence intervals for} - -\item{bord}{: logical for whether a border is desired around the confidence intervals} - -\item{mean}{: logical argument whether the mean is to be plotted} - -\item{mean.color}{: color for the mean confidence interval} - -\item{quan.color}{: color for the quantile confidence intervals} - -\item{opaq}{: opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque.} - -\item{...}{: arguments passed on to the boundaries of the confidence intervals in `segments`} -} -\value{ -adds segments for confidence intervals into an already existing plot environment -} -\description{ -Adds simultaneous confidence intervals for quantiles and means to an existing plot. -} -\examples{ -chain <- matrix(0, ncol = 1, nrow = 1e3) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -chain <- Smcmc(list(chain)) -plot(density(chain$stacked[,1])) -CIs <- getCI(chain) -addCI(chain, CIs, component = 1) -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/boxCI.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/boxCI.Rd deleted file mode 100644 index 496663b..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/boxCI.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/export.R -\name{boxCI} -\alias{boxCI} -\title{Add simultaneous confidence interval to existing boxplot} -\usage{ -boxCI(x, CI, component = c(1), dimn = 1, - quan.color = 'lightsteelblue3', horizontal = FALSE) -} -\arguments{ -\item{x}{: a `Smcmc' class object} - -\item{CI}{: the output from the `getCI` function with `iid = TRUE`} - -\item{component}{: vector indicating which components to draw the confidence intervals for} - -\item{dimn}{: numeric for how many components are being plotted} - -\item{quan.color}{: color for the quantile confidence intervals} - -\item{horizontal}{: logical for whether boxplots are horizontal} -} -\value{ -adds segments for confidence intervals into an already existing plot environment -} -\description{ -Adds simultaneous confidence intervals for quantiles to an existing boxplot. -} -\examples{ -output <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) - -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/boxplot.Siid.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/boxplot.Siid.Rd deleted file mode 100644 index 8e1307b..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/boxplot.Siid.Rd +++ /dev/null @@ -1,64 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/Siidclass.R -\name{boxplot.Siid} -\alias{boxplot.Siid} -\title{Boxplot for Siid} -\usage{ -\method{boxplot}{Siid}(x, ..., alpha = 0.05, thresh = 0.001, - quan.col = 'lightsteelblue3', opaq = .6, range = 1.5, - width = NULL, varwidth = FALSE, outline = TRUE, plot = TRUE, - border = par("fg"), col = 'white', ann = !add, - horizontal = FALSE, add = FALSE) -} -\arguments{ -\item{x}{: a `Siid' class object} - -\item{...}{: arguments sent to boxplot} - -\item{alpha}{: confidence level of simultaneous confidence intervals} - -\item{thresh}{: numeric typically less than .005 for the accuracy of the simulteaneous procedure} - -\item{quan.col}{: color for the quantile confidence intervals} - -\item{opaq}{: opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque.} - -\item{range}{: as defined for base \code{boxplot}} - -\item{width}{: as defined for base \code{boxplot}} - -\item{varwidth}{: as defined for base \code{boxplot}} - -\item{outline}{: as defined for base \code{boxplot}} - -\item{plot}{: logical indicating whether the plot is to be constructed} - -\item{border}{: as defined for base \code{boxplot}} - -\item{col}{: as defined for base \code{boxplot}} - -\item{ann}{: as defined for base \code{boxplot}} - -\item{horizontal}{: as defined for base \code{boxplot}} - -\item{add}{: as defined for base \code{boxplot}} -} -\value{ -returns the base \code{boxplot} with simultaneous confidence intervals around - all quantiles -} -\description{ -Boxplots with simultaenous error bars around all quantiles for iid data. -} -\examples{ -# Generating iid data -chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -siid.obj <- Siid(chain) -boxplot(siid.obj) - -} -\references{ -Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -“Assessing and Visualizing Simultaneous Simulation Error”, -Journal of Computational and Graphical Statistics, 2020. -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/getCI.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/getCI.Rd deleted file mode 100644 index a8ee1e0..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/getCI.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/export.R -\name{getCI} -\alias{getCI} -\title{Calculates simultaneous confidence intervals.} -\usage{ -getCI(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, iid = FALSE, - mean = TRUE) -} -\arguments{ -\item{x}{: a `Smcmc' class object} - -\item{Q}{: vector of quantiles} - -\item{alpha}{: confidence levels of the simulatenous intervals} - -\item{thresh}{: threshold for the optimization methodology that calculates the simultaneous CIs} - -\item{iid}{: logical argument for constructing density plot for iid samples. Defaults to \code{FALSE}} - -\item{mean}{: logical indicating whether mean is to be plotted} -} -\value{ -adds segments for confidence intervals into an already existing plot environment -} -\description{ -Calculates simultaneous confidence intervals for means and - quantiles as indicated for the desired MCMC output -} -\examples{ -chain <- matrix(0, ncol = 1, nrow = 1e3) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -chain <- Smcmc(list(chain)) -plot(density(chain$stacked[,1])) -CIs <- getCI(chain) -addCI(chain, CIs, component = 1) - -} -\references{ -Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -“Assessing and Visualizing Simultaneous Simulation Error”, -Journal of Computational and Graphical Statistics, 2020. -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/man/plot.Siid.Rd b/SimTools.Rcheck/00_pkg_src/SimTools/man/plot.Siid.Rd deleted file mode 100644 index 003ead4..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/man/plot.Siid.Rd +++ /dev/null @@ -1,62 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/Siidclass.R -\name{plot.Siid} -\alias{plot.Siid} -\title{Plot Siid} -\usage{ -\method{plot}{Siid}(x, Q = c(0.1, 0.9), alpha = 0.05, thresh = 0.001, - rug = TRUE, plot = TRUE, mean = TRUE, border = NA, - mean.col = 'plum4', quan.col = 'lightsteelblue3', - opaq = 0.7, auto.layout = TRUE, - ask = dev.interactive(), ...) -} -\arguments{ -\item{x}{: a `Siid' class object} - -\item{Q}{: vector of quantiles} - -\item{alpha}{: confidence level of simultaneous confidence intervals} - -\item{thresh}{: numeric typically less than .005 for the accuracy of the simulteaneous procedure} - -\item{rug}{: logical indicating whether a rug plot is desired} - -\item{plot}{: logical argument for is plots are to be returned} - -\item{mean}{: logical argument whether the mean is to be plotted} - -\item{border}{: whether a border is required for the simultaneous confidence intervals} - -\item{mean.col}{: color for the mean confidence interval} - -\item{quan.col}{: color for the quantile confidence intervals} - -\item{opaq}{: opacity of \code{mean.col} and \code{quan.col}. A value of 0 is transparent and 1 is completely opaque.} - -\item{auto.layout}{: logical argument for an automatic layout of plots} - -\item{ask}{: activating interactive plots} - -\item{...}{: arguments passed on to the \code{density} plot in base R} -} -\value{ -returns a plot of the univariate density estimates with simultaneous - confidence intervals wherever asked. If \code{plot == FALSE} a list of - estimates and simultaneous confidence intervals. -} -\description{ -Density plots with simultaenous error bars around means and quantiles - for iid data. -} -\examples{ -# Generating iid data -chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -siid.obj <- Siid(chain) -plot(siid.obj) - -} -\references{ -Robertson, N., Flegal, J. M., Vats, D., and Jones, G. L., -“Assessing and Visualizing Simultaneous Simulation Error”, -Journal of Computational and Graphical Statistics, 2020. -} diff --git a/SimTools.Rcheck/00_pkg_src/SimTools/runme.R b/SimTools.Rcheck/00_pkg_src/SimTools/runme.R deleted file mode 100644 index 6dc5f0c..0000000 --- a/SimTools.Rcheck/00_pkg_src/SimTools/runme.R +++ /dev/null @@ -1,170 +0,0 @@ -########################################## -## This document is a running file -## in place of a vignette for now. -## -## We run an MCMC example and an IID -## Monte Carlo example and demonstrate the -## plots that are available. -########################################## -set.seed(1) - - -############################ -# Smcmc class -############################ - -# Making a Markov chain -# RW MH for a standard normal multivariate target -MakeChain <- function(p = 4, n = 1e3, h = .5) -{ - chain <- matrix(0, nrow = n,ncol = p) - - for (i in 2:n) - { - prop <- chain[i-1, ] + rnorm(p, mean = 0, sd = h) - log.ratio <- sum(dnorm(prop, log = TRUE) - dnorm(chain[i-1, ], log = TRUE)) - - if(log(runif(1)) < log.ratio) - { - chain[i, ] <- prop - } - else { - chain[i, ] <- chain[i - 1, ] - } - } - return(chain) -} - -# Make chain -chain <- MakeChain() - - -# install SimTools package -# download the tarball from GitHub and then -# on the terminal run: R CMD INSTALL SimTools_1.0-0.tar.gz -library(SimTools) - - -# First, we tell the package that chain is an MCMC process -# using the class `Smcmc`. A few things, setting: -# batch.size = TRUE calculates the batch.size for this -# chain and uses it in the future, and not wasting -# time in the future -# varnames = colnames(chain) by default - -out.one <- Smcmc(chain) - -# the chain is accessed via -head(out.one$chains[[1]]) - -# the batch size chosen -out.one$b.size - - -# the stacked chain stores a cleaned -# and "stacked" version of all chains -# it stacks multiple chains so that -# n = ab for all chain -head(out.one$stacked) - - -# Density plots are called by `plot` -# This is because plot(Smcmc object) calls an underlying -# plot.Smcmc function -plot(out.one) - -# rug plots can be removed -plot(out.one, rug = FALSE) - -# flexibility in this function -plot(out.one, Q = c(.05, .20)) # change quantiles -plot(out.one, mean = FALSE) # no mean - - - -### Multiple chains -# The package now supports multiple chain implementations - -chain1 <- MakeChain() -chain2 <- MakeChain() -chain3 <- MakeChain() - -out.three <- Smcmc(list(chain1, chain2, chain3)) -str(out.three) -# access list of chains by out.three$chains - -# calculated batch size is the average of -# individual chain batch sizes -out.three$b.size - -# dimension is typically not #3k \times 4 -dim(out.three$stacked) - -# plots the density from the stacked estimates -plot(out.three) - - -# plotting individual chain densities versus combined -# using the getCI and the addCI functions -# we can add appropriate simulateneous intervals -par(mfrow = c(2,2)) - -foo1 <- Smcmc(chain1) -plot(density(foo1$stacked[,1]), main = "Markov chain 1") -CIs <- getCI(foo1) -addCI(foo1, CIs, component = 1) - -foo2 <- Smcmc(chain2) -plot(density(foo2$stacked[,1]), main = "Markov chain 2") -CIs <- getCI(foo2) -addCI(foo2, CIs, component = 1) - -foo3 <- Smcmc(chain3) -plot(density(foo3$stacked[,1]), main = "Markov chain 3") -CIs <- getCI(foo3) -addCI(foo3, CIs, component = 1) - -plot(density(out.three$stacked[,1]), main = "Combined") -CIs <- getCI(out.three) -addCI(out.three, CIs, component = 1) - - -# Typically, we would expect people to work -# with the stacked chains. So separate plots -# for each component can be made - -# get CIs for each component -CIs <- getCI(out.three) - -for(i in 1:4) -{ - plot(density(out.three$stacked[,i]), main = paste("Component", i), lty = 2) - addCI(out.three, CIs, component = i) -} - - - -############################ -# Siid class -############################ -n <- 5e2 -p <- 5 -sim <- matrix(rnorm(n*p), ncol = p, nrow = n) - -out <- Siid(sim) # make into Siid object) -plot(out) # since Siid object, mcmcse is not used in variance estimation -boxplot(out) - - -# Picks up the column names if present -colnames(sim) <- paste("Comp", 1:5) -out <- Siid(sim) # make into Siid object) -plot(out) # since Siid object, mcmcse is not used in variance estimation -boxplot(out) - -# only first component -boxplot(sim[,1], col = "white") -boxCI(out, getCI(out, Q = c(.25, .5, .75), iid = TRUE), component = 1) -# need to change getCI so that there is an automatic Q option in it - - diff --git a/SimTools.Rcheck/00check.log b/SimTools.Rcheck/00check.log deleted file mode 100644 index f13d497..0000000 --- a/SimTools.Rcheck/00check.log +++ /dev/null @@ -1,62 +0,0 @@ -* using log directory ‘/Users/Dootika/Documents/GitHub/SimTools/SimTools.Rcheck’ -* using R version 4.0.2 (2020-06-22) -* using platform: x86_64-apple-darwin17.0 (64-bit) -* using session charset: UTF-8 -* using option ‘--as-cran’ -* checking for file ‘SimTools/DESCRIPTION’ ... OK -* this is package ‘SimTools’ version ‘1.0-0’ -* package encoding: UTF-8 -* checking CRAN incoming feasibility ... NOTE -Maintainer: ‘Dootika Vats ’ - -New submission -* checking package namespace information ... OK -* checking package dependencies ... OK -* checking if this is a source package ... OK -* checking if there is a namespace ... OK -* checking for executable files ... OK -* checking for hidden files and directories ... OK -* checking for portable file names ... OK -* checking for sufficient/correct file permissions ... OK -* checking serialization versions ... OK -* checking whether package ‘SimTools’ can be installed ... OK -* checking installed package size ... OK -* checking package directory ... OK -* checking for future file timestamps ... OK -* checking DESCRIPTION meta-information ... OK -* checking top-level files ... NOTE -Files ‘README.md’ or ‘NEWS.md’ cannot be checked without ‘pandoc’ being installed. -Non-standard files/directories found at top level: - ‘SimTools_1.0-0.tar.gz’ ‘runme.R’ -* checking for left-over files ... OK -* checking index information ... OK -* checking package subdirectories ... OK -* checking R files for non-ASCII characters ... OK -* checking R files for syntax errors ... OK -* checking whether the package can be loaded ... OK -* checking whether the package can be loaded with stated dependencies ... OK -* checking whether the package can be unloaded cleanly ... OK -* checking whether the namespace can be loaded with stated dependencies ... OK -* checking whether the namespace can be unloaded cleanly ... OK -* checking loading without being on the library search path ... OK -* checking use of S3 registration ... OK -* checking dependencies in R code ... OK -* checking S3 generic/method consistency ... OK -* checking replacement functions ... OK -* checking foreign function calls ... OK -* checking R code for possible problems ... OK -* checking Rd files ... OK -* checking Rd metadata ... OK -* checking Rd line widths ... OK -* checking Rd cross-references ... OK -* checking for missing documentation entries ... OK -* checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... OK -* checking Rd contents ... OK -* checking for unstated dependencies in examples ... OK -* checking examples ... OK -* checking PDF version of manual ... OK -* checking for non-standard things in the check directory ... OK -* checking for detritus in the temp directory ... OK -* DONE -Status: 2 NOTEs diff --git a/SimTools.Rcheck/00install.out b/SimTools.Rcheck/00install.out deleted file mode 100644 index 9a93be1..0000000 --- a/SimTools.Rcheck/00install.out +++ /dev/null @@ -1,11 +0,0 @@ -* installing *source* package ‘SimTools’ ... -** using staged installation -** R -** byte-compile and prepare package for lazy loading -** help -*** installing help indices -** building package indices -** testing if installed package can be loaded from temporary location -** testing if installed package can be loaded from final location -** testing if installed package keeps a record of temporary installation path -* DONE (SimTools) diff --git a/SimTools.Rcheck/R_check_bin/R b/SimTools.Rcheck/R_check_bin/R deleted file mode 100755 index 3e289bc..0000000 --- a/SimTools.Rcheck/R_check_bin/R +++ /dev/null @@ -1,2 +0,0 @@ -echo "'R' should not be used without a path -- see par. 1.6 of the manual" -exit 1 diff --git a/SimTools.Rcheck/R_check_bin/Rscript b/SimTools.Rcheck/R_check_bin/Rscript deleted file mode 100755 index 6fead74..0000000 --- a/SimTools.Rcheck/R_check_bin/Rscript +++ /dev/null @@ -1,2 +0,0 @@ -echo "'Rscript' should not be used without a path -- see par. 1.6 of the manual" -exit 1 diff --git a/SimTools.Rcheck/Rdlatex.log b/SimTools.Rcheck/Rdlatex.log deleted file mode 100644 index dcb516a..0000000 --- a/SimTools.Rcheck/Rdlatex.log +++ /dev/null @@ -1,546 +0,0 @@ -Hmm ... looks like a package - -This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex) - restricted \write18 enabled. -entering extended mode -LaTeX2e <2015/01/01> -Babel <3.9l> and hyphenation patterns for 79 languages loaded. - -(./Rd2.tex -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/book.cls -Document Class: book 2014/09/29 v1.4h Standard LaTeX document class -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/bk10.clo)) -(/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Rd.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ifthen.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/bm.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/alltt.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/verbatim.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/textcomp.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/times.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/zi4.sty -`inconsolata-zi4' v1.05, 2014/06/22 Text macros for Inconsolata (msharpe) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg) -(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty) -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)) - -Package hyperref Message: Driver (autodetected): hpdftex. - -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) - -Package hyperref Warning: Option `hyperindex' has already been used, -(hyperref) setting the option has no effect on input line 377. - - -Package hyperref Warning: Option `pagebackref' has already been used, -(hyperref) setting the option has no effect on input line 377. - -) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/makeidx.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.dfu))) -Writing index file Rd2.idx -No file Rd2.aux. -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1ptm.fd) -(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii -[Loading MPS to PDF converter (version 2006.09.02).] -) (/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/t1zi4.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1phv.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/ts1zi4.fd) [1{/usr/lo -cal/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [2] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [3] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [4] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [5] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [6] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [7] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -No file Rd2.ind. -[8] -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) - -Package rerunfilecheck Warning: File `Rd2.out' has changed. -(rerunfilecheck) Rerun to get outlines right -(rerunfilecheck) or use package `bookmark'. - - ){/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/base/8r.enc}{/usr/local/t -exlive/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-ts1.enc}{/usr/local/texli -ve/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc} -Output written on Rd2.pdf (8 pages, 80564 bytes). -Transcript written on Rd2.log. -This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex) - restricted \write18 enabled. -entering extended mode -LaTeX2e <2015/01/01> -Babel <3.9l> and hyphenation patterns for 79 languages loaded. - -(./Rd2.tex -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/book.cls -Document Class: book 2014/09/29 v1.4h Standard LaTeX document class -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/bk10.clo)) -(/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Rd.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ifthen.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/bm.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/alltt.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/verbatim.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/textcomp.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/times.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/zi4.sty -`inconsolata-zi4' v1.05, 2014/06/22 Text macros for Inconsolata (msharpe) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg) -(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty) -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)) - -Package hyperref Message: Driver (autodetected): hpdftex. - -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) - -Package hyperref Warning: Option `hyperindex' has already been used, -(hyperref) setting the option has no effect on input line 377. - - -Package hyperref Warning: Option `pagebackref' has already been used, -(hyperref) setting the option has no effect on input line 377. - -) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/makeidx.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.dfu))) -Writing index file Rd2.idx - -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1ptm.fd) -(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii -[Loading MPS to PDF converter (version 2006.09.02).] -) (/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/t1zi4.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1phv.fd) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.toc) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/ts1zi4.fd) [1{/usr/lo -cal/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [2] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [3] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [4] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [5] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [6] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [7] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -No file Rd2.ind. -[8] -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) ){/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/inconsola -ta/i4-ts1.enc}{/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/base/8r.enc}{ -/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc} -Output written on Rd2.pdf (8 pages, 81595 bytes). -Transcript written on Rd2.log. -This is makeindex, version 2.15 [TeX Live 2015] (kpathsea + Thai support). -Scanning input file Rd2.idx....done (12 entries accepted, 0 rejected). -Sorting entries....done (49 comparisons). -Generating output file Rd2.ind....done (32 lines written, 0 warnings). -Output written in Rd2.ind. -Transcript written in Rd2.ilg. -This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex) - restricted \write18 enabled. -entering extended mode -LaTeX2e <2015/01/01> -Babel <3.9l> and hyphenation patterns for 79 languages loaded. - -(./Rd2.tex -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/book.cls -Document Class: book 2014/09/29 v1.4h Standard LaTeX document class -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/bk10.clo)) -(/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Rd.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ifthen.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/bm.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/alltt.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/verbatim.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/textcomp.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/times.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/zi4.sty -`inconsolata-zi4' v1.05, 2014/06/22 Text macros for Inconsolata (msharpe) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg) -(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty) -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)) - -Package hyperref Message: Driver (autodetected): hpdftex. - -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) - -Package hyperref Warning: Option `hyperindex' has already been used, -(hyperref) setting the option has no effect on input line 377. - - -Package hyperref Warning: Option `pagebackref' has already been used, -(hyperref) setting the option has no effect on input line 377. - -) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/makeidx.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.dfu))) -Writing index file Rd2.idx - -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1ptm.fd) -(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii -[Loading MPS to PDF converter (version 2006.09.02).] -) (/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/t1zi4.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1phv.fd) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.toc) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/ts1zi4.fd) [1{/usr/lo -cal/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [2] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [3] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [4] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [5] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [6] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [7] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.ind [8] - -LaTeX Font Warning: Font shape `T1/zi4/m/it' undefined -(Font) using `T1/zi4/m/n' instead on input line 4. - -[9]) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) - -Package rerunfilecheck Warning: File `Rd2.out' has changed. -(rerunfilecheck) Rerun to get outlines right -(rerunfilecheck) or use package `bookmark'. - - -LaTeX Font Warning: Some font shapes were not available, defaults substituted. - - ){/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-ts1.enc}{/ -usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/base/8r.enc}{/usr/local/texli -ve/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc} -Output written on Rd2.pdf (9 pages, 82983 bytes). -Transcript written on Rd2.log. -This is makeindex, version 2.15 [TeX Live 2015] (kpathsea + Thai support). -Scanning input file Rd2.idx....done (12 entries accepted, 0 rejected). -Sorting entries....done (49 comparisons). -Generating output file Rd2.ind....done (32 lines written, 0 warnings). -Output written in Rd2.ind. -Transcript written in Rd2.ilg. -This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex) - restricted \write18 enabled. -entering extended mode -LaTeX2e <2015/01/01> -Babel <3.9l> and hyphenation patterns for 79 languages loaded. - -(./Rd2.tex -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/book.cls -Document Class: book 2014/09/29 v1.4h Standard LaTeX document class -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/bk10.clo)) -(/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Rd.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ifthen.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/bm.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/alltt.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/verbatim.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/textcomp.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/times.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/zi4.sty -`inconsolata-zi4' v1.05, 2014/06/22 Text macros for Inconsolata (msharpe) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg) -(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty) -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)) - -Package hyperref Message: Driver (autodetected): hpdftex. - -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) - -Package hyperref Warning: Option `hyperindex' has already been used, -(hyperref) setting the option has no effect on input line 377. - - -Package hyperref Warning: Option `pagebackref' has already been used, -(hyperref) setting the option has no effect on input line 377. - -) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/makeidx.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.dfu))) -Writing index file Rd2.idx - -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1ptm.fd) -(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii -[Loading MPS to PDF converter (version 2006.09.02).] -) (/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/t1zi4.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1phv.fd) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.toc) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/ts1zi4.fd) [1{/usr/lo -cal/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [2] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [3] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [4] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [5] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [6] [7] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [8] -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.ind [9] - -LaTeX Font Warning: Font shape `T1/zi4/m/it' undefined -(Font) using `T1/zi4/m/n' instead on input line 4. - -[10]) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) - -LaTeX Font Warning: Some font shapes were not available, defaults substituted. - - ){/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-ts1.enc}{/ -usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/base/8r.enc}{/usr/local/texli -ve/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc} -Output written on Rd2.pdf (10 pages, 83727 bytes). -Transcript written on Rd2.log. -This is makeindex, version 2.15 [TeX Live 2015] (kpathsea + Thai support). -Scanning input file Rd2.idx....done (12 entries accepted, 0 rejected). -Sorting entries....done (49 comparisons). -Generating output file Rd2.ind....done (32 lines written, 0 warnings). -Output written in Rd2.ind. -Transcript written in Rd2.ilg. -This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex) - restricted \write18 enabled. -entering extended mode -LaTeX2e <2015/01/01> -Babel <3.9l> and hyphenation patterns for 79 languages loaded. - -(./Rd2.tex -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/book.cls -Document Class: book 2014/09/29 v1.4h Standard LaTeX document class -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/bk10.clo)) -(/Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Rd.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ifthen.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/longtable.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/bm.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/alltt.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/tools/verbatim.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/url/url.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/textcomp.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/fontenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.def)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/times.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/zi4.sty -`inconsolata-zi4' v1.05, 2014/06/22 Text macros for Inconsolata (msharpe) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/color.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/color.cfg) -(/usr/local/texlive/2015/texmf-dist/tex/latex/pdftex-def/pdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/infwarerr.sty) -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty)) -(/usr/local/texlive/2015/texmf-dist/tex/generic/ifxetex/ifxetex.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/auxhook.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/kvoptions.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/pd1enc.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/hyperref.cfg)) - -Package hyperref Message: Driver (autodetected): hpdftex. - -(/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/hpdftex.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty)) - -Package hyperref Warning: Option `hyperindex' has already been used, -(hyperref) setting the option has no effect on input line 377. - - -Package hyperref Warning: Option `pagebackref' has already been used, -(hyperref) setting the option has no effect on input line 377. - -) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/makeidx.sty) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/inputenc.sty -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/t1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ot1enc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/omsenc.dfu) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1enc.dfu))) -Writing index file Rd2.idx - -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/ts1cmr.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1ptm.fd) -(/usr/local/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii -[Loading MPS to PDF converter (version 2006.09.02).] -) (/usr/local/texlive/2015/texmf-dist/tex/latex/hyperref/nameref.sty -(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.out) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/t1zi4.fd) -(/usr/local/texlive/2015/texmf-dist/tex/latex/psnfss/t1phv.fd) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.toc) (/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/inconsolata/ts1zi4.fd) [1{/usr/lo -cal/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [2] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [3] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [4] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [5] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [6] [7] -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) -(/usr/local/texlive/2015/texmf-dist/tex/latex/base/utf8.def) [8] -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.ind [9] - -LaTeX Font Warning: Font shape `T1/zi4/m/it' undefined -(Font) using `T1/zi4/m/n' instead on input line 4. - -[10]) -(/private/var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T/RtmpVBcQoS/Rd2pdf3500 -7b7b51b/Rd2.aux) - -LaTeX Font Warning: Some font shapes were not available, defaults substituted. - - ){/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-ts1.enc}{/ -usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/base/8r.enc}{/usr/local/texli -ve/2015/texmf-dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc} -Output written on Rd2.pdf (10 pages, 83778 bytes). -Transcript written on Rd2.log. -Saving output to ‘SimTools-manual.pdf’ ... -Done -You may want to clean up by 'rm -Rf /var/folders/6h/ckff_c490ml7_lmhj4xqv3lw0000gp/T//RtmpVBcQoS/Rd2pdf35007b7b51b' diff --git a/SimTools.Rcheck/SimTools-Ex.R b/SimTools.Rcheck/SimTools-Ex.R deleted file mode 100644 index 3ddc1ce..0000000 --- a/SimTools.Rcheck/SimTools-Ex.R +++ /dev/null @@ -1,234 +0,0 @@ -pkgname <- "SimTools" -source(file.path(R.home("share"), "R", "examples-header.R")) -options(warn = 1) -base::assign(".ExTimings", "SimTools-Ex.timings", pos = 'CheckExEnv') -base::cat("name\tuser\tsystem\telapsed\n", file=base::get(".ExTimings", pos = 'CheckExEnv')) -base::assign(".format_ptime", -function(x) { - if(!is.na(x[4L])) x[1L] <- x[1L] + x[4L] - if(!is.na(x[5L])) x[2L] <- x[2L] + x[5L] - options(OutDec = '.') - format(x[1L:3L], digits = 7L) -}, -pos = 'CheckExEnv') - -### * -library('SimTools') - -base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') -base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') -cleanEx() -nameEx("Siid") -### * Siid - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: Siid -### Title: Siid class -### Aliases: Siid as.Siid as.Siid.default is.iid - -### ** Examples - -# Generating iid data -chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -siid.obj <- Siid(chain) - - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("Siid", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("Smcmc") -### * Smcmc - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: Smcmc -### Title: Smcmc class -### Aliases: Smcmc as.Smcmc as.Smcmc.default is.mcmc - -### ** Examples - -# Producing Markov chain -chain <- matrix(0, nrow = 1e3, ncol = 1) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -smcmc.obj <- Smcmc(chain) - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("Smcmc", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("addCI") -### * addCI - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: addCI -### Title: Add simultaneous confidence interval to existing plot. -### Aliases: addCI - -### ** Examples - -chain <- matrix(0, ncol = 1, nrow = 1e3) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -chain <- Smcmc(list(chain)) -plot(density(chain$stacked[,1])) -CIs <- getCI(chain) -addCI(chain, CIs, component = 1) - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("addCI", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("boxCI") -### * boxCI - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: boxCI -### Title: Add simultaneous confidence interval to existing boxplot -### Aliases: boxCI - -### ** Examples - -output <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) - - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("boxCI", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("boxplot.Siid") -### * boxplot.Siid - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: boxplot.Siid -### Title: Boxplot for Siid -### Aliases: boxplot.Siid - -### ** Examples - -# Generating iid data -chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -siid.obj <- Siid(chain) -boxplot(siid.obj) - - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("boxplot.Siid", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("getCI") -### * getCI - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: getCI -### Title: Calculates simultaneous confidence intervals. -### Aliases: getCI - -### ** Examples - -chain <- matrix(0, ncol = 1, nrow = 1e3) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -chain <- Smcmc(list(chain)) -plot(density(chain$stacked[,1])) -CIs <- getCI(chain) -addCI(chain, CIs, component = 1) - - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("getCI", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("plot.Siid") -### * plot.Siid - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: plot.Siid -### Title: Plot Siid -### Aliases: plot.Siid - -### ** Examples - -# Generating iid data -chain <- matrix(rnorm(3*1e3), nrow = 1e3, ncol = 3) -siid.obj <- Siid(chain) -plot(siid.obj) - - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("plot.Siid", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -cleanEx() -nameEx("plot.Smcmc") -### * plot.Smcmc - -flush(stderr()); flush(stdout()) - -base::assign(".ptime", proc.time(), pos = "CheckExEnv") -### Name: plot.Smcmc -### Title: Plot Smcmc -### Aliases: plot.Smcmc - -### ** Examples - -# Producing Markov chain -chain <- matrix(0, ncol = 1, nrow = 1e3) -chain[1,] <- 0 -err <- rnorm(1e3) -for(i in 2:1e3) -{ - chain[i,] <- .3*chain[i-1,] + err[i] -} -chain <- Smcmc(list(chain)) -plot(chain) - - - - -base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") -base::cat("plot.Smcmc", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") -### *