Skip to content

Commit

Permalink
Upgrades to documentation, ttest can now compare variance of fits onl…
Browse files Browse the repository at this point in the history
…y, some outputs now look better.
  • Loading branch information
demsarjure committed Jun 24, 2019
1 parent 26ca954 commit ea1eb9d
Show file tree
Hide file tree
Showing 29 changed files with 205 additions and 109 deletions.
2 changes: 1 addition & 1 deletion R/b_color.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @return An object of class `color_class`
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors for rgb
#' mu_prior <- b_prior(family="uniform", pars=c(0, 255))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 100))
Expand Down
2 changes: 1 addition & 1 deletion R/b_linear.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' @return An object of class `linear_class`.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors
#' mu_prior <- b_prior(family="normal", pars=c(0, 100))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down
2 changes: 1 addition & 1 deletion R/b_reaction_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @return An object of class `reaction_time_class`
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors
#' mu_prior <- b_prior(family="normal", pars=c(0, 100))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down
2 changes: 1 addition & 1 deletion R/b_success_rate.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @return An object of class `success_rate_class`.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors
#' p_prior <- b_prior(family="beta", pars=c(1, 1))
#' tau_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down
10 changes: 5 additions & 5 deletions R/b_ttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @return An object of class `ttest_class`.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors
#' mu_prior <- b_prior(family="normal", pars=c(0, 1000))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down Expand Up @@ -46,11 +46,11 @@ b_ttest <- function(data,
n <- length(data)

# prior ids and values
p_ids <- rep(0, 3)
p_values <- rep(0, 6)
p_ids <- rep(0, 2)
p_values <- rep(0, 4)

# parameter mapping
df_pars <- data.frame(par=c("mu", "sigma", "nu"), index=c(1, 2, 3))
df_pars <- data.frame(par=c("mu", "sigma"), index=c(1, 2))

