Skip to content

Commit

Permalink
Fix post hoc issue (#384)
Browse files Browse the repository at this point in the history
* update footnote table and naming

* handle multiple post hoc tests when conditioning

* indicate missing p-values with dot
  • Loading branch information
JohnnyDoorn authored Sep 3, 2024
1 parent 7cf0037 commit fe668b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions R/ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -885,18 +885,18 @@ AncovaInternal <- function(jaspResults, dataset = NULL, options) {
}

if (options$postHocTypeStandard)
.anovaPostHocTable(postHocContainer, dataset, options, anovaContainer[["model"]]$object, anovaContainer[["afexModel"]]$object)
.anovaStandardPostHocTable(postHocContainer, dataset, options, anovaContainer[["model"]]$object, anovaContainer[["afexModel"]]$object)

if (options$postHocTypeGames)
.anovaGamesTable(postHocContainer, dataset, options, anovaContainer[["model"]]$object)
.anovaGamesPostHocTable(postHocContainer, dataset, options, anovaContainer[["model"]]$object)

if (options$postHocTypeDunnet)
.anovaDunnettTable(postHocContainer, dataset, options, anovaContainer[["model"]]$object)
.anovaDunnettPostHocTable(postHocContainer, dataset, options, anovaContainer[["model"]]$object)

return()
}

.anovaPostHocTable <- function(postHocContainer, dataset, options, model, afexModel = NULL) {
.anovaStandardPostHocTable <- function(postHocContainer, dataset, options, model, afexModel = NULL) {
if (!is.null(postHocContainer[["postHocStandardContainer"]]))
return()

Expand Down Expand Up @@ -958,8 +958,8 @@ AncovaInternal <- function(jaspResults, dataset = NULL, options) {
isBetween = TRUE))
avFootnote <- attr(resultPostHoc[[1]], "mesg")[grep(attr(resultPostHoc[[1]], "mesg"), pattern = "Results are averaged")]
if (length(avFootnote) != 0) {
avTerms <- .unv(strsplit(gsub(avFootnote, pattern = "Results are averaged over the levels of: ", replacement = ""),
", ")[[1]])
avTerms <- strsplit(gsub(avFootnote, pattern = "Results are averaged over the levels of: ", replacement = ""),
", ")[[1]]
postHocStandardContainer[[thisVarNameRef]]$addFootnote(gettextf("Results are averaged over the levels of: %s", paste(avTerms, collapse = ", ")))
}
allPvalues <- do.call(cbind, lapply(resultPostHoc, function(x) x$p.value))
Expand Down Expand Up @@ -1098,7 +1098,7 @@ AncovaInternal <- function(jaspResults, dataset = NULL, options) {
}


.anovaGamesTable <- function(postHocContainer, dataset, options, model) {
.anovaGamesPostHocTable <- function(postHocContainer, dataset, options, model) {
if (!is.null(postHocContainer[["postHocGamesContainer"]]))
return()

Expand Down Expand Up @@ -1197,7 +1197,7 @@ AncovaInternal <- function(jaspResults, dataset = NULL, options) {
return()
}

.anovaDunnettTable <- function(postHocContainer, dataset, options, model) {
.anovaDunnettPostHocTable <- function(postHocContainer, dataset, options, model) {
if (!is.null(postHocContainer[["postHocDunnettContainer"]]))
return()

Expand Down
6 changes: 3 additions & 3 deletions R/anovarepeatedmeasures.R
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,8 @@ AnovaRepeatedMeasuresInternal <- function(jaspResults, dataset = NULL, options)

if (any(postHocVariables[[postHocVarIndex]] %in% allNames)) { ## If the variable is a repeated measures factor

resultPostHoc[["scheffe"]] <- ""
resultPostHoc[["tukey"]] <- ""
resultPostHoc[["scheffe"]] <- "."
resultPostHoc[["tukey"]] <- "."
if (options$postHocCorrectionScheffe || options$postHocCorrectionTukey) {
cors <- paste(c("Tukey", "Scheffe")[c(options$postHocCorrectionTukey, options$postHocCorrectionScheffe)], collapse = " and ")

Expand All @@ -1024,7 +1024,7 @@ AnovaRepeatedMeasuresInternal <- function(jaspResults, dataset = NULL, options)
postHocContainer[[thisVarNameRef]]$addFootnote(gettextf("Results are averaged over the levels of: %s", paste(avTerms, collapse = ", ")))
}

if (options[["postHocConditionalTable"]]) {
if (options[["postHocConditionalTable"]] & isFALSE(is.null(byVariable))) {
resultPostHoc[[".isNewGroup"]] <- !duplicated(resultPostHoc[[byVariable[termIndex]]])
} else {
resultPostHoc[[".isNewGroup"]] <- !duplicated(resultPostHoc[["contrast_A"]])
Expand Down
2 changes: 1 addition & 1 deletion R/commonAnovaFreq.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
confAdjust <- strsplit(confAdjust, " ")[[1]][1]

if (!includeCI) {
correctionFootnote <- gettextf("P-value adjusted for comparing a family of %s", as.character(nEstimates))
correctionFootnote <- gettextf("P-value adjusted for comparing a family of %s estimates.", as.character(nEstimates))
} else if (isFALSE(includeEffectSize) || isFALSE(isBetween)) {
correctionFootnote <- gettextf("P-value and confidence intervals adjusted for comparing a family of %1$s estimates (confidence intervals corrected using the %2$s method).", nEstimates, confAdjust)
} else {
Expand Down

0 comments on commit fe668b9

Please sign in to comment.