Skip to content

Commit

Permalink
Adjustable rules for gauge rr non rep
Browse files Browse the repository at this point in the history
  • Loading branch information
JTPetter committed Nov 8, 2024
1 parent 3c0176d commit c88d27b
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 12 deletions.
51 changes: 51 additions & 0 deletions R/commonQualityControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -1451,4 +1451,55 @@ KnownControlStats.RS <- function(N, sigma = 3) {
return(ruleList)
}

.getRuleListIndividualCharts <- function(options) {
ruleSet <- options[["testSet"]]
if (ruleSet == "jaspDefault") {
ruleList <- list("rule1" = list("enabled" = TRUE),
"rule2" = list("enabled" = TRUE, "k" = 7),
"rule3" = list("enabled" = TRUE, "k" = 7),
"rule4" = list("enabled" = TRUE, "k" = 14),
"rule5" = list("enabled" = TRUE, "k" = 2),
"rule6" = list("enabled" = TRUE, "k" = 4),
"rule7" = NULL,
"rule8" = NULL,
"rule9" = NULL
)
} else if (ruleSet == "nelsonLaws") {
ruleList <- list("rule1" = list("enabled" = TRUE),
"rule2" = list("enabled" = TRUE, "k" = 9),
"rule3" = list("enabled" = TRUE, "k" = 6),
"rule4" = list("enabled" = TRUE, "k" = 14),
"rule5" = list("enabled" = TRUE, "k" = 2),
"rule6" = list("enabled" = TRUE, "k" = 4),
"rule7" = list("enabled" = TRUE, "k" = 15),
"rule8" = list("enabled" = TRUE, "k" = 8),
"rule9" = NULL
)

} else if (ruleSet == "westernElectric") {
ruleList <- list("rule1" = list("enabled" = TRUE),
"rule2" = list("enabled" = TRUE, "k" = 8),
"rule3" = NULL,
"rule4" = NULL,
"rule5" = list("enabled" = TRUE, "k" = 2),
"rule6" = list("enabled" = TRUE, "k" = 4),
"rule7" = NULL,
"rule8" = NULL,
"rule9" = NULL
)
} else if (ruleSet == "custom") {
ruleList <- list("rule1" = list("enabled" = options[["rule1"]]),
"rule2" = list("enabled" = options[["rule2"]], "k" = options[["rule2Value"]]),
"rule3" = list("enabled" = options[["rule3"]], "k" = options[["rule3Value"]]),
"rule4" = list("enabled" = options[["rule4"]], "k" = options[["rule4Value"]]),
"rule5" = list("enabled" = options[["rule5"]], "k" = options[["rule5Value"]]),
"rule6" = list("enabled" = options[["rule6"]], "k" = options[["rule6Value"]]),
"rule7" = list("enabled" = options[["rule7"]], "k" = options[["rule7Value"]]),
"rule8" = list("enabled" = options[["rule8"]], "k" = options[["rule8Value"]]),
"rule9" = NULL
)
}
return(ruleList)
}


12 changes: 8 additions & 4 deletions R/msaGaugeRRnonrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
longMeasurementCols <- "Measurement"
}

# Get Rule List
if (ready)
ruleList <- .getRuleListSubgroupCharts(options)

# Report
if (options[["report"]]) {
nElements <- sum(options[["reportVariationComponents"]], options[["reportRChartByOperator"]], options[["reportMeasurementsByOperatorPlot"]],
Expand Down Expand Up @@ -120,7 +124,7 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
plotIndexCounter <- plotIndexCounter + 1
}
if (options[["reportRChartByOperator"]]) {
plots[[plotIndexCounter]] <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)],
plots[[plotIndexCounter]] <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)], ruleList = ruleList,
plotType = "R", stages = operators,
xAxisLabels = datasetWide[[parts]][order(datasetWide[[operators]])],
stagesSeparateCalculation = FALSE)$plotObject #R chart by operator
Expand All @@ -131,7 +135,7 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
plotIndexCounter <- plotIndexCounter + 1
}
if (options[["reportAverageChartByOperator"]]) {
plots[[plotIndexCounter]] <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)],
plots[[plotIndexCounter]] <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)], ruleList = ruleList,
plotType = "xBar", xBarSdType = "r", stages = operators,
xAxisLabels = datasetWide[[parts]][order(datasetWide[[operators]])],
stagesSeparateCalculation = FALSE)$plotObject #Average chart by operator
Expand Down Expand Up @@ -190,7 +194,7 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
jaspResults[["rChart"]][["plot"]] <- createJaspPlot(title = gettext("Range chart by operator"), width = 1200, height = 500)

