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

Instead of morey, make normalization optional #385

Merged
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
14 changes: 6 additions & 8 deletions R/commonAnovaBayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -1619,16 +1619,16 @@ BANOVAcomputMatchedInclusion <- function(effectNames, effects.matrix, interactio
plotErrorBars <- options$descriptivePlotCi
errorBarType <- "ci"
conf.interval <- options$descriptivePlotCiLevel
moreyCorrection <- TRUE
normalizeErrorBars <- TRUE
descriptivesPlotContainer$dependOn(c("dependent", "descriptivePlotCi", "descriptivePlotCiLevel"))

} else {
plotErrorBars <- options$descriptivePlotErrorBar
errorBarType <- options$descriptivePlotErrorBarType
conf.interval <- options$descriptivePlotCiLevel
moreyCorrection <- if (is.null(options[["applyMoreyCorrectionErrorBars"]])) FALSE else options[["applyMoreyCorrectionErrorBars"]]
normalizeErrorBars <- if (is.null(options[["normalizeErrorBarsDescriptives"]])) FALSE else options[["normalizeErrorBarsDescriptives"]]
descriptivesPlotContainer$dependOn(c("dependent", "descriptivePlotErrorBar", "descriptivePlotErrorBarType", "descriptivePlotCiLevel",
"descriptivePlotErrorBarPooled", "applyMoreyCorrectionErrorBars"))
"descriptivePlotErrorBarPooled", "normalizeErrorBarsDescriptives"))

}
usePooledSE <- if (is.null(options[["descriptivePlotErrorBarPooled"]])) FALSE else options[["descriptivePlotErrorBarPooled"]]
Expand All @@ -1653,7 +1653,7 @@ BANOVAcomputMatchedInclusion <- function(effectNames, effects.matrix, interactio
betweenSubjectFactors <- groupVars[groupVars %in% options$betweenSubjectFactors]
repeatedMeasuresFactors <- groupVars[groupVars %in% sapply(options$repeatedMeasuresFactors, `[[`, "name")]

if (length(repeatedMeasuresFactors) == 0) {
if (length(repeatedMeasuresFactors) == 0 || isFALSE(normalizeErrorBars)) {
summaryStat <- jaspTTests::.summarySE(as.data.frame(dataset), measurevar = dependent, groupvars = groupVars,
conf.interval = conf.interval, na.rm = TRUE, .drop = FALSE,
errorBarType = errorBarType, dependentName = .BANOVAdependentName,
Expand All @@ -1666,7 +1666,6 @@ BANOVAcomputMatchedInclusion <- function(effectNames, effects.matrix, interactio
conf.interval = conf.interval,
na.rm=TRUE, .drop = FALSE, errorBarType = errorBarType,
usePooledSE = usePooledSE,
useMoreyCorrection = moreyCorrection,
dependentName = .BANOVAdependentName,
subjectName = .BANOVAsubjectName)
}
Expand Down Expand Up @@ -1861,7 +1860,7 @@ BANOVAcomputMatchedInclusion <- function(effectNames, effects.matrix, interactio
"barPlotHorizontalZeroFix", "barPlotCiInterval", "usePooledStandErrorCITwo"))

usePooledSE <- if (is.null(options[["usePooledStandErrorCITwo"]])) FALSE else options[["usePooledStandErrorCITwo"]]
useMoreyCorrection <- if (is.null(options[["applyMoreyCorrectionErrorBarsBarplot"]])) TRUE else options[["applyMoreyCorrectionErrorBarsBarplot"]]
normalizeErrorBars <- if (is.null(options[["normalizeErrorBarsBarplot"]])) TRUE else options[["normalizeErrorBarsBarplot"]]

barPlotHorizontalZeroFix <- options[["barPlotHorizontalZeroFix"]]
barPlotContainer$dependOn(c("barPlotHorizontalAxis", "barPlotSeparatePlots", "labelYAxisTwo"))
Expand All @@ -1884,7 +1883,7 @@ BANOVAcomputMatchedInclusion <- function(effectNames, effects.matrix, interactio
betweenSubjectFactors <- groupVars[groupVars %in% options[["betweenSubjectFactors"]]]
repeatedMeasuresFactors <- groupVars[groupVars %in% sapply(options[["repeatedMeasuresFactors"]], `[[`, "name")]

if (length(repeatedMeasuresFactors) == 0) {
if (length(repeatedMeasuresFactors) == 0 || isFALSE(normalizeErrorBars)) {
summaryStat <- jaspTTests::.summarySE(as.data.frame(dataset), measurevar = dependent, groupvars = groupVars,
conf.interval = confInterval, na.rm = TRUE, .drop = FALSE,
errorBarType = errorBarType, dependentName = .BANOVAdependentName,
Expand All @@ -1897,7 +1896,6 @@ BANOVAcomputMatchedInclusion <- function(effectNames, effects.matrix, interactio
conf.interval = confInterval,
na.rm=TRUE, .drop = FALSE, errorBarType = errorBarType,
usePooledSE = usePooledSE,
useMoreyCorrection = useMoreyCorrection,
dependentName = .BANOVAdependentName,
subjectName = .BANOVAsubjectName)
}
Expand Down
2 changes: 1 addition & 1 deletion inst/help/AnovaRepeatedMeasures.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ To create a descriptive plot, select the repeated measures factor to be placed o
- Confidence interval: This option is selected by default. With this option, the error bars will represent confidence intervals of the mean of each level combination of the repeated measures factors. By default the confidence interval is set to 95%, but this can be changed into the desired percentage.
- Standard error: By selecting this option, the error bars will represent standard errors of the mean of each level combination of the repeated measures factor.
- Average across unused RM factors: When there are multiple RM factors in the model, but only plotting a subset of these factors, the mean is taken across the unused RM factors. For instance, when there are two RM factors with two levels in the model, A (1&2) and B (1&2), and only A is selected to be plotted, the average is taken of B across its levels. This means that when the mean of A1 is plotted, it is actually the average of A1B1 and A1B2). This procedure is discussed by Loftus & Masson (1994). When the box is not ticked, the averages are not taken, and the columns A1B1 and A1B2 are simply concatenated.
- Normalize error bars: In order to get accurate confidence intervals and standard errors, the data are normalized by subtracting the appropriate participantʹs mean performance from each observation, and then adding the grand mean score to every observation. The variances of the resulting normalized values in each condition, and thus the size of the bars, no longer depend on the participant effects and are therefore a more accurate representation of the experimental manipulation. See Morey (2008) for a thorough discussion of this procedure.
- Normalize error bars: In order to get accurate confidence intervals and standard errors for within subjects effects, the data are normalized by subtracting the appropriate participantʹs mean performance from each observation, and then adding the grand mean score to every observation. The variances of the resulting normalized values in each condition, and thus the size of the bars, no longer depend on the participant effects and are therefore a more accurate representation of the experimental manipulation. See Morey (2008) for a thorough discussion of this procedure. Recommended when visualizing within subjects effects, but not for between subjects effects.

### Bar Plots
- To create a bar plot, select the repeated measures factor to be placed on the horizontal axis. If there are more than one repeated measures factor, the variables can be displayed in separate plots by selecting the other variable in the box Separate plots.
Expand Down
2 changes: 1 addition & 1 deletion inst/qml/AnovaRepeatedMeasures.qml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Form
framework: form.framework
TextField { name: "labelYAxisTwo"; label: qsTr("Label y-axis"); fieldWidth: 200 }
CheckBox { name: "usePooledStandErrorCITwo"; label: qsTr("Average across unused RM factors") }
CheckBox { name: "applyMoreyCorrectionErrorBarsBarplot"; label: qsTr("Normalize error bars"); checked: true}
CheckBox { name: "normalizeErrorBarsBarplot"; label: qsTr("Normalize error bars"); checked: true}
}

Common.RainCloudPlots
Expand Down
2 changes: 1 addition & 1 deletion inst/qml/common/classical/DescriptivePlots.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Section

CheckBox
{
name: "applyMoreyCorrectionErrorBars"
name: "normalizeErrorBarsDescriptives"
label: qsTr("Normalize error bars")
checked: true
visible: analysis === Common.Type.Analysis.RMANOVA
Expand Down
Loading