# priors
if (!is.null(priors)) {
Expand All @@ -64,7 +64,7 @@ b_ttest <- function(data,
if (nrow(par_id) > 0) {
id <- par_id$index
} else {
wrong_prior <- "Provided an unknown parameter for prior, use \"mu\" \"sigma\" or \"nu\"."
wrong_prior <- "Provided an unknown parameter for prior, use \"mu\" or \"sigma\"."
warning(wrong_prior)
return()
}
Expand Down
2 changes: 1 addition & 1 deletion R/color_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#' @slot data Data on which the fit is based.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors for rgb
#' mu_prior <- b_prior(family="uniform", pars=c(0, 255))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 100))
Expand Down
8 changes: 4 additions & 4 deletions R/linear_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' @slot data Raw data for the tested group.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors
#' mu_prior <- b_prior(family="normal", pars=c(0, 100))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down Expand Up @@ -177,9 +177,9 @@ setMethod(f="summary", signature(object="linear_class"), definition=function(obj
sigma_hdi <- mcmc_hdi(object@extract$mu_s)

# print
cat(sprintf("intercept (alpha):\t%.2f +/- %.5f,, 95%% HDI: [%.2f, %.2f]\n",
cat(sprintf("intercept (alpha):\t%.2f +/- %.5f, 95%% HDI: [%.2f, %.2f]\n",
alpha, mcmcse::mcse(object@extract$mu_a)$se, alpha_hdi[1], alpha_hdi[2]))
cat(sprintf("slope (beta):\t\t%.2f +/- %.5f,, 95%% HDI: [%.2f, %.2f]\n",
cat(sprintf("slope (beta):\t\t%.2f +/- %.5f, 95%% HDI: [%.2f, %.2f]\n",
beta, mcmcse::mcse(object@extract$mu_b)$se, beta_hdi[1], beta_hdi[2]))
cat(sprintf("sigma:\t\t\t%.2f +/- %.5f, 95%% HDI: [%.2f, %.2f]\n",
sigma, mcmcse::mcse(object@extract$mu_s)$se, sigma_hdi[1], sigma_hdi[2]))
Expand Down Expand Up @@ -426,7 +426,7 @@ setMethod(f="plot_means_difference", signature(object="linear_class"), definitio
#' @title plot_means
#' @description \code{plot_means} plots means or the first and the second group means.
#' @param object linear_class object.
#' @param ... fit2 - a second linear_class object, par - specific parameter of comparison (slope or intercept).
#' @param ... fit2 - a second linear_class object, par - plot a specific parameter (slope or intercept).
#' @rdname linear_class-plot_means
#' @aliases plot_means_linear
#' @return A ggplot visualization or a warning if something went wrong.
Expand Down
12 changes: 6 additions & 6 deletions R/reaction_time_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' @slot data Data on which the fit is based.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # priors
#' mu_prior <- b_prior(family="normal", pars=c(0, 100))
#' sigma_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down Expand Up @@ -290,7 +290,7 @@ setMethod(f="get_subject_parameters", signature(object="reaction_time_class"), d
#' @title compare_means
#' @description \code{compare_means} prints difference in reaction times between two groups or multiple groups.
#' @param object reaction_time_class object.
#' @param ... fit2 - a second reaction_time_class object, fits - a list of reaction_time_class objects, rope - region of practical equivalence, par - specific parameter of comparison - mu or lambda.
#' @param ... fit2 - a second reaction_time_class object, fits - a list of reaction_time_class objects, rope - region of practical equivalence, par - specific parameter of comparison (mu or lambda).
#' @rdname reaction_time_class-compare_means
#' @aliases compare_means_reaction_time
#' @return Comparison results or a warning if something went wrong.
Expand Down Expand Up @@ -396,7 +396,7 @@ setMethod(f="compare_means", signature(object="reaction_time_class"), definition

# largest/smallest probabilities
if (n > 2) {
cat("\nProbabilities that a certain group is smallest/largest or equal to all others:\n\n")
cat("\nProbabilities that a certain group is\nsmallest/largest or equal to all others:\n\n")
smallest_largest <- is_smallest_or_largest(data=y, rope=rope)
print(smallest_largest)
cat("\n\n")
Expand All @@ -410,7 +410,7 @@ setMethod(f="compare_means", signature(object="reaction_time_class"), definition
#' @title plot_means_difference
#' @description \code{plot_means_difference} a visualization of the difference between two groups or multiple groups.
#' @param object reaction_time_class object.
#' @param ... fit2 - a second reaction_time_class object, fits - a list of reaction_time_class objects, rope - region of practical equivalence, bins - number of bins in the histogram, par - specific parameter of comparison - mu or lambda.
#' @param ... fit2 - a second reaction_time_class object, fits - a list of reaction_time_class objects, rope - region of practical equivalence, bins - number of bins in the histogram, par - specific parameter of comparison (mu or lambda).
#' @rdname reaction_time_class-plot_means_difference
#' @aliases plot_means_difference_reaction_time
#' @return A ggplot visualization or a warning if something went wrong.
Expand Down Expand Up @@ -556,7 +556,7 @@ setMethod(f="plot_means_difference", signature(object="reaction_time_class"), de
#' @title plot_means
#' @description \code{plot_means} plots density of means for one, two or multiple groups.
#' @param object reaction_time_class object.
#' @param ... fit2 - a second reaction_time_class object, fits - a list of reaction_time_class objects, par - specific parameter of comparison - mu or lambda.
#' @param ... fit2 - a second reaction_time_class object, fits - a list of reaction_time_class objects, par - plot a specific parameter (mu or lambda).
#' @rdname reaction_time_class-plot_means
#' @aliases plot_means_reaction_time
#' @return A ggplot visualization or a warning if something went wrong.
Expand Down Expand Up @@ -750,7 +750,7 @@ setMethod(f="compare_distributions", signature(object="reaction_time_class"), de

# largest/smallest probabilities
if (n > 2) {
cat("\nProbabilities that a certain group is smallest/largest or equal to all others:\n\n")
cat("\nProbabilities that a certain group is\nsmallest/largest or equal to all others:\n\n")
smallest_largest <- is_smallest_or_largest(data=y, rope=rope)
print(smallest_largest)
cat("\n\n")
Expand Down
6 changes: 3 additions & 3 deletions R/success_rate_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' @slot data Data on which the fit is based.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' #priors
#' p_prior <- b_prior(family="beta", pars=c(1, 1))
#' tau_prior <- b_prior(family="uniform", pars=c(0, 500))
Expand Down Expand Up @@ -328,7 +328,7 @@ setMethod(f="compare_means", signature(object="success_rate_class"), definition=

# largest/smallest probabilities
if (n > 2) {
cat("\nProbabilities that a certain group is smallest/largest or equal to all others:\n\n")
cat("\nProbabilities that a certain group is\nsmallest/largest or equal to all others:\n\n")
smallest_largest <- is_smallest_or_largest(data=y, rope=rope)
print(smallest_largest)
cat("\n\n")
Expand Down Expand Up @@ -593,7 +593,7 @@ setMethod(f="compare_distributions", signature(object="success_rate_class"), def

# largest/smallest probabilities
if (n > 2) {
cat("\nProbabilities that a certain group is smallest/largest or equal to all others:\n\n")
cat("\nProbabilities that a certain group is\nsmallest/largest or equal to all others:\n\n")
smallest_largest <- is_smallest_or_largest(data=y, rope=rope)
print(smallest_largest)
cat("\n\n")
Expand Down
Loading

0 comments on commit ea1eb9d

Please sign in to comment.