Skip to content
Permalink
Browse files

0.4.0

  • Loading branch information...
Øystein Olav Skaar
Øystein Olav Skaar committed Feb 4, 2019
1 parent 4c12106 commit 90a880e79f7469a6a2c1f4d543d33b6bab1e69de
Showing with 62 additions and 38 deletions.
  1. +2 −2 DESCRIPTION
  2. +11 −0 NEWS.md
  3. +11 −7 R/mcmc.R
  4. +4 −4 R/plot_parse.R
  5. +8 −1 R/settings.R
  6. +1 −4 R/stats_nominal.R
  7. +4 −4 README.md
  8. +2 −2 man/ParsePlot.Rd
  9. +11 −9 man/RunMCMC.Rd
  10. +8 −5 man/bfw.Rd
@@ -1,6 +1,6 @@
Package: bfw
Version: 0.3.0.9002
Date: 2018-12-19
Version: 0.4.0
Date: 2010-02-04
Title: Bayesian Framework for Computational Modeling
Authors@R: person( "Øystein Olav","Skaar", email="bayesianfw@gmail.com", role=c("aut","cre"))
Maintainer: Øystein Olav Skaar <bayesianfw@gmail.com>
11 NEWS.md
@@ -1,3 +1,14 @@
# bfw 0.4.0

#### Critical

* Fixed an sorting error in `contrasts` function

#### Minor

* Added the ability to use custom save names
* Removed the appended "Plot" in save names for `ParsePlot` function

# bfw 0.3.0.9002