if (ready) {
rChart <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)],
rChart <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)], ruleList = ruleList,
plotType = "R", stages = operators,
xAxisLabels = datasetWide[[parts]][order(datasetWide[[operators]])],
stagesSeparateCalculation = FALSE)
Expand All @@ -206,7 +210,7 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
jaspResults[["xBarChart"]]$dependOn(c("xBarChart", "measurementLongFormat", "measurementsWideFormat", "report"))
jaspResults[["xBarChart"]][["plot"]] <- createJaspPlot(title = gettext("Average chart by operator"), width = 1200, height = 500)
if (ready) {
xBarChart <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)],
xBarChart <- .controlChart(dataset = datasetWide[c(wideMeasurementCols, operators)], ruleList = ruleList,
plotType = "xBar", xBarSdType = "r", stages = operators,
xAxisLabels = datasetWide[[parts]][order(datasetWide[[operators]])],
stagesSeparateCalculation = FALSE)
Expand Down
160 changes: 160 additions & 0 deletions inst/qml/msaGaugeRRnonrep.qml
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,164 @@ Form
}
}
}

Section
{
title: qsTr("Advanced Options")
columns: 1

Group
{
title: qsTr("Tests for control charts")

DropDown
{
name: "testSet"
label: qsTr("Test set")
id: testSet
indexDefaultValue: 0
values: [
{ label: qsTr("JASP"), value: "jaspDefault"},
{ label: qsTr("Nelson laws"), value: "nelsonLaws"},
{ label: qsTr("Western Electric rules"), value: "westernElectric"},
{ label: qsTr("Custom selection"), value: "custom"}
]
}


CheckBox
{
name: "rule1"
label: qsTr("Points outside of control limits")
checked: true
enabled: testSet.currentValue == "custom"
}

CheckBox
{
name: "rule2"
label: ""
checked: true
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule2Value"
afterLabel: qsTr("points in a row, on the same side of center line")
fieldWidth: 25
defaultValue: testSet.currentValue == "nelsonLaws" ? 9 : testSet.currentValue == "westernElectric" ? 8 : 7
min: 2
}
}

CheckBox
{
name: "rule3"
label: ""
checked: testSet.currentValue != "westernElectric"
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule3Value"
afterLabel: qsTr("points in a row, all increasing or decreasing")
fieldWidth: 25
defaultValue: testSet.currentValue == "nelsonLaws" ? 6 : 7
min: 2
}
}

CheckBox
{
name: "rule4"
label: ""
checked: testSet.currentValue == "nelsonLaws" | testSet.currentValue == "custom"
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule4Value"
afterLabel: qsTr("points in a row, alternating increase and decrease")
fieldWidth: 25
defaultValue: 14
min: 2
}
}

CheckBox
{
name: "rule5"
label: ""
checked: testSet.currentValue != "jaspDefault"
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule5Value"
afterLabel: qsTr("out of k+1 points > 2 std. dev. from center line (same side)")
fieldWidth: 25
defaultValue: 2
min: 2
}
}

CheckBox
{
name: "rule6"
label: ""
checked: testSet.currentValue != "jaspDefault"
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule6Value"
afterLabel: qsTr("out of k+1 points > 1 std. dev. from center line (same side)")
fieldWidth: 25
defaultValue: 4
min: 2
}
}

CheckBox
{
name: "rule7"
label: ""
checked: testSet.currentValue == "nelsonLaws" | testSet.currentValue == "custom"
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule7Value"
afterLabel: qsTr("points in a row < 1 std. dev from center line (either side)")
fieldWidth: 25
defaultValue: 15
min: 2
}
}

CheckBox
{
name: "rule8"
label: ""
checked: testSet.currentValue == "nelsonLaws" | testSet.currentValue == "custom"
enabled: testSet.currentValue == "custom"
childrenOnSameRow: true

IntegerField
{
name: "rule8Value"
afterLabel: qsTr("points in a row > 1 std. dev from center line (either side)")
fieldWidth: 25
defaultValue: 8
min: 2
}
}
}
}
}
Loading

0 comments on commit c88d27b

Please sign in to comment.