Skip to content

Commit

Permalink
Unbreak entire module (#88)
Browse files Browse the repository at this point in the history
* Fix figures and tables

* Update rest

* Force rerun of expired unit tests

* Update equivalencepairedsamplesttest.R
  • Loading branch information
koenderks authored Dec 2, 2023
1 parent 3e404be commit 3aafbea
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 51 deletions.
47 changes: 28 additions & 19 deletions R/equivalenceindependentsamplesttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ EquivalenceIndependentSamplesTTest <- function(jaspResults, dataset, options) {
tableResults <- try(TOSTER::dataTOSTtwo(data = dataset,
deps = .v(variable),
group = .v(options$groupingVariable),
var_equal = ifelse(options$tests == "students", TRUE, FALSE),
var_equal = options$tests == "students",
low_eqbound = options$lowerbound,
high_eqbound = options$upperbound,
eqbound_type = ifelse(options$boundstype == "raw", "raw", "d"), # bounds type is raw or cohen's d
eqbound_type = switch(options$boundstype, "raw" = "raw", "cohensD" = "SMD"), # bounds type is raw or cohen's d
alpha = options$alpha,
desc = TRUE))

Expand Down Expand Up @@ -122,12 +122,12 @@ EquivalenceIndependentSamplesTTest <- function(jaspResults, dataset, options) {
lowerP = tableResults$tost$asDF$`p[2]`,
lowCohen = tableResults$eqb$asDF$`low[cohen]`,
highCohen = tableResults$eqb$asDF$`high[cohen]`,
cilCohen = as.numeric(confIntEffSize[1]),
ciuCohen = as.numeric(confIntEffSize[2]),
cilCohen = tableResults$effsize$asDF$`cil[cohen]`,
ciuCohen = tableResults$effsize$asDF$`ciu[raw]`,
lowRaw = tableResults$eqb$asDF$`low[raw]`,
highRaw = tableResults$eqb$asDF$`high[raw]`,
cilRaw = tableResults$eqb$asDF$`cil[raw]`,
ciuRaw = tableResults$eqb$asDF$`ciu[raw]`,
cilRaw = tableResults$effsize$asDF$`cil[raw]`,
ciuRaw = tableResults$effsize$asDF$`ciu[raw]`,
desc = as.data.frame(tableResults$desc))
}

Expand Down Expand Up @@ -337,8 +337,9 @@ EquivalenceIndependentSamplesTTest <- function(jaspResults, dataset, options) {
"alpha", "missingValues"))
jaspResults[["equivalenceBoundsContainer"]] <- equivalenceBoundsContainer

if (!ready)
if (!ready) {
return()
}