#### Minor
@@ -8,6 +8,7 @@
#' @param run.contrasts logical, indicating whether or not to run contrasts, Default: FALSE
#' @param use.contrast choose from "between", "within" and "mixed". Between compare groups at different conditions. Within compare a group at different conditions. Mixed compute all comparisons, Default: "between",
#' @param contrasts define contrasts to use for analysis (defaults to all) , Default: NULL
#' @param custom.contrast define contrasts for custom models , Default: NULL
#' @param run.ppp logical, indicating whether or not to conduct ppp analysis, Default: FALSE
#' @param k.ppp run ppp for every kth length of MCMC chains, Default: 10
#' @param n.data sample size for each parameter
@@ -58,6 +59,7 @@ RunMCMC <- function(jags.model,
run.contrasts = FALSE,
use.contrast = "between",
contrasts = NULL,
custom.contrast = NULL,
run.ppp = FALSE,
k.ppp = 10,
n.data,
@@ -145,8 +147,6 @@ RunMCMC <- function(jags.model,

# Treat results as matrix for further examination
matrix.MCMC <- as.matrix(data.MCMC)
# Sort matrix by column names
if (ncol(matrix.MCMC)>1) matrix.MCMC <- matrix.MCMC[, order(colnames(matrix.MCMC))]

# Append bracket (ie., [1] ) for naming purposes
colnames(matrix.MCMC) <- unlist(lapply(colnames(matrix.MCMC), function (x) if(regexpr('\\[', x)[1]<0) paste0(x,"[1]") else x ))
@@ -212,24 +212,25 @@ RunMCMC <- function(jags.model,
if (run.contrasts) {

q.levels <- data.list$q.levels
defined.contrast <- if (length(custom.contrast)) tolower(custom.contrast) else tolower(model.type)

cat("\nComputing contrasts. Please wait.\n")

# Createsum to zero contrasts for metric and nominal models
if (model.type == "Metric" | model.type == "Nominal") {
if (defined.contrast == "metric" | defined.contrast == "nominal") {
sum.zero <- SumToZero(q.levels, matrix.MCMC, contrasts)
}

# Add odds (and odds-ratios/cohen's d) for nominal models
if (model.type == "Nominal") {
if (defined.contrast == "nominal") {

# Create expected and observed nominal and proportions data
expected.observed <- MatrixCombn(matrix.MCMC,
"o,o,e,e",
"NULL,p,NULL,p",
q.levels,
rm.last = FALSE,
row.means=FALSE)
row.means = FALSE)

# Remove expected and observed columns from MCMC matrix
matrix.MCMC <- matrix.MCMC[ , !colnames(matrix.MCMC) %in% colnames(expected.observed)]
@@ -240,7 +241,7 @@ RunMCMC <- function(jags.model,
}

# Add effect size cohen's d for metric model
if (model.type == "Metric") {
if (defined.contrast == "metric") {

# Create mean difference data
mean.diff <- MatrixCombn(matrix.MCMC, "m,s", q.levels = q.levels, rm.last = FALSE)
@@ -391,7 +392,7 @@ RunMCMC <- function(jags.model,

# Find params from MCMC list
params <- colnames(list.MCMC[[k]])

# Create final posterior parameter indicies
summary.start.time <- Sys.time()
summary.cat <- sprintf("\nSummarizing data for each parameter in %s. Please wait.\n" ,
@@ -414,6 +415,9 @@ RunMCMC <- function(jags.model,

}))
}))

# Sort summary by rownames
if (nrow(summary.MCMC)>1) summary.MCMC <- summary.MCMC[order(rownames(summary.MCMC)) ,]

# Display completion and running time
stop.time <- Sys.time()
@@ -37,7 +37,7 @@
#' \donttest{
#' # Save plots as png with a4 layout and return file names
#' project.dir <- tempdir()
#' project.name <- FileName(name="Testing")
#' project.name <- FileName(name="Testing-Plot")
#' ParsePlot(plot.data,
#' project.dir = project.dir,
#' project.name = project.name,
@@ -51,7 +51,7 @@
#' # [3] "\\Temp/Project-Testing-Plot03-1528833217.png"
#' # Save plots as single PowerPoint (default) and return file names
#' project.dir <- tempdir()
#' project.name <- FileName(name="Testing")
#' project.name <- FileName(name="Testing-Plot")
#' ParsePlot(plot.data,
#' project.dir = project.dir,
#' project.name = project.name,
@@ -196,9 +196,9 @@ ParsePlot <- function (plot.data,
if (one.file & ( dev.type == "postscript" |
dev.type == "pdf" |
dev.type == "pptx" ) ) {
plot.type <- "-Plot"
plot.type <- ""
} else {
plot.type <- "-Plot%02d"
plot.type <- "%02d"
}

# split file name
@@ -14,6 +14,7 @@
#' @param adapt.steps the number of adaptive iterations to use at the start of each simulation, Default: NULL
#' @param burnin.steps the number of burnin iterations, NOT including the adaptive iterations to use for the simulation, Default: NULL
#' @param initial.list initial values for analysis, Default: list()
#' @param custom.name custom name of project, Default: NULL
#' @param project.name name of project, Default: 'Project'
#' @param project.dir define where to save data, Default: 'Results/'
#' @param project.data define data to use for analysis (e.g., csv, rda, custom data.frame or matrix, or data included in package, Default: NULL
@@ -49,6 +50,7 @@ bfw <- function(job.title = NULL,
adapt.steps = NULL,
burnin.steps = NULL,
initial.list = list(),
custom.name = NULL,
project.name = "Project",
project.dir = "Results/",
project.data = NULL,
@@ -178,7 +180,12 @@ bfw <- function(job.title = NULL,
if (run.robust) {
job.title <- if (is.null(job.title)) "Robust" else paste0(job.title,"-Robust")
}
project.name <- FileName( project.name , data.set , model.type , job.title , time.stamp)

if (length(custom.name)) {
project.name <- custom.name
} else {
project.name <- FileName( project.name , data.set , model.type , job.title , time.stamp)
}

# Tidy up JAGS model
jags.model <- TidyCode(jags.model)
@@ -311,9 +311,6 @@ StatsNominal <- function(x = NULL,

}),collapse="\n\n")




# Replace placeholders in jags model with created values
model.name <- paste0(model.name,n.x)
jags.model <- gsub("\\#FACTORS", factors.additive, jags.model)
@@ -328,7 +325,7 @@ StatsNominal <- function(x = NULL,
job.names = job.names,
model.name = model.name
)

# Return data list
return (list(
data.list = data.list,
@@ -7,9 +7,9 @@
<a href="man/figures/logo2.png" id="logo2" title="Logo II"><img src="man/figures/logo2.png" width="250px" alt="Logo II" /></a>
</p>
<p align="center">
<a href="NEWS.md" id="news" title="News"><img src="https://img.shields.io/badge/News-2018.12.19 @ 09:55:10-purple.svg" alt="News" /></a>
<a href="NEWS.md" id="news" title="News"><img src="https://img.shields.io/badge/News-2019.02.04 @ 11:50:01-purple.svg" alt="News" /></a>
<a href="https://CRAN.R-project.org/package=bfw" id="cran" title="CRAN Version"><img src="https://www.r-pkg.org/badges/version/bfw" alt="CRAN Version" /></a>
<a href="https://github.com/oeysan/bfw" id="github" title="GitHub Version"><img src="https://img.shields.io/badge/GitHub-0.3.0.9002-red.svg?style=flat-square" alt="GitHub Version" /></a>
<a href="https://github.com/oeysan/bfw" id="github" title="GitHub Version"><img src="https://img.shields.io/badge/GitHub-0.4.0-red.svg?style=flat-square" alt="GitHub Version" /></a>
<br/>
<a href="LICENSE.md" id="license" title="License"><img src="https://img.shields.io/badge/Licence-MIT-blue.svg" alt="License" /></a>
<a href="https://travis-ci.org/oeysan/bfw" id="travis" title="Build Status"><img src="https://travis-ci.org/oeysan/bfw.svg?branch=master" alt="Build Status" /></a>
@@ -265,11 +265,11 @@ The cost of conducting robust estimates

# Running time for normal distribution analyis
biased.mcmc$run.time[2] - biased.mcmc$run.time[1]
#> Time difference of 8.09 secs
#> Time difference of 7.66 secs

# Running time for t-distribution analysis
biased.mcmc.robust$run.time[2] - biased.mcmc.robust$run.time[1]
#> Time difference of 38.1 secs
#> Time difference of 32.9 secs

License
-------

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 90a880e

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.