Skip to content

Commit

Permalink
footnote influence when too extreme
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyDoorn committed Apr 11, 2024
1 parent 099711d commit dea6089
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions R/commonglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,10 @@
colInd <- c(colInd, optionToColInd(measure, nDFBETAS))
}

influenceResData <- as.data.frame(influenceRes[["infmat"]][, colInd])
tempResult <- influenceRes[["infmat"]][, colInd]
resultContainsNaN <- any(is.nan(tempResult))
tempResult[which(is.nan(tempResult))] <- NA
influenceResData <- as.data.frame(tempResult)
colnames(influenceResData)[1:length(colInd)] <- colNames[1:length(colInd)]

influenceResData[["caseN"]] <- seq.int(nrow(influenceResData))
Expand All @@ -857,17 +860,16 @@
# funky statement to ensure a df even if only 1 row
influenceResSig <- subset(influenceRes[["is.inf"]], 1:nrow(influenceResData) %in% index, select = colInd)
colnames(influenceResSig) <- colNames[1:length(colInd)]

influenceResData <- influenceResData[index, ]

if (length(index) == 0)
influenceTable$addFootnote(gettext("No influential cases found."))
else {
influenceTable$setData(influenceResData)
# if any other metrix show influence, add footnotes:
if (sum(influenceResSig) > 0) {
if (sum(influenceResSig, na.rm = TRUE) > 0) {
for (thisCol in colnames(influenceResSig)) {
if (sum(influenceResSig[, thisCol]) > 0)
if (sum(influenceResSig[, thisCol], na.rm = TRUE) > 0)
influenceTable$addFootnote(
gettext("Potentially influential case, according to the selected influence measure."),
colNames = thisCol,
Expand All @@ -876,6 +878,12 @@
)
}
}

if (resultContainsNaN) {
influenceTable$addFootnote(
gettext("Influence measures could not be computed for some cases due to extreme values, try another measure.")
)
}
}
}

Expand Down

0 comments on commit dea6089

Please sign in to comment.