for (variable in options$variables) {

Expand All @@ -347,7 +348,7 @@ EquivalenceIndependentSamplesTTest <- function(jaspResults, dataset, options) {
next

equivalenceIndTTestPlot <- createJaspPlot(title = variable, width = 480, height = 320)
equivalenceIndTTestPlot$dependOn(optionContainsValue = list("variables" = variable))
equivalenceIndTTestPlot$dependOn(options = "boundstype", optionContainsValue = list("variables" = variable))

# Get results
results <- equivalenceIndTTestResults[[variable]]
Expand All @@ -361,17 +362,25 @@ EquivalenceIndependentSamplesTTest <- function(jaspResults, dataset, options) {
dif <- (m1 - m2)

# Make plot
plot <- ggplot2::ggplot(data = dataset, ggplot2::aes_string(x = 0, y = dif)) +
ggplot2::annotate("rect", xmin = -20, xmax = 20, ymin = results$lowRaw, ymax = results$highRaw, alpha = .5) +
ggplot2::geom_errorbar(ggplot2::aes_string(x = 0, ymin = results$cilRaw, ymax = results$ciuRaw, width = .4), size = .8, colour = "black") +
ggplot2::geom_point(ggplot2::aes_string(x = 0, y = dif), shape = 21, fill = "black", size = 3, colour = "black") +
ggplot2::labs(x = ' ', y = variable) +
ggplot2::expand_limits(x = c(-2, 4), y = 0)
plot <- jaspGraphs::themeJasp(plot)
plot <- plot + ggplot2::theme(axis.text.x = ggplot2::element_blank(),
axis.title.x = ggplot2::element_blank(),
axis.ticks.x = ggplot2::element_blank(),
axis.line.x = ggplot2::element_blank(),) + ggplot2::scale_x_discrete(limits = c("", "", "", "", "", "", ""))
plot <- ggplot2::ggplot(data = dataset, ggplot2::aes_string(x = 0, y = dif))
if (options[["boundstype"]] == "raw") {
plot <- plot + ggplot2::annotate(geom = "rect", xmin = -20, xmax = 20, ymin = results$lowRaw, ymax = results$highRaw, alpha = .5) +
ggplot2::geom_errorbar(ymin = results$cilRaw, ymax = results$ciuRaw, width = .4, size = .8, colour = "black")
} else {
plot <- plot + ggplot2::annotate(geom = "rect", xmin = -20, xmax = 20, ymin = results$lowCohen, ymax = results$highCohen, alpha = .5) +
ggplot2::geom_errorbar(ymin = results$cilCohen, ymax = results$ciuCohen, width = .4, size = .8, colour = "black")
}
plot <- plot +
ggplot2::geom_point(x = 0, y = dif, shape = 21, fill = "black", size = 3, colour = "black") +
ggplot2::labs(x = NULL, y = variable) +
ggplot2::expand_limits(x = c(-2, 4), y = 0) +
jaspGraphs::geom_rangeframe() +
jaspGraphs::themeJaspRaw() +
ggplot2::theme(axis.text.x = ggplot2::element_blank(),
axis.title.x = ggplot2::element_blank(),
axis.ticks.x = ggplot2::element_blank(),
axis.line.x = ggplot2::element_blank()) +
ggplot2::scale_x_discrete(limits = c("", "", "", "", "", "", ""))

equivalenceIndTTestPlot$plotObject <- plot
}
Expand Down
41 changes: 25 additions & 16 deletions R/equivalenceonesamplettest.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ EquivalenceOneSampleTTest <- function(jaspResults, dataset, options) {
mu = options$mu,
low_eqbound = options$lowerbound,
high_eqbound = options$upperbound,
eqbound_type = ifelse(options$boundstype == "raw", "raw", "d"), # bounds type is raw or cohen's d
eqbound_type = switch(options$boundstype, "raw" = "raw", "cohensD" = "SMD"), # bounds type is raw or cohen's d
alpha = options$alpha, # default = 0.05
desc = TRUE))

Expand Down Expand Up @@ -114,12 +114,12 @@ EquivalenceOneSampleTTest <- function(jaspResults, dataset, options) {
lowerP = tableResults$tost$asDF$`p[2]`,
lowCohen = tableResults$eqb$asDF$`low[cohen]`,
highCohen = tableResults$eqb$asDF$`high[cohen]`,
cilCohen = as.numeric(confIntEffSize[1]),
ciuCohen = as.numeric(confIntEffSize[2]),
cilCohen = tableResults$effsize$asDF$`cil[cohen]`,
ciuCohen = tableResults$effsize$asDF$`ciu[cohen]`,
lowRaw = tableResults$eqb$asDF$`low[raw]`,
highRaw = tableResults$eqb$asDF$`high[raw]`,
cilRaw = tableResults$eqb$asDF$`cil[raw]`,
ciuRaw = tableResults$eqb$asDF$`ciu[raw]`,
cilRaw = tableResults$effsize$asDF$`cil[raw]`,
ciuRaw = tableResults$effsize$asDF$`ciu[raw]`,
desc = as.data.frame(tableResults$desc))
}
}
Expand Down Expand Up @@ -326,7 +326,7 @@ EquivalenceOneSampleTTest <- function(jaspResults, dataset, options) {
next

equivalenceOneTTestPlot <- createJaspPlot(title = variable, width = 480, height = 320)
equivalenceOneTTestPlot$dependOn(optionContainsValue = list("variables" = variable))
equivalenceOneTTestPlot$dependOn(options = "boundstype", optionContainsValue = list("variables" = variable))

# Get results
results <- equivalenceOneTTestResults[[variable]]
Expand All @@ -340,17 +340,26 @@ EquivalenceOneSampleTTest <- function(jaspResults, dataset, options) {
dif <- (m1 - m2)

# Make plot:
plot <- ggplot2::ggplot(data = dataset, ggplot2::aes_string(x = 0, y = dif)) +
ggplot2::annotate("rect", xmin = -20, xmax = 20, ymin = results$lowRaw, ymax = results$highRaw, alpha = .5) +
ggplot2::geom_errorbar(ggplot2::aes_string(x = 0, ymin = results$cilRaw, ymax = results$ciuRaw, width = .4), size = .8, colour = "black") +

plot <- ggplot2::ggplot(data = dataset, ggplot2::aes_string(x = 0, y = dif))
if (options[["boundstype"]] == "raw") {
plot <- plot + ggplot2::annotate(geom = "rect", xmin = -20, xmax = 20, ymin = results$lowRaw, ymax = results$highRaw, alpha = .5) +
ggplot2::geom_errorbar(ymin = results$cilRaw, ymax = results$ciuRaw, width = .4, size = .8, colour = "black")
} else {
plot <- plot + ggplot2::annotate(geom = "rect", xmin = -20, xmax = 20, ymin = results$lowCohen, ymax = results$highCohen, alpha = .5) +
ggplot2::geom_errorbar(ymin = results$cilCohen, ymax = results$ciuCohen, width = .4, size = .8, colour = "black")
}
plot <- plot +
ggplot2::geom_point(ggplot2::aes_string(x = 0, y = dif), shape = 21, fill = "black", size = 3, colour = "black") +
ggplot2::labs(x = '', y = variable) +
ggplot2::expand_limits(x = c(-2, 4), y = 0)
plot <- jaspGraphs::themeJasp(plot)
plot <- plot + ggplot2::theme(axis.text.x = ggplot2::element_blank(),
axis.title.x = ggplot2::element_blank(),
axis.ticks.x = ggplot2::element_blank(),
axis.line.x = ggplot2::element_blank(),) + ggplot2::scale_x_discrete(limits = c("", "", "", "", "", "", ""))
ggplot2::labs(x = NULL, y = variable) +
ggplot2::expand_limits(x = c(-2, 4), y = 0) +
jaspGraphs::geom_rangeframe() +
jaspGraphs::themeJaspRaw() +
ggplot2::theme(axis.text.x = ggplot2::element_blank(),
axis.title.x = ggplot2::element_blank(),
axis.ticks.x = ggplot2::element_blank(),
axis.line.x = ggplot2::element_blank()) +
ggplot2::scale_x_discrete(limits = c("", "", "", "", "", "", ""))

equivalenceOneTTestPlot$plotObject <- plot
}
Expand Down
41 changes: 25 additions & 16 deletions R/equivalencepairedsamplesttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ EquivalencePairedSamplesTTest <- function(jaspResults, dataset, options) {
results[[namePair]][["errorFootnotes"]] <- errorMessage
} else {
tableResults <- try(TOSTER::dataTOSTpaired(data = dataset,
pairs = list(list(i1 = p1, i2 = p2)),
pair1 = p1,
pair2 = p2,
low_eqbound = options$lowerbound,
high_eqbound = options$upperbound,
eqbound_type = ifelse(options$boundstype == "raw", "raw", "d"), # bounds type is raw or cohen's d
eqbound_type = switch(options$boundstype, "raw" = "raw", "cohensD" = "SMD"), # bounds type is raw or cohen's d
alpha = options$alpha, # default = 0.05
desc = TRUE))

Expand Down Expand Up @@ -125,12 +126,12 @@ EquivalencePairedSamplesTTest <- function(jaspResults, dataset, options) {
lowerP = tableResults$tost$asDF$`p[2]`,
lowCohen = tableResults$eqb$asDF$`low[cohen]`,
highCohen = tableResults$eqb$asDF$`high[cohen]`,
cilCohen = as.numeric(confIntEffSize[1]),
ciuCohen = as.numeric(confIntEffSize[2]),
cilCohen = tableResults$effsize$asDF$`cil[cohen]`,
ciuCohen = tableResults$effsize$asDF$`ciu[cohen]`,
lowRaw = tableResults$eqb$asDF$`low[raw]`,
highRaw = tableResults$eqb$asDF$`high[raw]`,
cilRaw = tableResults$eqb$asDF$`cil[raw]`,
ciuRaw = tableResults$eqb$asDF$`ciu[raw]`,
cilRaw = tableResults$effsize$asDF$`cil[raw]`,
ciuRaw = tableResults$effsize$asDF$`ciu[raw]`,
desc = as.data.frame(tableResults$desc))
}
}
Expand Down Expand Up @@ -372,17 +373,25 @@ EquivalencePairedSamplesTTest <- function(jaspResults, dataset, options) {
dif <- (m1 - m2)

# Make plot
plot <- ggplot2::ggplot(data = dataset, ggplot2::aes_string(x = 0, y = dif)) +
ggplot2::annotate("rect", xmin = -20, xmax = 20, ymin = results$lowRaw, ymax = results$highRaw, alpha = .5) +
ggplot2::geom_errorbar(ggplot2::aes_string(x = 0, ymin = results$cilRaw, ymax = results$ciuRaw, width = .4), size = .8, colour = "black") +
plot <- ggplot2::ggplot(data = dataset, ggplot2::aes_string(x = 0, y = dif))
if (options[["boundstype"]] == "raw") {
plot <- plot + ggplot2::annotate(geom = "rect", xmin = -20, xmax = 20, ymin = results$lowRaw, ymax = results$highRaw, alpha = .5) +
ggplot2::geom_errorbar(ymin = results$cilRaw, ymax = results$ciuRaw, width = .4, size = .8, colour = "black")
} else {
plot <- plot + ggplot2::annotate(geom = "rect", xmin = -20, xmax = 20, ymin = results$lowCohen, ymax = results$highCohen, alpha = .5) +
ggplot2::geom_errorbar(ymin = results$cilCohen, ymax = results$ciuCohen, width = .4, size = .8, colour = "black")
}
plot <- plot +
ggplot2::geom_point(ggplot2::aes_string(x = 0, y = dif), shape = 21, fill = "black", size = 3, colour = "black") +
ggplot2::labs(x = '', y = namePair) +
ggplot2::expand_limits(x = c(-2, 4), y = 0)
plot <- jaspGraphs::themeJasp(plot)
plot <- plot + ggplot2::theme(axis.text.x = ggplot2::element_blank(),
axis.title.x = ggplot2::element_blank(),
axis.ticks.x = ggplot2::element_blank(),
axis.line.x = ggplot2::element_blank(),) + ggplot2::scale_x_discrete(limits = c("", "", "", "", "", "", ""))
ggplot2::labs(x = NULL, y = namePair) +
ggplot2::expand_limits(x = c(-2, 4), y = 0) +
jaspGraphs::geom_rangeframe() +
jaspGraphs::themeJaspRaw() +
ggplot2::theme(axis.text.x = ggplot2::element_blank(),
axis.title.x = ggplot2::element_blank(),
axis.ticks.x = ggplot2::element_blank(),
axis.line.x = ggplot2::element_blank()) +
ggplot2::scale_x_discrete(limits = c("", "", "", "", "", "", ""))

equivalencePairedTTestPlot$plotObject <- plot
}
Expand Down

0 comments on commit 3aafbea

Please sign in to comment.