Skip to content

Commit d553edf

Browse files
JTPetterCopilot
andauthored
Minor issues (jasp-stats#475)
* Fix minor issues * Remove double dependencies Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Improve error message * Additional review comments * fix unit tests * update lockfile * lockfile from master --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a8b6b76 commit d553edf

29 files changed

Lines changed: 603 additions & 521 deletions

R/doeAnalysis.R

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@
4141
# avoid e-notation for small-to-moderate numbers
4242
mag <- floor(log10(absVal))
4343
sigDigits <- max(digits, mag + 1 + digits)
44-
trimws(formatC(val, digits = sigDigits, format = "g", drop0trailing = TRUE))
44+
formatted <- trimws(formatC(val, digits = sigDigits, format = "g", drop0trailing = TRUE))
4545
} else {
46-
trimws(formatC(val, digits = digits, format = "g", drop0trailing = TRUE))
46+
formatted <- trimws(formatC(val, digits = digits, format = "g", drop0trailing = TRUE))
4747
}
48+
sub("^-", "\u2013", formatted)
4849
}, character(1))
4950
}
5051

@@ -1527,7 +1528,7 @@ get_levels <- function(var, num_levels, dataset) {
15271528
return()
15281529
}
15291530

1530-
tb <- createJaspTable(gettext("ANOVA"))
1531+
tb <- createJaspTable(gettext("Analysis of Variance"))
15311532
tb$addColumnInfo(name = "terms", title = gettext("Source"), type = "string")
15321533
tb$addColumnInfo(name = "adjss", title = gettext("Sum of squares"), type = "number")
15331534
tb$addColumnInfo(name = "df", title = gettext("df"), type = "integer")
@@ -1967,6 +1968,16 @@ get_levels <- function(var, num_levels, dataset) {
19671968
plotTitle <- gettextf("%1$s of %2$s vs %3$s", plotTypeString, dep, variablePairString)
19681969
plot <- createJaspPlot(title = plotTitle, width = 560, height = 460)
19691970
result <- jaspResults[[dep]][["doeResult"]]$object[["regression"]]
1971+
modelVars <- all.vars(attr(stats::terms(result[["object"]]), "variables"))
1972+
missingVars <- setdiff(variablePair, modelVars)
1973+
if (length(missingVars) > 0) {
1974+
plot$setError(gettextf(
1975+
"Could not plot because the following selected variable(s) were not included in the final model: %1$s. They might have been removed during model selection.",
1976+
paste(missingVars, collapse = ", ")
1977+
))
1978+
jaspResults[[dep]][["contourSurfacePlot"]][[plotTitle]] <- plot
1979+
next
1980+
}
19701981
if (plotType == "contourPlot") {
19711982
plot$plotObject <- .doeContourPlotObject(result, options, dep, variablePair)
19721983
} else if (plotType == "surfacePlot") {

R/msaGaugeRR.R

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) {
250250
# Gauge r&R ANOVA Table
251251
if (options[["anova"]]) {
252252
if (is.null(jaspResults[["gaugeANOVA"]])) {
253-
jaspResults[["gaugeANOVA"]] <- createJaspContainer(gettext("Gauge r&R ANOVA table"))
254-
jaspResults[["gaugeANOVA"]]$dependOn(c("processVariationReference", "historicalSdValue", "report"))
253+
jaspResults[["gaugeANOVA"]] <- createJaspContainer(gettext("Gauge r&R Analysis of Variance table"))
254+
jaspResults[["gaugeANOVA"]]$dependOn(c("processVariationReference", "historicalSdValue", "report", "anova"))
255255
jaspResults[["gaugeANOVA"]]$position <- 1
256256
}
257257
jaspResults[["gaugeANOVA"]] <- .gaugeANOVA(dataset = dataset, measurements = measurements, parts = parts, operators = operators, options = options, ready = ready, Type3 = Type3)
@@ -334,7 +334,11 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) {
334334
if(options[["trafficLightChart"]] & is.null(jaspResults[["trafficPlot"]] )) {
335335
jaspResults[["trafficPlot"]] <- createJaspContainer(gettext("Traffic light chart"))
336336
jaspResults[["trafficPlot"]]$position <- 9
337-
jaspResults[["trafficPlot"]]$dependOn(c("trafficLightChart", "toleranceValue", "tolerance", "gaugeRRmethod", "processVariationReference", "historicalSdValue", "report"))
337+
jaspResults[["trafficPlot"]]$dependOn(c("trafficLightChart", "toleranceValue", "tolerance", "gaugeRRmethod",
338+
"processVariationReference", "historicalSdValue", "studyVarianceMultiplierType",
339+
"studyVarianceMultiplierValue", "measurementLongFormat", "operatorLongFormat",
340+
"partLongFormat", "measurementsWideFormat", "operatorWideFormat",
341+
"partWideFormat", "dataFormat", "type3", "report"))
338342
trafficContainer <- jaspResults[["trafficPlot"]]
339343

340344
valuesVec <- .gaugeANOVA(dataset = dataset, measurements = measurements, parts = parts, operators = operators, options = options, ready = ready, returnTrafficValues = TRUE, Type3 = Type3)
@@ -348,11 +352,11 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) {
348352

349353
.gaugeANOVA <- function(dataset, measurements, parts, operators, options, ready, returnPlotOnly = FALSE, returnTrafficValues = FALSE,
350354
gaugeEvaluationDfOnly = FALSE, Type3 = FALSE) {
351-
anovaTables <- createJaspContainer(gettext("Gauge r&R study - crossed ANOVA"))
355+
anovaTables <- createJaspContainer(gettext("Gauge r&R study - crossed Analysis of Variance"))
352356
anovaTables$dependOn(c("anova", "gaugeRRmethod", "report"))
353357
anovaTables$position <- 1
354358

355-
anovaTable1 <- createJaspTable(title = ifelse(Type3, gettext("One-way ANOVA table"), gettext("Two-way ANOVA table with interaction")))
359+
anovaTable1 <- createJaspTable(title = ifelse(Type3, gettext("One-way Analysis of Variance table"), gettext("Two-way Analysis of Variance table with interaction")))
356360
anovaTable1$addColumnInfo(title = gettext("Source"), name = "source", type = "string" )
357361
anovaTable1$addColumnInfo(title = gettext("df"), name = "Df", type = "integer")
358362
anovaTable1$addColumnInfo(title = gettext("Sum of squares"), name = "Sum Sq", type = "number")
@@ -569,7 +573,7 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) {
569573

570574
} else {
571575

572-
anovaTable2 <- createJaspTable(title = gettext("Two-way ANOVA table without interaction"))
576+
anovaTable2 <- createJaspTable(title = gettext("Two-way Analysis of Variance table without interaction"))
573577
anovaTable2$addColumnInfo(title = gettext("Source"), name = "source", type = "string" )
574578
anovaTable2$addColumnInfo(title = gettext("df"), name = "Df", type = "integer")
575579
anovaTable2$addColumnInfo(title = gettext("Sum of squares"), name = "Sum Sq", type = "number")
@@ -904,32 +908,35 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) {
904908
}
905909

906910
.gaugeVarCompGraph <- function(percentContributionValues, studyVariationValues, percentToleranceValues, Type3 = FALSE) {
907-
sources <- gettext(c('Gauge r&R', 'Repeat', 'Reprod', 'Part-to-part'))
911+
sourceIds <- c("gaugeRR", "repeatability", "reproducibility", "partToPart")
912+
sources <- gettext(c("Gauge r&R", "Repeatability", "Reproducibility", "Part-to-part"))
908913
if (!all(is.na(percentToleranceValues))) {
909914
references <- gettextf(c('%% Contribution', '%% Study variation', '%% Tolerance'))
910915
values <- c(percentContributionValues, studyVariationValues, percentToleranceValues)
911916
} else {
912917
references <- gettextf(c('%% Contribution', '%% Study Variation'))
913918
values <- c(percentContributionValues, studyVariationValues)
914919
}
915-
plotframe <- data.frame(source = rep(sources, length(references)),
920+
plotframe <- data.frame(sourceId = rep(sourceIds, length(references)),
921+
source = rep(sources, length(references)),
916922
reference = rep(references, each = 4),
917-
value = values)
923+
value = values)
918924
plotframe$source <- factor(plotframe$source, levels = sources)
919925
yBreaks <- jaspGraphs::getPrettyAxisBreaks(c(0, plotframe$value))
920926

921927

922928
if (Type3)
923-
plotframe <- subset(plotframe, source != "Reprod")
929+
plotframe <- subset(plotframe, sourceId != "reproducibility")
924930

925931
p <- ggplot2::ggplot() +
926932
ggplot2::geom_bar(data = plotframe, mapping = ggplot2::aes(fill = reference, y = value, x = source),
927933
position="dodge", stat = "identity") +
928934
jaspGraphs::themeJaspRaw() +
929935
jaspGraphs::geom_rangeframe() +
930-
ggplot2::theme(legend.position = 'right', legend.title = ggplot2::element_blank()) +
936+
ggplot2::theme(legend.position = "right", legend.title = ggplot2::element_blank(),
937+
plot.margin = ggplot2::margin(5.5, 30, 5.5, 5.5, "pt")) +
931938
ggplot2::xlab(NULL) +
932-
ggplot2::scale_y_continuous(name = "Percent", breaks = yBreaks, limits = range(c(yBreaks, plotframe$value)))
939+
ggplot2::scale_y_continuous(name = gettext("Percent"), breaks = yBreaks, limits = range(c(yBreaks, plotframe$value)))
933940
return(p)
934941
}
935942

R/msaGaugeRRnonrep.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,19 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
267267
jaspResults[["trafficLightChart"]] <- .trafficplot(StudyVar = percentMSVar, ToleranceUsed = options[["tolerance"]],
268268
ToleranceVar = percentMSTolerance, options = options,
269269
ready = ready)
270-
jaspResults[["trafficLightChart"]]$dependOn(c("trafficLightChart", "report"))
270+
jaspResults[["trafficLightChart"]]$dependOn(c("trafficLightChart", "report", "processVariationReference",
271+
"historicalSdValue", "tolerance", "toleranceValue",
272+
"studyVarianceMultiplierType", "studyVarianceMultiplierValue",
273+
"measurementLongFormat", "operatorLongFormat", "partLongFormat",
274+
"measurementsWideFormat", "operatorWideFormat", "partWideFormat",
275+
"dataFormat"))
271276
}
272277
}
273278
}
274279

275280
.gaugeRRNonRep <- function(dataset, measurements, parts, operators, options, ready, plotOnly = FALSE, trafficPlotValuesOnly = FALSE,
276281
gaugeEvaluationDfOnly = FALSE) {
277-
gaugeRRNonRepTables <- createJaspContainer(gettext("Gauge r&R study - nested ANOVA"))
282+
gaugeRRNonRepTables <- createJaspContainer(gettext("Gauge r&R study - nested Analysis of Variance"))
278283
gaugeRRNonRepTables$position <- 1
279284

280285
gaugeRRNonRepTable1 <- createJaspTable(title = gettext("Gauge r&R (nested)"))

R/msaTestRetest.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ msaTestRetest <- function(jaspResults, dataset, options, ...) {
107107
if(options[["trafficLightChart"]] && is.null(jaspResults[["trafficPlot"]] )) {
108108
jaspResults[["trafficPlot"]] <- createJaspContainer(gettext("Traffic light chart"))
109109
jaspResults[["trafficPlot"]]$position <- 4
110-
jaspResults[["trafficPlot"]]$dependOn(c("trafficLightChart", "manualProcessSdValue", "manualProcessSd", "toleranceValue", "tolerance"))
110+
jaspResults[["trafficPlot"]]$dependOn(c(
111+
"trafficLightChart", "manualProcessSdValue", "manualProcessSd",
112+
"toleranceValue", "tolerance",
113+
"measurementLongFormat", "measurementsWideFormat",
114+
"partLongFormat", "partWideFormat",
115+
"operator", "dataFormat"
116+
))
111117
TrafficContainer <- jaspResults[["trafficPlot"]]
112118

113119
valuesVec <- .rAndRtableRange(dataset = dataset, measurements = measurements, parts = parts, operators = operators, options = options, jaspResults, ready = ready, GRRpercent = TRUE)

inst/help/attributesCharts.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ In the case that the data of the individual and moving Range chart (X-mR chart)
6060

6161
- Duncan, A.J. (1986), *Quality control and industrial statistics*, Richard D. Irwin, Inc.
6262
- Automotive Industry Action Group, *Statistical Process Control – Reference Manual* (July 2005, 2nd Edition)
63-
- SKF Quality Techniques, Klerx, R., Dodson, B., and Dumont, D., QT 1 – *Process capability studies* (PUB GQ/P9 10347/1 EN – December 2021)
64-
- SKF Quality Techniques, Dodson, B., Lynch, D., Weidenbacher, M., and Klerx, R., QT 2 – *Statistical process control* (PUB GQS/P9 18343 EN – April 2019)
6563
- International Organization for Standardization, *Control charts – Part 2: Shewhart control charts*, ISO 7870-2:2023 (E)
6664

6765

inst/help/doeAnalysis.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@ A response surface design is an experimental framework used to optimize and unde
1818

1919
### Assignment box
2020
- Response: The measured outcome variable of the process under investigation.
21-
- Discrete predictors: The columns corresponding to the discrete predictors in the design.
22-
- Continuous predictors: The columns corresponding to the continuous predictors in the design.
23-
- Covariates: The columns corresponding to the covariates in the design. The difference between a covariate and a continuous predictor is that the covariate will not be analysed for interaction effects and excluded from effect plots.
24-
- Blocks: The columns corresponding to the blocks in the design. The difference between a block variable and a discrete predictor is that the blocks will not be analysed for interaction effects and excluded from effect plots.
21+
- Discrete factors: The columns corresponding to the discrete factors in the design.
22+
- Continuous factors: The columns corresponding to the continuous factors in the design.
23+
- Covariates: The columns corresponding to the covariates in the design. The difference between a covariate and a continuous factor is that the covariate will not be analysed for interaction effects and excluded from effect plots.
24+
- Blocks: The columns corresponding to the blocks in the design. The difference between a block variable and a discrete factor is that the blocks will not be analysed for interaction effects and excluded from effect plots.
2525

2626
## Analysis options
2727
-------
2828

29-
### Predictor levels
30-
For the ordering of contrasts and to identify the alpha points in a response surface design, the low and high levels of all predictors need to be specified. There are two options to handle this.
29+
### Factor levels
30+
For the ordering of contrasts and to identify the alpha points in a response surface design, the low and high levels of all factors need to be specified. There are two options to handle this.
3131

32-
- Automatically detect low/high: Attempts to automatically detect the low and high levels by taking the minimum and maximum for continuous predictors, and by ordering discrete predictors alphabetically. For response surface designs, this might recognize alpha values as low/high levels. In this case, manual specification is needed.
32+
- Automatically detect low/high: Attempts to automatically detect the low and high levels by taking the minimum and maximum for continuous factors, and by ordering discrete factors alphabetically. For response surface designs, this might recognize alpha values as low/high levels. In this case, manual specification is needed.
3333

34-
- Manually specify low/high: Shows all predictors in the analysis to allow for manual specification of the low and high levels.
34+
- Manually specify low/high: Shows all factors in the analysis to allow for manual specification of the low and high levels.
3535

3636
### Other analysis options
3737

38-
- Use alias names: Check to assign alias names to predictors. Useful when predictors have long names.
38+
- Use alias names: Check to assign alias names to factors. Useful when factors have long names.
3939
- Show regression equation: Check to display the regression coefficients as an equation predicting the response.
40-
- Display result in coded units: Check to display the results in coded units. This means, all predictor levels are standardized between -1 and 1.
41-
- Show optimal response: Check to display the predictor levels yielding the optimal response.
40+
- Display result in coded units: Check to display the results in coded units. This means, all factor levels are standardized between -1 and 1.
41+
- Show optimal response: Check to display the factor levels yielding the optimal response.
4242

4343
## Model options
4444
-------

inst/help/doeResponseSurfaceMethodology.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ The Box-Behnken set-up consists of twelve "edge" points (shown as red dots) all
100100
-------
101101
- Dodson, L., Dodson, M., and Klerx, R. (2010), *A study of the hierarchical ordering principle and the effect heredity principle in factorial experimental designs*, 10th Annual Transaction of ENBIS (12 16 September 2010, Antwerp).
102102
- Box, G.E.P., and Wilson, K.B. (1951), On the experimental attainment of optimum conditions. *Journal of the Royal Statistical Society 13*(1), 1-45.
103-
- Dodson, B., Weidenbacher, M., Lynch D., and Klerx, R., QT 9 - Design and analysis of experiments. *SKF Quality Techniques*. (PUB GQS/P9 16083 EN - August 2015).
103+
- Automotive Industry Action Group (July 2005), *Statistical process control (SPC) – Reference manual*, AIAG.

inst/help/msaAttribute.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Data can be in the form of all observations in one column ("Single column") or a
3838
## References
3939
-------
4040
- Duncan, A.J. (1986), Quality control and industrial statistics, Richard D. Irwin, Inc., and Automotive Industry Action Group (July 2005), Statistical process control (SPC) – Reference manual, AIAG.
41-
- Dodson, B., Lynch, D., Weidenbacher, M., & Klerx, R. (2009).*Statistical process control handbook*. SKF group.
4241
## R Packages
4342
-------
4443
- jaspGraphs

inst/help/msaGaugeLinearity.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ bias (matching between measurements and reference values) of a system.
3131
## References
3232
-------
3333
- Duncan, A.J. (1986), Quality control and industrial statistics, Richard D. Irwin, Inc., and Automotive Industry Action Group (July 2005), Statistical process control (SPC) – Reference manual, AIAG.
34-
- Dodson, B., Lynch, D., Weidenbacher, M., & Klerx, R. (2009).*Statistical process control handbook*. SKF group.
3534

3635
## R Packages
3736
-------

inst/help/msaGaugeRR.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Data can be in the form of all observations in one column ("Single column") or a
1717

1818
### Gauge r&R Method
1919
The method used in the analysis.
20-
- ANOVA method: analysis is based on analysis of variance (ANOVA).
20+
- Analysis of Variance method: analysis is based on analysis of variance (ANOVA).
2121

22-
### Options (ANOVA method)
22+
### Options (Analysis of Variance method)
2323
#### Analysis options
2424
- Std.Deviation reference: either a historically known standard deviation (Historical process std.Deviation) or estimated from the data (Study std.Deviation).
2525
- Tolerance: include a value for tolerance.
26-
- r&R table ANOVA method: options for the ANOVA table.
26+
- r&R table Analysis of Variance method: options for the Analysis of Variance table.
2727
- Alpha interaction removal: value for alpha level.
2828
- Study Var. multiplier type: multiplier based on either Std.Deviation or Percent.
2929
- Study Var. multiplier value: value for the multiplier.
@@ -44,14 +44,13 @@ The method used in the analysis.
4444

4545
## Output
4646
-------
47-
- ANOVA Table: Two-way anova tables with and without interactions for the input variables, repeatability, reproducibility, and total Gauge r&R.
47+
- Analysis of Variance table: Two-way analysis of variance tables with and without interactions for the input variables, repeatability, reproducibility, and total Gauge r&R.
4848
- Gauge r&R Variance Components: variance and contribution in percentage of the input variables, repeatability, reproducibility, and total Gauge r&R.
4949
- Gauge Evaluation: the standard deviations, study variations, and percent of study variation and tolerance for input variables, repeatability, reproducibility, and total Gauge r&R.
5050

5151
## References
5252
-------
5353
- Duncan, A.J. (1986), Quality control and industrial statistics, Richard D. Irwin, Inc., and Automotive Industry Action Group (July 2005), Statistical process control (SPC) – Reference manual, AIAG.
54-
- Dodson, B., Lynch, D., Weidenbacher, M., & Klerx, R. (2009).*Statistical process control handbook*. SKF group.
5554

5655
## R Packages
5756
-------

0 commit comments

Comments
 (0)