Skip to content

Commit dfa16ac

Browse files
committed
add shapiro-francia as a separate option (for normal dist)
1 parent 6f80a10 commit dfa16ac

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

R/commonDiscoverDistributions.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@
417417
isTRUE(options[["andersonDarling"]]) ||
418418
isTRUE(options[["lillienfors"]]) ||
419419
isTRUE(options[["shapiroWilk"]]) ||
420+
isTRUE(options[["shapiroFrancia"]]) ||
420421
isTRUE(options[["chiSquare"]]) ||
421422
isTRUE(options[["estPDF"]]) ||
422423
isTRUE(options[["estPMF"]]) ||
@@ -522,7 +523,7 @@
522523
.ldFitStatisticsTable <- function(fitContainer, options, method){
523524
if(!is.null(fitContainer[['fitStatisticsTable']])) return()
524525

525-
allTests <- c("kolmogorovSmirnov", "cramerVonMisses", "andersonDarling", "lillienfors", "shapiroWilk", "chiSquare")
526+
allTests <- c("kolmogorovSmirnov", "cramerVonMisses", "andersonDarling", "lillienfors", "shapiroWilk", "shapiroFrancia", "chiSquare")
526527
optionsTests <- allTests %in% names(options)
527528
whichTests <- unlist(options[allTests[optionsTests]])
528529

@@ -550,7 +551,7 @@
550551
if(is.null(fit)) return()
551552
if(!is.null(fitContainer[['fitStatisticsResults']])) return(fitContainer[['fitStatisticsResults']]$object)
552553

553-
allTests <- c("kolmogorovSmirnov", "cramerVonMisses", "andersonDarling", "lillienfors", "shapiroWilk", "chiSquare")
554+
allTests <- c("kolmogorovSmirnov", "cramerVonMisses", "andersonDarling", "lillienfors", "shapiroWilk", "shapiroFrancia", "chiSquare")
554555
tests <- allTests[allTests %in% names(options)]
555556

556557
res <- data.frame(test = tests, statistic = numeric(length = length(tests)), p.value = numeric(length = length(tests)))
@@ -562,6 +563,7 @@
562563
"kolmogorovSmirnov" = c(list(x = variable, y = options$cdfFun), pars),
563564
"lillienfors" = list(x = variable),
564565
"shapiroWilk" = list(x = variable),
566+
"shapiroFrancia" = list(x = variable),
565567
"chiSquare" = list(x = as.numeric(table(variable)),
566568
p = do.call(options[['pdfFun']],
567569
utils::modifyList(pars,
@@ -577,7 +579,8 @@
577579
"cramerVonMisses" = goftest::cvm.test,
578580
"andersonDarling" = goftest::ad.test,
579581
"lillienfors" = nortest::lillie.test,
580-
"shapiroWilk" = nortest::sf.test,
582+
"shapiroWilk" = stats::shapiro.test,
583+
"shapiroFrancia" = nortest::sf.test,
581584
"chiSquare" = stats::chisq.test
582585
)
583586

@@ -593,13 +596,9 @@
593596
fun <- function(x) {
594597
return(list(statistic = NA, p.value = NA))
595598
}
596-
} else if (test == "shapiroWilk" && (length(variable) < 5 || length(variable) > 5000)) {
597-
fun <- stats::shapiro.test
598599
}
599600
} else {
600-
if (test == "shapiroWilk") {
601-
fun <- stats::shapiro.test
602-
} else if (test=="lillienfors") {
601+
if (test=="lillienfors") {
603602
fun <- function(x) {
604603
return(list(statistic = NA, p.value = NA))
605604
}
@@ -622,13 +621,14 @@
622621
if(is.null(table)) return()
623622

624623

625-
allTests <- c("kolmogorovSmirnov", "cramerVonMisses", "andersonDarling", "lillienfors", "shapiroWilk", "chiSquare")
624+
allTests <- c("kolmogorovSmirnov", "cramerVonMisses", "andersonDarling", "lillienfors", "shapiroWilk", "shapiroFrancia", "chiSquare")
626625
tests <- allTests[allTests %in% names(options)]
627626
testNames <- c(gettext("Kolmogorov-Smirnov"),
628627
gettext("Cramér-von Mises"),
629628
gettext("Anderson-Darling"),
630629
gettext("Lillienfors"),
631630
gettext("Shapiro-Wilk"),
631+
gettext("Shapiro-Francia"),
632632
gettext("Chi-square"))[allTests %in% names(options)]
633633

634634
whichTests <- unlist(options[tests])

inst/qml/LDgaussianunivariate.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ Form
107107

108108
LD.LDEstimateParameters { enabled: dataSetInfo.dataAvailable; includeUnbiased: true }
109109

110-
LD.LDAssessFit{ enabled: dataSetInfo.dataAvailable; includeShapiroWilk: true; includeLillienfors: true}
110+
LD.LDAssessFit{ enabled: dataSetInfo.dataAvailable; includeShapiro: true; includeLillienfors: true}
111111
}

inst/qml/common/LDAssessFit.qml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Section
2424
{
2525
property string distributionType : "continuous" // "counts" or "categorical"
2626
property bool includeLillienfors : false
27-
property bool includeShapiroWilk : false
27+
property bool includeShapiro : false
2828
property bool isDistributionContinuous : distributionType === "continuous"
2929

3030
title: enabled ? qsTr("Assess Fit") : qsTr("Assess Fit") + " - " + qsTr("[requires a loaded data set]")
@@ -86,8 +86,9 @@ Section
8686
CheckBox{ name: "kolmogorovSmirnov"; label: qsTr("Kolmogorov-Smirnov"); info: qsTr("Displays the Kolmogorov-Smirnov test") }
8787
CheckBox{ name: "cramerVonMisses"; label: qsTr("Cramér–von Mises"); info: qsTr("Displays the Cramér-von Mises test") }
8888
CheckBox{ name: "andersonDarling"; label: qsTr("Anderson-Darling"); info: qsTr("Displays the Anderson-Darling test") }
89-
CheckBox{ name: "lillienfors"; label: qsTr("Lillienfors"); info: qsTr("Displays the Lillienfors test"); visible: includeLillienfors }
90-
CheckBox{ name: "shapiroWilk"; label: qsTr("Shapiro-Wilk"); info: qsTr("Displays the Shapiro-Wilk test of normality"); visible: includeShapiroWilk }
89+
CheckBox{ name: "lillienfors"; label: qsTr("Lillienfors"); info: qsTr("Displays the Lillienfors test"); visible: includeLillienfors }
90+
CheckBox{ name: "shapiroWilk"; label: qsTr("Shapiro-Wilk"); info: qsTr("Displays the Shapiro-Wilk test of normality"); visible: includeShapiro }
91+
CheckBox{ name: "shapiroFrancia"; label: qsTr("Shapiro-Francia"); info: qsTr("Displays the Shapiro-Francia test of normality"); visible: includeShapiro }
9192
}
9293
}
9394

tests/testthat/test-ldgaussianunivariate.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ options$plotQF <- TRUE
2929
options$ppplot <- TRUE
3030
options$qqplot <- TRUE
3131
options$shapiroWilk <- TRUE
32+
options$shapiroFrancia <- TRUE
3233
options$qqPlotCi <- TRUE
3334
options$qqPlotCiLevel <- 0.95
3435
options$ppPlotCi <- TRUE
@@ -99,8 +100,8 @@ test_that("Fit Statistics table results match", {
99100
list(0.991407439010072, 0.0435417886558164, "Kolmogorov-Smirnov", 0.943808236870346,
100101
0.0222708494545493, "Cram<unicode>r-von Mises", 0.977570565641067,
101102
0.135493314971953, "Anderson-Darling", 0.912509972807986, 0.0435417886558163,
102-
"Lillienfors", 0.992785911992608, 0.996812818710274, "Shapiro-Wilk"
103-
))
103+
"Lillienfors", 0.994211531885928, 0.996119141722174, "Shapiro-Wilk",
104+
0.992785911992608, 0.996812818710274, "Shapiro-Francia"))
104105
})
105106

106107
test_that("P-P plot matches", {

0 commit comments

Comments
 (0)