diff --git a/R/linreg.b.R b/R/linreg.b.R index f58c1fd7..d9a77449 100644 --- a/R/linreg.b.R +++ b/R/linreg.b.R @@ -891,29 +891,22 @@ linRegClass <- R6::R6Class( mahalp <- as.numeric(self$options$mahalp) groups <- self$results$models termsAll <- private$.getModelTerms() -print(termsAll) -print(mahal) for (i in seq_along(termsAll)) { table <- groups$get(key=i)$dataSummary$mahal if (is.null(mahal[[i]])) { table$setNote("row", .("Mahalanobis distance can only be calculated for models with two or more independent variables.")) # setAnalysisNotice(self, .("Mahalanobis distance can only be calculated for models with two or more independent variables.")) - } else if (all(mahal[[i]]$p <= mahalp)) { - table$setNote( - "row", - jmvcore::format(.("There were no Mahalanobis distances with a threshold below p < {p}."), p = mahalp) - ) } else { - # select values below p-threshold (outliers) - selRow <- which(mahal[[i]]$p <= mahalp) - for (j in selRow) - table$addRow(rowKey = j, values = mahal[[i]][j, ]) - table$setNote( - "row", - jmvcore::format(.("Filter syntax: {filter}"), - filter = paste(paste0("ROW() != ", mahal[[i]][selRow, "row"]), collapse = " and ")) - ) + # select which rows contain values below p-threshold (outliers) + mahalRow <- mahal[[i]][mahal[[i]]$p <= mahalp, "row"] + mahalVal = list(mean = mean(mahal[[i]]$chisq), median = median(mahal[[i]]$chisq), sd = sd(mahal[[i]]$chisq), + min = min(mahal[[i]]$chisq), max = max(mahal[[i]]$chisq), excRow = paste(mahalRow, collapse = ", ")) + table$setRow(rowNo = 1, values = mahalVal) + table$setNote("excRow", + ifelse(length(mahalRow) == 0, + jmvcore::format(.("There were no Mahalanobis distances with a threshold below p < {p}."), p = mahalp), + jmvcore::format(.("Filter syntax: {filter}"), filter = paste(paste0("ROW() != ", mahalRow), collapse = " and ")))) } } }, diff --git a/R/linreg.h.R b/R/linreg.h.R index a8ed15bc..5d61b995 100644 --- a/R/linreg.h.R +++ b/R/linreg.h.R @@ -665,6 +665,7 @@ linRegResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class( options=options, name="mahal", title="Mahalanobis Distance", + rows=1, visible="(mahal)", clearWith=list( "dep", @@ -672,18 +673,31 @@ linRegResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class( "weights"), columns=list( list( - `name`="row", - `title`="Row", + `name`="mean", + `title`="Mean", `type`="number"), list( - `name`="chisq", - `title`="Statistics", + `name`="median", + `title`="Median", `type`="number"), list( - `name`="p", - `title`="p", + `name`="sd", + `title`="SD", + `type`="number"), + list( + `name`="min", + `title`="Min", + `type`="number", + `superTitle`="Range"), + list( + `name`="max", + `title`="Max", `type`="number", - `format`="zto,pvalue"))))}))$new(options=options)) + `superTitle`="Range"), + list( + `name`="excRow", + `title`="Participants (rows) below p-threshold", + `type`="text"))))}))$new(options=options)) self$add(R6::R6Class( inherit = jmvcore::Group, active = list( diff --git a/jamovi/linreg.r.yaml b/jamovi/linreg.r.yaml index 26652343..e3a9be24 100644 --- a/jamovi/linreg.r.yaml +++ b/jamovi/linreg.r.yaml @@ -273,6 +273,7 @@ items: - name: mahal title: Mahalanobis Distance type: Table + rows: 1 visible: (mahal) clearWith: - dep @@ -280,18 +281,31 @@ items: - weights columns: - - name: row - title: Row + - name: mean + title: Mean type: number - - name: chisq - title: Statistics + - name: median + title: Median type: number - - name: p - title: p + - name: sd + title: SD type: number - format: zto,pvalue + + - name: min + title: Min + type: number + superTitle: Range + + - name: max + title: Max + type: number + superTitle: Range + + - name: excRow + title: Participants (rows) below p-threshold + type: text - name: assump title: Assumption Checks