Skip to content

Commit

Permalink
Moved example data and started working on vignettes.
Browse files Browse the repository at this point in the history
  • Loading branch information
demsarjure committed Nov 18, 2019
1 parent bcc370a commit 943310b
Show file tree
Hide file tree
Showing 34 changed files with 808 additions and 106 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
^\.travis\.yml$
.git
cran-comments.md
^doc$
^Meta$
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ vignettes/*.pdf
*.o
*.so
*.cc
*.hpp
*.hpp
doc
Meta
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ LinkingTo:
Rcpp (>= 0.12.16),
RcppEigen (>= 0.3.3.4.0)
SystemRequirements: GNU make
VignetteBuilder: knitr
NeedsCompilation: yes
RoxygenNote: 6.1.1
Suggests:
testthat
testthat,
knitr
5 changes: 5 additions & 0 deletions R/b_color.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ b_color <- function(colors,
control=NULL,
suppress_warnings=TRUE) {

# multi core
if (chains > 1) {
options(mc.cores = parallel::detectCores())
}

# prepare data
n <- nrow(colors)

Expand Down
5 changes: 5 additions & 0 deletions R/b_linear.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ b_linear <- function(x,
control=NULL,
suppress_warnings=TRUE) {

# multi core
if (chains > 1) {
options(mc.cores = parallel::detectCores())
}

# prepare data
n <- length(y)
m <- length(unique(s))
Expand Down
5 changes: 5 additions & 0 deletions R/b_reaction_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ b_reaction_time <- function(t,
control=NULL,
suppress_warnings=TRUE) {

# multi core
if (chains > 1) {
options(mc.cores = parallel::detectCores())
}

# prepare data
n <- length(t)
m <- length(unique(s))
Expand Down
5 changes: 5 additions & 0 deletions R/b_success_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ b_success_rate <- function(r,
control=NULL,
suppress_warnings=TRUE) {

# multi core
if (chains > 1) {
options(mc.cores = parallel::detectCores())
}

# prepare data
n <- length(r)
m <- length(unique(s))
Expand Down
5 changes: 5 additions & 0 deletions R/b_ttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ b_ttest <- function(data,
control=NULL,
suppress_warnings=TRUE) {

# multi core
if (chains > 1) {
options(mc.cores = parallel::detectCores())
}

# prepare data
n <- length(data)

Expand Down
27 changes: 27 additions & 0 deletions R/color_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#'
#' plot_distributions_difference(`color_class`, hsv=`vector`): a visualization of the difference between the distribution of the first fit and a color defined with hsv components. You can also provide the rope and bins (number of bins in the histogram) parameters or visualize the comparison only through chosen color components (r, g, b, h, s, v) by using the pars parameter.
#'
#' plot_hsv(`color_class`): plots fitted model against the data. Use this function to explore the quality of your fit thorough a circular visualization of hsv color components.
#'
#' plot_fit_hsv(`color_class`): plots fitted model against the data. Use this function to explore the quality of your fit thorough a circular visualization of hsv color components.
#'
#' plot_means_hsv(`color_class`): a visualization of the difference between means of two fits through a circular visualization of hsv color components. You can also compare fit means with colors defined through rgb or hsv components (as points or as lines on the visualization).
Expand Down Expand Up @@ -244,6 +246,9 @@
#' plot_distributions_difference(fit1, hsv=c(pi/2, 1, 1))
#'
#' # plot the fitted distribution for hue against the hue data
#' plot_hsv(fit1)
#'
#' # plot the fitted distribution for hue against the hue data
#' plot_fit_hsv(fit1)
#'
#' # visualize hue means of a single fit
Expand Down Expand Up @@ -1989,6 +1994,28 @@ setMethod(f="plot_distributions_difference", signature(object="color_class"), de
})


#' @rdname color_class-plot_hsv
#' @exportMethod plot_hsv
setGeneric(name="plot_hsv", function(object) standardGeneric("plot_hsv"))

#' @title plot_hsv
#' @description \code{plot_hsv} plots fitted model against the data. Use this function to explore the quality of your fit thorough a circular visualization of hsv color components.
#' @param object color_class object.
#' @rdname color_class-plot_hsv
#' @aliases plot_hsv_color
#' @return A ggplot visualization.
#'
#' @examples
#' # to use the function you first have to prepare the data and fit the model
#' # see class documentation for an example of the whole process
#' # along with an example of how to use this function
#' ?color_class
#'
setMethod(f="plot_hsv", signature(object="color_class"), definition=function(object) {
return(plot_fit_hsv(object))
})


#' @rdname color_class-plot_fit_hsv
#' @exportMethod plot_fit_hsv
setGeneric(name="plot_fit_hsv", function(object) standardGeneric("plot_fit_hsv"))
Expand Down
133 changes: 130 additions & 3 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,147 @@
#' Datasets for bayes4psy examples
#' Small datasets for use in \pkg{rstanarm} examples and vignettes.
#' Example datasets for use in \pkg{rstanarm} examples and vignettes.
#'
#' @name rstanarm-datasets
#' @name bayes4psy-datasets
#' @aliases adaptation_level_small
#'
#' @format
#' \describe{
#' \item{\code{adaptation_level_small}}{
#' Small dataset on subjects picking up weights and determining their weights from 1..10.
#'
#' 50 obs. of 3 variables
#' \itemize{
#' \item \code{sequence} sequence index.
#' \item \code{weight} actual weight of the object.
#' \item \code{response} subject's estimation of weight.
#' }
#' }
#' \item{\code{adaptation_level}}{
#' Data on subjects picking up weights and determining their weights from 1..10.
#'
#' 50 obs. of 5 variables
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 2900 obs. of 6 variables
#' \itemize{
#' \item \code{subject} subject index.
#' \item \code{group} group index.
#' \item \code{part} first or second part of the experiment.
#' \item \code{sequence} sequence index.
#' \item \code{weight} actual weight of the object.
#' \item \code{response} subject's estimation of weight.
#' }
#' }
#' #' \item{\code{after_images_opponent_process}}{
#' Colors predicted by the opponent process theory.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 6 obs. of 7 variables
#' \itemize{
#' \item \code{stimuli} name of the color stimuli.
#' \item \code{r} value of the R component in the RGB model.
#' \item \code{g} value of the G component in the RGB model.
#' \item \code{b} value of the B component in the RGB model.
#' \item \code{h} value of the H component in the HSV model.
#' \item \code{s} value of the S component in the HSV model.
#' \item \code{v} value of the V component in the HSV model.
#' }
#' }
#' #' \item{\code{after_images_opponent_stimuli}}{
#' Stimuli used in the after images experiment.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 6 obs. of 7 variables
#' \itemize{
#' \item \code{r_s} value of the R component in the RGB model.
#' \item \code{g_s} value of the G component in the RGB model.
#' \item \code{b_s} value of the B component in the RGB model.
#' \item \code{stimuli} name of the color stimuli.
#' \item \code{h_s} value of the H component in the HSV model.
#' \item \code{s_s} value of the S component in the HSV model.
#' \item \code{v_s} value of the V component in the HSV model.
#' }
#' }
#' #' \item{\code{after_images_trichromatic}}{
#' Colors predicted by the trichromatic theory.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 6 obs. of 7 variables
#' \itemize{
#' \item \code{stimuli} name of the color stimuli.
#' \item \code{r} value of the R component in the RGB model.
#' \item \code{g} value of the G component in the RGB model.
#' \item \code{b} value of the B component in the RGB model.
#' \item \code{h} value of the H component in the HSV model.
#' \item \code{s} value of the S component in the HSV model.
#' \item \code{v} value of the V component in the HSV model.
#' }
#' }
#' #' \item{\code{after_images}}{
#' Data gathered by the after images experiment.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 1311 obs. of 12 variables
#' \itemize{
#' \item \code{subject} subject index.
#' \item \code{rt} reaction time.
#' \item \code{r} value of the R component in the RGB model of subject's response.
#' \item \code{g} value of the G component in the RGB model of subject's response.
#' \item \code{b} value of the B component in the RGB model of subject's response.
#' \item \code{stimuli} name of the color stimuli.
#' \item \code{r_s} value of the R component in the RGB model of the shown stimulus
#' \item \code{g_s} value of the G component in the RGB model of the shown stimulus
#' \item \code{b_s} value of the B component in the RGB model of the shown stimulus
#' \item \code{h_s} value of the H component in the HSV model of the shown stimulus
#' \item \code{s_s} value of the S component in the HSV model of the shown stimulus
#' \item \code{v_s} value of the V component in the HSV model of the shown stimulus
#' }
#' }
#' #' \item{\code{flanker}}{
#' Data gathered by the flanker experiment.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 8256 obs. of 5 variables
#' \itemize{
#' \item \code{subject} subject index.
#' \item \code{group} group index.
#' \item \code{congruencty} type of stimulus.
#' \item \code{result} was subject's reponse correct or wrong?
#' \item \code{rt} reaction time.
#' }
#' }
#' #' \item{\code{stroop_extended}}{
#' All the data gathered by the Stroop experiment.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 41068 obs. of 5 variables
#' \itemize{
#' \item \code{subject} subject ID.
#' \item \code{cond} type of condition.
#' \item \code{rt} reaction time.
#' \item \code{acc} was subject's reponse correct or wrong?
#' \item \code{age} age of subject.
#' }
#' }
#' #' \item{\code{stroop_simple}}{
#' All the data gathered by the Stroop experiment.
#'
#' Source: Internal MBLab \url{www.mblab.si} repository.
#'
#' 61 obs. of 5 variables
#' \itemize{
#' \item \code{subject} subject ID.
#' \item \code{reading_neutral} average response time for reading neutral stimuli.
#' \item \code{naming_neutral} average response time for naming neutral stimuli.
#' \item \code{reading_incongruent} average response time for reading incongruent stimuli.
#' \item \code{naming_incongruent} average response time for naming incongruent stimuli.
#' }
#' }
#' }
#'
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion bayes4psy.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --no-multiarch
PackageRoxygenize: rd,collate,namespace
PackageRoxygenize: rd,collate,namespace,vignette
Binary file added data/adaptation_level.rda
Binary file not shown.
Binary file added data/after_images.rda
Binary file not shown.
Binary file added data/after_images_opponent_process.rda
Binary file not shown.
Binary file added data/after_images_stimuli.rda
Binary file not shown.
Binary file added data/after_images_trichromatic.rda
Binary file not shown.
Binary file added data/flanker.rda
Binary file not shown.
Binary file added data/stroop_extended.rda
Binary file not shown.
Binary file added data/stroop_simple.rda
Binary file not shown.
Loading

0 comments on commit 943310b

Please sign in to comment.