diff --git a/R/DESCRIPTION b/R/DESCRIPTION
index f6f82f0d..2a1cc3fb 100644
--- a/R/DESCRIPTION
+++ b/R/DESCRIPTION
@@ -1,7 +1,7 @@
Package: hBayesDM
Title: Hierarchical Bayesian Modeling of Decision-Making Tasks
-Version: 1.0.1.9000
-Date: 2019-09-01
+Version: 1.0.2.9000
+Date: 2019-11-13
Author:
Woo-Young Ahn [aut, cre],
Nate Haines [aut],
diff --git a/R/NEWS.md b/R/NEWS.md
index 21446d94..1364103e 100644
--- a/R/NEWS.md
+++ b/R/NEWS.md
@@ -1,3 +1,7 @@
+# hBayesDM 1.0.2
+
+- Fix an error on using data.frame objects as data (#112).
+
# hBayesDM 1.0.1
- Minor fix on the plotting function.
diff --git a/R/R/HDIofMCMC.R b/R/R/HDIofMCMC.R
index a8f578f3..0b1c0558 100644
--- a/R/R/HDIofMCMC.R
+++ b/R/R/HDIofMCMC.R
@@ -1,8 +1,9 @@
#' Compute Highest-Density Interval
#'
#' @description
-#' Computes the highest density interval from a sample of representative values, estimated as shortest credible interval.
-#' Downloaded from John Kruschke's website \url{http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis/}
+#' Computes the highest density interval from a sample of representative values,
+#' estimated as shortest credible interval.
+#' Based on John Kruschke's codes.
#'
#' @param sampleVec A vector of representative values from a probability distribution (e.g., MCMC samples).
#' @param credMass A scalar between 0 and 1, indicating the mass within the credible interval that is to be estimated.
diff --git a/R/R/hBayesDM_model.R b/R/R/hBayesDM_model.R
index bef5c1f3..ba71b874 100644
--- a/R/R/hBayesDM_model.R
+++ b/R/R/hBayesDM_model.R
@@ -306,7 +306,8 @@ hBayesDM_model <- function(task_name,
############### Print for user ###############
cat("\n")
cat("Model name =", model, "\n")
- cat("Data file =", data, "\n")
+ if (is.character(data))
+ cat("Data file =", data, "\n")
cat("\n")
cat("Details:\n")
if (vb) {
diff --git a/R/R/plotHDI.R b/R/R/plotHDI.R
index b439fc94..eb5852ac 100644
--- a/R/R/plotHDI.R
+++ b/R/R/plotHDI.R
@@ -1,6 +1,7 @@
-#' Plots highest density interval (HDI) from (MCMC) samples and prints HDI in the R console. HDI is indicated by a red line.
+#' Plots highest density interval (HDI) from (MCMC) samples and prints HDI in the R console.
+#' HDI is indicated by a red line.
+#' Based on John Kruschke's codes.
#'
-#' Based on John Kruschke's codes \url{http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis/}
#' @param sample MCMC samples
#' @param credMass A scalar between 0 and 1, indicating the mass within the credible interval that is to be estimated.
#' @param Title Character value containing the main title for the plot
diff --git a/R/docs/404.html b/R/docs/404.html
new file mode 100644
index 00000000..bedafff8
--- /dev/null
+++ b/R/docs/404.html
@@ -0,0 +1,152 @@
+
+
+
+
How can you tell if RStan is correctly installed? Check if you can fit the ‘Eight Schools’ model without a problem. Check here or here if you experience difficulty installing RStan.
Method A (recommended for all users - Windows/Mac/Linux)
If you follow the direction described below, Stan models will be precompiled during installation and models will run immediately when called. This is recommended if you are a frequent hBayesDM user!
-
Sys.setenv(BUILD_ALL='true') # Build all the models on installation
-Sys.setenv(MAKEFLAGS='-j 4') # Use 4 cores for compilation (or the number you want)
+
Sys.setenv(BUILD_ALL='true') # Build all the models on installation
+Sys.setenv(MAKEFLAGS='-j 4') # Use 4 cores for compilation (or the number you want)
-install.packages("hBayesDM") # Install from CRAN
+install.packages("hBayesDM") # Install from CRAN## or
-devtools::install_github("CCS-Lab/hBayesDM") # Install from GitHub
Four steps of doing HBA with hBayesDM are illustrated below. As an example, four models of the orthogonalized Go/Nogo task (Guitart-Masip et al., 2012; Cavanagh et al., 2013) are fit and compared with the hBayesDM package.
@@ -182,7 +184,7 @@
It is okay if the number of trials is different across subjects. But there should exist no N/A data. If some trials contain N/A data (e.g., choice=NA in trial#10), remove the trials first.
Sample data are available here, although users can fit a model with sample data without separately downloading them with one of the function arguments. Once the hBayesDM package is installed, sample data can be also retrieved from the package folder. Note that the file name of sample (example) data for a given task is taskName_exampleData.txt (e.g., dd_exampleData.txt, igt_exampleData.txt, gng_exampleData.txt, etc.). See each model’s help file (e.g., ?gng_m1) to check required data columns and their labels.
## Warning: Pareto k diagnostic value is 1.06. Resampling is disabled.
+
## Warning: Pareto k diagnostic value is 1.25. Resampling is disabled.
## Decreasing tol_rel_obj may help if variational algorithm has terminated
## prematurely. Otherwise consider using sampling instead.
##
@@ -286,7 +288,7 @@
allIndPars: Summary of individual subjects’ parameters (default: mean). Users can also choose to use median or mode (e.g., output1 = gng_m1("example", indPars="mode") ).
-parVals: Posterior samples of all parameters. Extracted by rstan::extract(rstan_object, permuted=T). Note that hyper (group) mean parameters are indicated by mu_PARAMETER (e.g., mu_xi, mu_ep, mu_rho).
+parVals: Posterior samples of all parameters. Extracted by rstan::extract(rstan_object, permuted=T). Note that hyper (group) mean parameters are indicated by mu_PARAMETER (e.g., mu_xi, mu_ep, mu_rho).
fit: RStan object (i.e., fit = stan(file='gng_m1.stan', ...) ).
@@ -323,13 +325,13 @@
3) Plot model parameters
Make sure to visually diagnose MCMC performance (i.e., visually check whether MCMC samples are well mixed and converged to stationary distributions). For the diagnosis or visualization of hyper (group) parameters, you can use plot.hBayesDM or just plot, which searches for an extension function that contains the class name. The class of any hBayesDM output is hBayesDM:
Let’s first visually diagnose MCMC performance of hyper parameters with trace plots:
-
plot(output1, type="trace", fontSize=11) # traceplot of hyper parameters. Set font size 11.
+
plot(output1, type="trace", fontSize=11) # traceplot of hyper parameters. Set font size 11.
The trace plots indicate that MCMC samples are indeed well mixed and converged, which is consistent with their \(\hat{R}\) values (see here for some discussion on why we care about mixing). Note that the plots above exclude burn-in samples. If you want, you can include burn-in (warmup) MCMC samples.
## Warning: Pareto k diagnostic value is 1.13. Resampling is disabled.
+
## Warning: Pareto k diagnostic value is 1.14. Resampling is disabled.
## Decreasing tol_rel_obj may help if variational algorithm has terminated
## prematurely. Otherwise consider using sampling instead.
+plot(sv_all[5, ], type="l", xlab="Trial", ylab="Stimulus Value (subject #5)")
Similarly, users can extract and visualize other model-based regressors. W(Go), W(NoGo), Q(Go), Q(NoGo) are stored in Wgo, Wnogo, Qgo, and Qnogo, respectively.
@@ -471,7 +475,7 @@
For example, to run gng_m1 using variational inference: