Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add df to posthoc tables, remove LSD from standard post hoc #388

Merged
merged 6 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion R/ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ AncovaInternal <- function(jaspResults, dataset = NULL, options) {
if (!is.null(postHocContainer[["postHocStandardContainer"]]))
return()

postHocStandardContainer <- createJaspContainer(title = gettext("Standard (LSD)"))
myTitle <- if (options[["postHocCorrectionTukey"]]) gettext("Standard (HSD)") else gettext("Standard")
postHocStandardContainer <- createJaspContainer(title = myTitle)
postHocStandardContainer$dependOn(c("postHocTerms", "postHocTypeStandardEffectSize", "postHocTypeStandard",
"postHocCorrectionBonferroni", "postHocCorrectionHolm", "postHocCorrectionScheffe",
"postHocCorrectionTukey", "postHocCorrectionSidak", "postHocSignificanceFlag",
Expand Down Expand Up @@ -933,6 +934,8 @@ AncovaInternal <- function(jaspResults, dataset = NULL, options) {
wantsCorrections <- c(options[["postHocCorrectionTukey"]], options[["postHocCorrectionScheffe"]],
options[["postHocCorrectionBonferroni"]], options[["postHocCorrectionHolm"]],
options[["postHocCorrectionSidak"]])
if (sum(wantsCorrections) == 0)
wantsCorrections <- "none"
postHocCorrections <- c("tukey", "scheffe", "bonferroni", "holm", "sidak")[wantsCorrections]

## Computation
Expand Down
3 changes: 2 additions & 1 deletion R/anovarepeatedmeasures.R
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,9 @@ AnovaRepeatedMeasuresInternal <- function(jaspResults, dataset = NULL, options)
thisVarName <- paste(postHocVariables[[postHocVarIndex]], collapse = ":")
byVariable <- if (options[["postHocConditionalTable"]] && length(postHocVariables[[postHocVarIndex]]) > 1) postHocVariables[[postHocVarIndex]] else NULL
termsToLoop <- if (options[["postHocConditionalTable"]]) postHocVariables[[postHocVarIndex]] else 1
dfType <- if (options[["poolErrorTermFollowup"]] && (length(postHocVariables[[postHocVarIndex]]) > 1)) "number" else "integer"
for (termIndex in seq_along(termsToLoop))
postHocContainer[[ paste0(thisVarName, termIndex)]] <- .createPostHocStandardTable(thisTitle, byVariable[termIndex], options)
postHocContainer[[ paste0(thisVarName, termIndex)]] <- .createPostHocStandardTable(thisTitle, byVariable[termIndex], options, dfType = dfType)

if (options[["postHocLetterTable"]]) {
letterTable <- createJaspTable(title = paste0("Letter-Based Grouping - ", thisVarName))
Expand Down
3 changes: 2 additions & 1 deletion R/commonAnovaFreq.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
return(coefTable)
}

.createPostHocStandardTable <- function(myTitle, byVariable = NULL, options, makeBootstrapTable = FALSE) {
.createPostHocStandardTable <- function(myTitle, byVariable = NULL, options, makeBootstrapTable = FALSE, dfType = "integer") {

preTitle <- if (!makeBootstrapTable) gettext("Post Hoc Comparisons - ") else gettext("Bootstrapped Post Hoc Comparisons - ")
postHocTable <- createJaspTable(title = paste0(preTitle, myTitle)) #this paste is ok
Expand All @@ -92,6 +92,7 @@
}

postHocTable$addColumnInfo(name="SE", title=gettext("SE"), type="number")
postHocTable$addColumnInfo(name="df", title=gettext("df"), type = dfType)

if (makeBootstrapTable)
postHocTable$addColumnInfo(name="bias", title=gettext("bias"), type="number")
Expand Down
2 changes: 1 addition & 1 deletion inst/help/Ancova.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ANCOVA allows the user to analyze the difference between multiple group means, w
### Post Hoc Tests
- To perform a post hoc test, drag one or more factor names to the right column. Several options are available:
- Type: Different types of post hoc tests can be selected.
- Standard (LSD): Pairwise t-tests are performed. All the corrections can be applied to this method. This option is selected by default.
- Standard: Pairwise t-tests are performed. All the corrections can be applied to this method. When Tukey's p-value correction is selected, this is equivalent to Tukey's HSD. This option is selected by default.
- Confidence intervals: When this option is selected, the confidence interval for the mean difference is calculated. This is done for every post hoc method except for Dunn. By default this is set to 95% but this can be adjusted into the desired percentage.
- From `...` bootstraps: By selecting this option, the bootstrapped post hoc test is applied. By default, the number of replications is set to 1000. This can be changed into the desired number.
- Effect size: By selecting this option, the effect size (i.e., the magnitude of the observed effect) will be displayed. The used measure for the effect size is Cohen's d. The effect size will only be displayed for the post hoc type `Standard`.
Expand Down
2 changes: 1 addition & 1 deletion inst/help/Ancova_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Met een ANCOVA kan men het verschil tussen meerdere groepsgemiddelden analyseren
- Bonferroni: Deze correctie wordt gezien als vrij conservatief. Het risico op een type 1 fout wordt verminderd, maar de statistische kracht (power) wordt ook lager.
- Holm: Deze methode wordt ook wel sequentiële Bonferroni genoemd, en wordt gezien als minder conservatief dan de Bonferroni methode.
- Type: Er kunnen verschillende typen post-hoc toetsen worden geselecteerd.
- Standaard (LSD): Paarsgewijze t-toetsen worden uitgevoerd. Alle correcties kunnen op deze methode worden toegepast. Dit is de standaardoptie.
- Standaard: Paarsgewijze t-toetsen worden uitgevoerd. Alle correcties kunnen op deze methode worden toegepast. Als Tukey's p-waarde correctie is geselecteerd, is dit equivalent aan Tukey's HSD. Dit is de standaardoptie.
- Games-Howell: Deze methode kan worden gebruikt wanneer groeps-/niveauvarianties niet gelijk zijn. De p-waarden worden gecorrigeerd met de Tukey methode.
- Dunett: Als u deze methode selecteert, worden alle niveaus vergeleken met een specifiek niveau, bijvoorbeeld met de controlegroep. Momenteel is het nog niet mogelijk om handmatig te specificeren met welk niveau de andere niveaus worden vergeleken, maar dit is gebaseerd op de volgorde van de niveaus. Om de volgorde aan te passen kunnen de niveaulabels worden veranderd.
<details>
Expand Down
2 changes: 1 addition & 1 deletion inst/help/Anova.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ANOVA allows the user to analyze the difference between multiple group means.
### Post Hoc Tests
- To perform a post hoc test, drag one or more factor names to the right column. Several options are available:
- Type: Different types of post hoc tests can be selected.
- Standard (LSD): Pairwise t-tests are performed. All the corrections can be applied to this method. This option is selected by default.
- Standard: Pairwise t-tests are performed. All the corrections can be applied to this method. When Tukey's p-value correction is selected, this is equivalent to Tukey's HSD. This option is selected by default.
- Confidence intervals: When this option is selected, the confidence interval for the mean difference is calculated. This is done for every post hoc method except for Dunn. By default this is set to 95% but this can be adjusted into the desired percentage.
- From `...` bootstraps: By selecting this option, the bootstrapped post hoc test is applied. By default, the number of replications is set to 1000. This can be changed into the desired number.
- Effect size: By selecting this option, the effect size (i.e., the magnitude of the observed effect) will be displayed. The used measure for the effect size is Cohen's d. The effect size will only be displayed for the post hoc type `Standard`.
Expand Down
2 changes: 1 addition & 1 deletion inst/help/Anova_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Met een ANOVA berekent men het verschil tussen meerdere groepsgemiddelden.
- Bonferroni: Deze correctie wordt gezien als vrij conservatief. Het risico op een type 1 fout wordt verminderd, maar statistische kracht (power) wordt ook lager.
- Holm: Deze methode wordt ook wel sequentiële Bonferroni genoemd, en wordt gezien als minder conservatief dan de Bonferroni methode.
- Type: Er kunnen verschillende typen post-hoc toets worden geselecteerd.
- Standaard (LSD): Paarsgewijze t-toetsen worden uitgevoerd. Alle correcties kunnen op deze methode worden toegepast. Dit is de standaardoptie.
- Standaard: Paarsgewijze t-toetsen worden uitgevoerd. Alle correcties kunnen op deze methode worden toegepast. Als Tukey's p-waarde correctie is geselecteerd, is dit equivalent aan Tukey's HSD. Dit is de standaardoptie.
- Games-Howell: Deze methode kan worden gebruikt wanneer groeps-/niveauvarianties niet gelijk zijn. De p-waarden worden gecorrigeerd met de Tukey methode.
- Dunett: Als u deze methode selecteert, worden alle niveaus vergeleken met een specifiek niveau, bijvoorbeeld met de controlegroep. Momenteel is het nog niet mogelijk om handmatig te specificeren met welk niveau de andere niveaus worden vergeleken, maar dit is gebaseerd op de volgorde van de niveaus. Om de volgorde aan te passen, kunnen de niveaulabels worden veranderd.
<details>
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ test_that("Post Hoc table results match", {
jaspTools::expect_equal_tables(table,
list("TRUE", 0.21391801479091, 0.698555762823947, -0.0779045273305165,
-0.476129796984023, 0.32032074232299, "control", "experimental",
-0.0830902357515325, 0.698555762823947, -0.507658279613134,
-0.0830902357515325, 0.698555762823947, -0.507658279613134, 97,
0.698555762823947, 0.698555762823947, -0.388420937024623, 0.698555762823947,
0.341477808110069)
)
Expand Down Expand Up @@ -354,9 +354,9 @@ test_that("Field - Chapter 6 results match", {
table <- results$results$anovaContainer$collection$anovaContainer_postHocContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer$collection[[1]]$data
jaspTools::expect_equal_tables(table,
list("TRUE", 0.538336190074754, -0.0194100366350722, 1, 2, -1.78324124481148,
-2.83630538964887, 0.129983128349044, -2.1023947223315, -0.858078871455782,
"FALSE", 0.763324066789791, -0.0155779657803694, 1, 3, -2.18556663740395,
-3.97107607430337, 0.0302155022603601, -2.77136409916095, -0.844312084720958,
-2.83630538964887, 0.129983128349044, -2.1023947223315, -0.858078871455782,26,
"FALSE", 0.763324066789791, -0.0155779657803694, 1, 3, -2.18556663740395, 26,
-3.97107607430337, 0.0302155022603601, -2.77136409916095, -0.844312084720958,26,
"FALSE", 0.775278163963213, 0.00383207085470289, 2, 3, -0.410252544853603,
-2.12122714048355, 0.932499470707816, -0.541407321622228, 0.972524781215359
))
Expand Down
39 changes: 20 additions & 19 deletions tests/testthat/test-anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ test_that("Post Hoc table results match", {
table <- results$results$anovaContainer$collection$anovaContainer_postHocContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer_contBinom$data
jaspTools::expect_equal_tables(table,
list("TRUE", 0.214904085649005, 0.448976320466698, 0.15401876311258,
-0.24864690950018, 0.55668443572534, 0, 1, 0.163364220743842,
-0.24864690950018, 0.55668443572534, 0, 1, 0.163364220743842, 98,
0.448976320466698, -0.263105943067512, 0.448976320466698, 0.448976320466698,
0.760172707980336, 0.448976320466698, 0.589834384555196)
)
Expand Down Expand Up @@ -507,11 +507,12 @@ test_that("Post Hoc Comparisons - Species table results match and contrast names
table <- results[["results"]][["anovaContainer"]][["collection"]][["anovaContainer_postHocContainer"]][["collection"]][["anovaContainer_postHocContainer_postHocStandardContainer"]][["collection"]][["anovaContainer_postHocContainer_postHocStandardContainer_Species1"]][["data"]]
jaspTools::expect_equal_tables(table,
list("TRUE", 0.286589136802729, "First species", "Second species",
-1.6, -5.58290526239083, 0.000324812090923943, "FALSE", 0.286589136802729,
"First species", "Third species", -1.54, -5.37354631505117,
0.000453440993214982, "FALSE", 0.286589136802729, "Second species",
"Third species", 0.0599999999999998, 0.209358947339655, 0.976174158311121
))
12, -1.6, -5.58290526239083, 0.000324812090923943, "FALSE",
0.286589136802729, "First species", "Third species", 12, -1.54,
-5.37354631505117, 0.000453440993215093, "FALSE", 0.286589136802729,
"Second species", "Third species", 12, 0.0600000000000003, 0.209358947339657,
0.97617415831112)
)

# following https://github.com/jasp-stats/jasp-issues/issues/1295, assert that these names do not contain commas.
contrast_A <- vapply(table, `[[`, "contrast_A", FUN.VALUE = character(1L))
Expand Down Expand Up @@ -581,11 +582,11 @@ test_that("Field - Chapter 5 results match", {
# standard post hoc (tukey)
table <- results[["results"]]$anovaContainer$collection$anovaContainer_postHocContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer_Dose$data
jaspTools::expect_equal_tables(table,
list("TRUE", 0.886942313043338, 1, 2, -1, -3.36624115850686, -1.12746904200424,
0.516276123508473, 1.36624115850686, "FALSE", 0.886942313043338,
1, 3, -2.8, -5.16624115850687, -3.15691331761188, 0.0209243994922408,
-0.433758841493136, "FALSE", 0.886942313043338, 2, 3, -1.8,
-4.16624115850686, -2.02944427560764, 0.147457622995377, 0.566241158506864
list("TRUE", 0.886942313043338, 1, 2, 12, -1, -3.36624115850687, -1.12746904200424,
0.516276123508473, 1.36624115850687, "FALSE", 0.886942313043338,
1, 3, 12, -2.8, -5.16624115850687, -3.15691331761188, 0.020924399492241,
-0.433758841493132, "FALSE", 0.886942313043338, 2, 3, 12, -1.8,
-4.16624115850687, -2.02944427560764, 0.147457622995377, 0.566241158506867
))

# games-howell post hoc
Expand Down Expand Up @@ -658,14 +659,14 @@ test_that("Field - Chapter 7 results match", {
# removed both post hoc table and contrast table because bootstrap results are now in same table
table <- results[["results"]]$anovaContainer$collection$anovaContainer_postHocContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer$collection$anovaContainer_postHocContainer_postHocStandardContainer_Alcohol$data
jaspTools::expect_equal_tables(table,
list("TRUE", 0.392000159227314, -0.00376914898826786, 0.230950085511107,
0, 1, -0.769579725829724, -1.48733254329573, -1.8129965586672,
0.177726007657148, 0.0548973391001529, "FALSE", 0.435378856593833,
0.0142934574412505, 0.00359956767679779, 0, 2, -1.43536324786325,
-2.31465226049576, -3.47491007077881, 0.00337043014651417, -0.602581004497449,
"FALSE", 0.407611902363181, 0.0180626064295184, 0.311931949521,
1, 2, -0.690674603174603, -1.43846891737073, -1.66191351211161,
0.231712504393661, 0.214248742598683))
list("TRUE", 0.392000159227314, -0.00376914898826863, 0.230950085511108,
0, 1, 42, -0.769579725829724, -1.48733254329573, -1.8129965586672,
0.177726007657148, 0.0548973391001528, "FALSE", 0.435378856593833,
0.014293457441249, 0.00359956767679781, 0, 2, 42, -1.43536324786325,
-2.31465226049576, -3.47491007077881, 0.00337043014651439, -0.602581004497448,
"FALSE", 0.407611902363181, 0.0180626064295178, 0.311931949521002,
1, 2, 42, -0.690674603174603, -1.43846891737072, -1.6619135121116,
0.231712504393662, 0.214248742598684))


table <- results[["results"]]$anovaContainer$collection$anovaContainer_marginalMeansContainer$collection[[1]]$data
Expand Down
Loading
Loading