From 8f08f42feca2498de31a64183b40c18a5c00f35a Mon Sep 17 00:00:00 2001 From: Jure Demsar Date: Fri, 13 Dec 2019 09:53:28 +0100 Subject: [PATCH] CRAN preparations. --- .Rbuildignore | 1 + CRAN-RELEASE | 2 ++ DESCRIPTION | 1 + R/color_class.R | 3 +- R/data.R | 22 +++++++------ R/linear_class.R | 2 +- R/reaction_time_class.R | 3 +- R/success_rate_class.R | 3 +- R/ttest_class.R | 4 +-- README.md | 2 +- cran-comments.md | 2 +- man/bayes4psy-datasets.Rd | 32 +++++++++++++------ man/plot-color_class-missing-method.Rd | 6 ++-- man/plot-linear_class-missing-method.Rd | 4 +-- ...plot-reaction_time_class-missing-method.Rd | 6 ++-- man/plot-success_rate_class-missing-method.Rd | 6 ++-- man/plot-ttest_class-missing-method.Rd | 2 +- vignettes/adaptation_level.Rmd | 21 ++++++------ vignettes/afterimages.Rmd | 11 ++++--- vignettes/stroop.Rmd | 2 +- 20 files changed, 84 insertions(+), 51 deletions(-) create mode 100644 CRAN-RELEASE diff --git a/.Rbuildignore b/.Rbuildignore index 6ceb88c..6f55499 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,4 @@ cran-comments.md ^doc$ ^Meta$ +^CRAN-RELEASE$ diff --git a/CRAN-RELEASE b/CRAN-RELEASE new file mode 100644 index 0000000..890847c --- /dev/null +++ b/CRAN-RELEASE @@ -0,0 +1,2 @@ +This package was submitted to CRAN on 2019-12-09. +Once it is accepted, delete this file and tag the release (commit a74156ffe8). diff --git a/DESCRIPTION b/DESCRIPTION index 2a8b9a7..01e38e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,6 +20,7 @@ Depends: Imports: circular (>= 0.4.93), cowplot (>= 0.9.3), + plyr, dplyr (>= 0.7.6), emg (>= 1.0.7), ggplot2 (>= 2.2.1), diff --git a/R/color_class.R b/R/color_class.R index a268490..5b0b3b5 100644 --- a/R/color_class.R +++ b/R/color_class.R @@ -386,7 +386,8 @@ setMethod(f="show", signature(object="color_class"), definition=function(object) #' @title plot #' @description \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can compare fit with underlying data only through chosen color components (r, g, b, h, s, v). -#' @param object color_class object. +#' @param x color_class object. +#' @param y empty dummy variable, ignore this. #' @param ... pars - components of comparison, a subset of (r, g, b, h, s, v). #' @exportMethod plot #' diff --git a/R/data.R b/R/data.R index 01d9558..1d6ef41 100644 --- a/R/data.R +++ b/R/data.R @@ -1,14 +1,18 @@ #' Datasets for bayes4psy examples #' Example datasets for use in \pkg{rstanarm} examples and vignettes. +#' The datasets were extracted from the internal MBLab \url{http://www.mblab.si} repository. +#' MBLab is a research lab at the Faculty of Arts, Department of Psychology, University of Ljubljana, Slovenia. #' #' @name bayes4psy-datasets -#' @aliases adaptation_level_small +#' @aliases adaptation_level_small adaptation_level after_images_opponent_process after_images_stimuli after_images_trichromatic after_images flanker stroop_extended stroop_simple #' #' @format #' \describe{ #' \item{\code{adaptation_level_small}}{ #' Small dataset on subjects picking up weights and determining their weights from 1..10. #' +#' Source: Internal MBLab repository. +#' #' 50 obs. of 3 variables #' \itemize{ #' \item \code{sequence} sequence index. @@ -19,7 +23,7 @@ #' \item{\code{adaptation_level}}{ #' Data on subjects picking up weights and determining their weights from 1..10. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 2900 obs. of 6 variables #' \itemize{ @@ -34,7 +38,7 @@ #' #' \item{\code{after_images_opponent_process}}{ #' Colors predicted by the opponent process theory. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 6 obs. of 7 variables #' \itemize{ @@ -50,7 +54,7 @@ #' #' \item{\code{after_images_opponent_stimuli}}{ #' Stimuli used in the after images experiment. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 6 obs. of 7 variables #' \itemize{ @@ -66,7 +70,7 @@ #' #' \item{\code{after_images_trichromatic}}{ #' Colors predicted by the trichromatic theory. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 6 obs. of 7 variables #' \itemize{ @@ -82,7 +86,7 @@ #' #' \item{\code{after_images}}{ #' Data gathered by the after images experiment. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 1311 obs. of 12 variables #' \itemize{ @@ -103,7 +107,7 @@ #' #' \item{\code{flanker}}{ #' Data gathered by the flanker experiment. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 8256 obs. of 5 variables #' \itemize{ @@ -117,7 +121,7 @@ #' #' \item{\code{stroop_extended}}{ #' All the data gathered by the Stroop experiment. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 41068 obs. of 5 variables #' \itemize{ @@ -131,7 +135,7 @@ #' #' \item{\code{stroop_simple}}{ #' All the data gathered by the Stroop experiment. #' -#' Source: Internal MBLab \url{www.mblab.si} repository. +#' Source: Internal MBLab repository. #' #' 61 obs. of 5 variables #' \itemize{ diff --git a/R/linear_class.R b/R/linear_class.R index deffbf6..0155e2d 100644 --- a/R/linear_class.R +++ b/R/linear_class.R @@ -210,7 +210,7 @@ setMethod(f="show", signature(object="linear_class"), definition=function(object #' @title plot #' @description \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subject level (subjects=TRUE) or on the group level (subjects=FALSE). -#' @param object linear_class object. +#' @param x linear_class object. #' @param ... subjects - plot fits on a subject level (default = TRUE). #' @exportMethod plot #' diff --git a/R/reaction_time_class.R b/R/reaction_time_class.R index ec4fdb5..da20352 100644 --- a/R/reaction_time_class.R +++ b/R/reaction_time_class.R @@ -240,7 +240,8 @@ setMethod(f="show", signature(object="reaction_time_class"), definition=function #' @title plot #' @description \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subjects level (subjects=TRUE) or on the group level (subjects=FALSE). -#' @param object reaction_time_class object. +#' @param x reaction_time_class object. +#' @param y empty dummy variable, ignore this. #' @param ... subjects - plot fits on a subject level (default = TRUE). #' @exportMethod plot #' diff --git a/R/success_rate_class.R b/R/success_rate_class.R index c258c6a..8292bc8 100644 --- a/R/success_rate_class.R +++ b/R/success_rate_class.R @@ -216,7 +216,8 @@ setMethod(f="show", signature(object="success_rate_class"), definition=function( #' @title plot #' @description \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subjects level (subjects=TRUE) or on the group level (subjects=FALSE). -#' @param object success_rate_class object. +#' @param x success_rate_class object. +#' @param y empty dummy variable, ignore this. #' @param ... subjects - plot fits on a subject level (default = TRUE). #' @exportMethod plot #' diff --git a/R/ttest_class.R b/R/ttest_class.R index 03acd8a..7c45ac9 100644 --- a/R/ttest_class.R +++ b/R/ttest_class.R @@ -259,7 +259,7 @@ setMethod(f="show", signature(object="ttest_class"), definition=function(object) #' @title plot #' @description \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. -#' @param object ttest_class object. +#' @param x ttest_class object. #' @exportMethod plot #' #' @examples @@ -780,7 +780,7 @@ setMethod(f="plot_means", signature(object="ttest_class"), definition=function(o x_min <- min(x_min, par2) x_max <- max(x_max, par2) } - + diff <- x_max - x_min x_min <- x_min - 0.1*diff x_max <- x_max + 0.1*diff diff --git a/README.md b/README.md index d765cd5..fd9725a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # bayes4psy -[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/bayes4psy?color=blue)](http://cran.r-project.org/package=bayes4psy)[![Downloads](http://cranlogs.r-pkg.org/badges/bayes4psy?color=blue)](http://cran.rstudio.com/package=bayes4psy) +[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/bayes4psy?color=blue)](https://CRAN.R-project.org/package=bayes4psy)[![Downloads](http://cranlogs.r-pkg.org/badges/bayes4psy?color=blue)](https://CRAN.R-project.org/package=bayes4psy) ## The package diff --git a/cran-comments.md b/cran-comments.md index 46696fd..526174b 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,6 @@ ## Revisions -### CRAN submission 18. 6. 2019 +### CRAN submission 28. 6. 2019 Everything was OK. diff --git a/man/bayes4psy-datasets.Rd b/man/bayes4psy-datasets.Rd index 3194f8f..e112620 100644 --- a/man/bayes4psy-datasets.Rd +++ b/man/bayes4psy-datasets.Rd @@ -3,12 +3,24 @@ \name{bayes4psy-datasets} \alias{bayes4psy-datasets} \alias{adaptation_level_small} +\alias{adaptation_level} +\alias{after_images_opponent_process} +\alias{after_images_stimuli} +\alias{after_images_trichromatic} +\alias{after_images} +\alias{flanker} +\alias{stroop_extended} +\alias{stroop_simple} \title{Datasets for bayes4psy examples -Example datasets for use in \pkg{rstanarm} examples and vignettes.} +Example datasets for use in \pkg{rstanarm} examples and vignettes. +The datasets were extracted from the internal MBLab \url{http://www.mblab.si} repository. +MBLab is a research lab at the Faculty of Arts, Department of Psychology, University of Ljubljana, Slovenia.} \format{\describe{ \item{\code{adaptation_level_small}}{ Small dataset on subjects picking up weights and determining their weights from 1..10. +Source: Internal MBLab repository. + 50 obs. of 3 variables \itemize{ \item \code{sequence} sequence index. @@ -19,7 +31,7 @@ Small dataset on subjects picking up weights and determining their weights from \item{\code{adaptation_level}}{ Data on subjects picking up weights and determining their weights from 1..10. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 2900 obs. of 6 variables \itemize{ @@ -34,7 +46,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{after_images_opponent_process}}{ Colors predicted by the opponent process theory. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 6 obs. of 7 variables \itemize{ @@ -50,7 +62,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{after_images_opponent_stimuli}}{ Stimuli used in the after images experiment. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 6 obs. of 7 variables \itemize{ @@ -66,7 +78,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{after_images_trichromatic}}{ Colors predicted by the trichromatic theory. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 6 obs. of 7 variables \itemize{ @@ -82,7 +94,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{after_images}}{ Data gathered by the after images experiment. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 1311 obs. of 12 variables \itemize{ @@ -103,7 +115,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{flanker}}{ Data gathered by the flanker experiment. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 8256 obs. of 5 variables \itemize{ @@ -117,7 +129,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{stroop_extended}}{ All the data gathered by the Stroop experiment. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 41068 obs. of 5 variables \itemize{ @@ -131,7 +143,7 @@ Source: Internal MBLab \url{www.mblab.si} repository. #' \item{\code{stroop_simple}}{ All the data gathered by the Stroop experiment. -Source: Internal MBLab \url{www.mblab.si} repository. +Source: Internal MBLab repository. 61 obs. of 5 variables \itemize{ @@ -146,6 +158,8 @@ Source: Internal MBLab \url{www.mblab.si} repository. \description{ Datasets for bayes4psy examples Example datasets for use in \pkg{rstanarm} examples and vignettes. +The datasets were extracted from the internal MBLab \url{http://www.mblab.si} repository. +MBLab is a research lab at the Faculty of Arts, Department of Psychology, University of Ljubljana, Slovenia. } \examples{ diff --git a/man/plot-color_class-missing-method.Rd b/man/plot-color_class-missing-method.Rd index 3d5c130..9590837 100644 --- a/man/plot-color_class-missing-method.Rd +++ b/man/plot-color_class-missing-method.Rd @@ -8,9 +8,11 @@ \S4method{plot}{color_class,missing}(x, y, ...) } \arguments{ -\item{...}{pars - components of comparison, a subset of (r, g, b, h, s, v).} +\item{x}{color_class object.} + +\item{y}{empty dummy variable, ignore this.} -\item{object}{color_class object.} +\item{...}{pars - components of comparison, a subset of (r, g, b, h, s, v).} } \description{ \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can compare fit with underlying data only through chosen color components (r, g, b, h, s, v). diff --git a/man/plot-linear_class-missing-method.Rd b/man/plot-linear_class-missing-method.Rd index b5982fc..8672dd8 100644 --- a/man/plot-linear_class-missing-method.Rd +++ b/man/plot-linear_class-missing-method.Rd @@ -8,9 +8,9 @@ \S4method{plot}{linear_class,missing}(x, y, ...) } \arguments{ -\item{...}{subjects - plot fits on a subject level (default = TRUE).} +\item{x}{linear_class object.} -\item{object}{linear_class object.} +\item{...}{subjects - plot fits on a subject level (default = TRUE).} } \description{ \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subject level (subjects=TRUE) or on the group level (subjects=FALSE). diff --git a/man/plot-reaction_time_class-missing-method.Rd b/man/plot-reaction_time_class-missing-method.Rd index d9608aa..9796ca7 100644 --- a/man/plot-reaction_time_class-missing-method.Rd +++ b/man/plot-reaction_time_class-missing-method.Rd @@ -8,9 +8,11 @@ \S4method{plot}{reaction_time_class,missing}(x, y, ...) } \arguments{ -\item{...}{subjects - plot fits on a subject level (default = TRUE).} +\item{x}{reaction_time_class object.} + +\item{y}{empty dummy variable, ignore this.} -\item{object}{reaction_time_class object.} +\item{...}{subjects - plot fits on a subject level (default = TRUE).} } \description{ \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subjects level (subjects=TRUE) or on the group level (subjects=FALSE). diff --git a/man/plot-success_rate_class-missing-method.Rd b/man/plot-success_rate_class-missing-method.Rd index 5de911a..30482d4 100644 --- a/man/plot-success_rate_class-missing-method.Rd +++ b/man/plot-success_rate_class-missing-method.Rd @@ -8,9 +8,11 @@ \S4method{plot}{success_rate_class,missing}(x, y, ...) } \arguments{ -\item{...}{subjects - plot fits on a subject level (default = TRUE).} +\item{x}{success_rate_class object.} + +\item{y}{empty dummy variable, ignore this.} -\item{object}{success_rate_class object.} +\item{...}{subjects - plot fits on a subject level (default = TRUE).} } \description{ \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subjects level (subjects=TRUE) or on the group level (subjects=FALSE). diff --git a/man/plot-ttest_class-missing-method.Rd b/man/plot-ttest_class-missing-method.Rd index e2aa238..8fe95be 100644 --- a/man/plot-ttest_class-missing-method.Rd +++ b/man/plot-ttest_class-missing-method.Rd @@ -8,7 +8,7 @@ \S4method{plot}{ttest_class,missing}(x) } \arguments{ -\item{object}{ttest_class object.} +\item{x}{ttest_class object.} } \description{ \code{plot} plots fitted model against the data. Use this function to explore the quality of your fit. diff --git a/vignettes/adaptation_level.Rmd b/vignettes/adaptation_level.Rmd index a248830..66091e1 100644 --- a/vignettes/adaptation_level.Rmd +++ b/vignettes/adaptation_level.Rmd @@ -10,7 +10,7 @@ ```{r, message=FALSE, warning=FALSE, echo=FALSE} @@ -40,6 +40,7 @@ We will conduct the analysis by using the hierarchical linear model. First we ha # libs library(bayes4psy) library(ggplot2) +library(plyr) library(dplyr) # load data @@ -54,30 +55,30 @@ n1 <- length(unique(group1$subject)) n2 <- length(unique(group2$subject)) # map subjects to 1..n interval -group1$subject <- plyr::mapvalues(group1$subject, - from=unique(group1$subject), - to=1:n1) -group2$subject <- plyr::mapvalues(group2$subject, - from=unique(group2$subject), - to=1:n2) +group1$subject <- mapvalues(group1$subject, + from=unique(group1$subject), + to=1:n1) +group2$subject <- mapvalues(group2$subject, + from=unique(group2$subject), + to=1:n2) # second part data group1_part2 <- group1 %>% filter(part == 2) group2_part2 <- group2 %>% filter(part == 2) ``` -Once the data is prepared we can fit the Bayesian models, the input data comes in the form of three vectors, $x$ stores indexes of the measurements, $y$ subject's responses and $s$ indexes of subjects. The **warmup** and **iter** parameters are set in order to achieve an effective sample size of 10,000. +Once the data is prepared we can fit the Bayesian models, the input data comes in the form of three vectors, $x$ stores indexes of the measurements, $y$ subject's responses and $s$ indexes of subjects. ```{r, message=FALSE, warning=FALSE} fit1 <- b_linear(x=group1_part2$sequence, y=group1_part2$response, s=group1_part2$subject, - iter=10000, warmup=500) + iter=2000, warmup=500) fit2 <- b_linear(x=group2_part2$sequence, y=group2_part2$response, s=group2_part2$subject, - iter=10000, warmup=500) + iter=2000, warmup=500) ``` The fitting process is always followed by the quality analysis. diff --git a/vignettes/afterimages.Rmd b/vignettes/afterimages.Rmd index 5f2e362..abd24ee 100644 --- a/vignettes/afterimages.Rmd +++ b/vignettes/afterimages.Rmd @@ -1,5 +1,5 @@ --- - title: "Analysis of the Stroop experiment data using the Bayesian t-test" + title: "Analysis of the afterimages experiment data using the Bayesian color model" author: "Jure Demšar, Erik Štrumbelj and Grega Repovš" date: "`r Sys.Date()`" output: @@ -10,7 +10,7 @@ ```{r, message=FALSE, warning=FALSE, echo=FALSE} @@ -33,6 +33,7 @@ We start our analysis by loading the experiment and stimuli data. The experiment library(bayes4psy) library(dplyr) library(ggplot2) +library(cowplot) # load data data_all <- after_images @@ -232,9 +233,9 @@ plot_magenta <- plot_magenta + ggtitle("Magenta") + We can then use the **cowplot** library to combine the plots into a single figure. ```{r, message=FALSE, warning=FALSE} -cowplot::plot_grid(plot_red, plot_green, plot_blue, - plot_yellow, plot_cyan, plot_magenta, - ncol=3, nrow=2, scale=0.9) +plot_grid(plot_red, plot_green, plot_blue, + plot_yellow, plot_cyan, plot_magenta, + ncol=3, nrow=2, scale=0.9) ``` This last figure features the comparison of predictions between the thrichromatic and the oponent-process color coding. The long solid line visualizes the trichromatic color coding prediction while the dashed line visualizes the opponent-process color coding. Short solid line represents the mean hue of the fit and the the colored band the 95% HDI of the distribution underlying the fit. The small colored circle visualizes the color of the presented stimuli. In the case of blue and yellow stimuli the dashed line is not visible because both color codings predict the same outcome. The prediction based on the thrichromatic color coding seems more accurate as its prediction is always inside the 95% of the most probable subject's responses and is always closer to the mean predicted hue than the opponent-process prediction. The opponent-process prediction is outside of the 95% of the most probable subject's responses in cases of red and green stimuli. diff --git a/vignettes/stroop.Rmd b/vignettes/stroop.Rmd index 84fc04b..c247e13 100644 --- a/vignettes/stroop.Rmd +++ b/vignettes/stroop.Rmd @@ -10,7 +10,7 @@ ```{r, message=FALSE, warning=FALSE, echo=FALSE}