Skip to content

Commit 8c33634

Browse files
authored
Unit test fix (#466)
* Remove mle.tools and adjust unit test pixel changes * Update tseries version * Update other relevant packages * update ragg * Delete diff viewer leftover * update more packages * Update all packages to latest version and fix issues * remove typo * update more packages * downgrade igraph because binaries not av * downgrade jaspTools
1 parent f81ea2d commit 8c33634

969 files changed

Lines changed: 1270 additions & 1149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
^.*\.Rproj$
44
^\.Rproj\.user$
55
^\examples$
6+
^\.positai$
7+
^\.claude$

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ renv/
6464
_processedLockFile.lock
6565

6666
.vscode/
67+
.positai

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Imports:
2828
jaspDescriptives,
2929
jaspGraphs,
3030
lubridate,
31-
mle.tools,
3231
psych,
3332
qcc,
3433
rsm,

R/TimeWeightedCharts.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ timeWeightedCharts <- function(jaspResults, dataset, options) {
5858
if ((!wideFormat && options[["subgroupSizeType"]] == "manual" &&
5959
any(lapply(split(dataset[[stages]], ceiling(seq_along(dataset[[stages]])/options[["manualSubgroupSizeValue"]])), FUN = function(x)length(unique(x))) > 1)) ||
6060
(!wideFormat && options[["subgroupSizeType"]] == "groupingVariable" &&
61-
any(table(dplyr::count_(dataset, vars = c(stages, subgroupVariable))[subgroupVariable]) > 1))) {
61+
any(table(dplyr::count(dataset, dplyr::across(dplyr::all_of(c(stages, subgroupVariable))))[[subgroupVariable]]) > 1))) {
6262
plotNotes <- paste0(plotNotes, gettext("One or more subgroups are assigned to more than one stage, only first stage is considered.<br>"))
6363
}
6464
if (anyNA(dataset[[stages]])) {

R/processCapabilityStudies.R

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ processCapabilityStudies <- function(jaspResults, dataset, options) {
5959
if ((!wideFormat && options[["subgroupSizeType"]] == "manual" &&
6060
any(lapply(split(dataset[[stages]], ceiling(seq_along(dataset[[stages]])/options[["manualSubgroupSizeValue"]])), FUN = function(x)length(unique(x))) > 1)) ||
6161
(!wideFormat && options[["subgroupSizeType"]] == "groupingVariable" &&
62-
any(table(dplyr::count_(dataset, vars = c(stages, subgroupVariable))[subgroupVariable]) > 1))) {
62+
any(table(dplyr::count(dataset, dplyr::across(dplyr::all_of(c(stages, subgroupVariable))))[[subgroupVariable]]) > 1))) {
6363
plotNotes <- paste0(plotNotes, gettext("One or more subgroups are assigned to more than one stage, only first stage is considered.<br>"))
6464
}
6565
if (anyNA(dataset[[stages]])) {
@@ -2703,6 +2703,37 @@ processCapabilityStudies <- function(jaspResults, dataset, options) {
27032703
return(plot)
27042704
}
27052705

2706+
.qcObservedVarcov <- function(logdensity, X, parms, mle) {
2707+
mle <- unlist(mle)
2708+
2709+
if (!all(parms %in% names(mle))) {
2710+
if (length(mle) != length(parms))
2711+
stop(gettext("Could not compute variance-covariance matrix: parameter vector has unexpected length."), call. = FALSE)
2712+
2713+
names(mle) <- parms
2714+
}
2715+
2716+
mle <- as.numeric(mle[parms])
2717+
names(mle) <- parms
2718+
2719+
negLogLik <- function(theta) {
2720+
names(theta) <- parms
2721+
env <- list2env(c(as.list(theta), list(x = X)), parent = baseenv())
2722+
ll <- eval(logdensity, envir = env)
2723+
-sum(ll)
2724+
}
2725+
2726+
hessian <- stats::optimHess(par = mle, fn = negLogLik)
2727+
2728+
if (anyNA(hessian) || any(!is.finite(hessian)))
2729+
stop(gettext("Could not compute variance-covariance matrix: Hessian contains invalid values."), call. = FALSE)
2730+
2731+
varcov <- solve(hessian)
2732+
dimnames(varcov) <- list(parms, parms)
2733+
2734+
list(varcov = varcov)
2735+
}
2736+
27062737
.qcProbabilityPlotObject <- function(options, dataset, measurements, stages) {
27072738
if (identical(stages, "")) {
27082739
nStages <- 1
@@ -2749,8 +2780,8 @@ processCapabilityStudies <- function(jaspResults, dataset, options) {
27492780
# Computing according to the distribution
27502781
if (options[["nullDistribution"]] == "normal") {
27512782
lpdf <- quote(-log(sigma) - 0.5 / sigma ^ 2 * (x - mu) ^ 2)
2752-
matrix <- try(mle.tools::observed.varcov(logdensity = lpdf, X = dataCurrentStage, parms = c("mu", "sigma"),
2753-
mle = c(mean(dataCurrentStage), sd(dataCurrentStage))))
2783+
matrix <- try(.qcObservedVarcov(logdensity = lpdf, X = dataCurrentStage, parms = c("mu", "sigma"),
2784+
mle = c(mean(dataCurrentStage), sd(dataCurrentStage))))
27542785
# Gracefully handle confidence band computation failure
27552786
if (jaspBase::isTryError(matrix)) {
27562787
hasConfidenceBands <- FALSE
@@ -2781,7 +2812,7 @@ processCapabilityStudies <- function(jaspResults, dataset, options) {
27812812
meanlog <- as.numeric(fit$parameters[1])
27822813
sdlog <- as.numeric(fit$parameters[2])
27832814
lpdf <- quote(log(1/(sqrt(2*pi)*x*sdlog) * exp(-(log(x)- meanlog)^2/(2*sdlog^2))))
2784-
matrix <- try(mle.tools::observed.varcov(logdensity = lpdf, X = dataCurrentStage, parms = c("meanlog", "sdlog"), mle = fit$parameters))
2815+
matrix <- try(.qcObservedVarcov(logdensity = lpdf, X = dataCurrentStage, parms = c("meanlog", "sdlog"), mle = fit$parameters))
27852816
# Gracefully handle confidence band computation failure
27862817
if (jaspBase::isTryError(matrix)) {
27872818
hasConfidenceBands <- FALSE
@@ -2819,7 +2850,7 @@ processCapabilityStudies <- function(jaspResults, dataset, options) {
28192850
shape <- as.numeric(fit_Weibull[["beta"]])
28202851
scale <- as.numeric(fit_Weibull[["theta"]])
28212852
lpdf <- quote(log(shape) - shape * log(scale) + shape * log(x) - (x/scale)^shape)
2822-
matrix <- try(mle.tools::observed.varcov(logdensity = lpdf, X = dataCurrentStage, parms = c("shape", "scale"), mle = c("shape" = shape, "scale" = scale)))
2853+
matrix <- try(.qcObservedVarcov(logdensity = lpdf, X = dataCurrentStage, parms = c("shape", "scale"), mle = c("shape" = shape, "scale" = scale)))
28232854
# Gracefully handle confidence band computation failure
28242855
if (jaspBase::isTryError(matrix)) {
28252856
hasConfidenceBands <- FALSE

R/variablesChartsSubgroups.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ variablesChartsSubgroups <- function(jaspResults, dataset, options) {
7474
if ((!wideFormat && options[["subgroupSizeType"]] == "manual" &&
7575
any(lapply(split(dataset[[stages]], ceiling(seq_along(dataset[[stages]])/options[["manualSubgroupSizeValue"]])), FUN = function(x)length(unique(x))) > 1)) ||
7676
(!wideFormat && options[["subgroupSizeType"]] == "groupingVariable" &&
77-
any(table(dplyr::count_(dataset, vars = c(stages, subgroupVariable))[subgroupVariable]) > 1))) {
77+
any(table(dplyr::count(dataset, dplyr::across(dplyr::all_of(c(stages, subgroupVariable))))[[subgroupVariable]]) > 1))) {
7878
plotNotes <- paste0(plotNotes, gettext("One or more subgroups are assigned to more than one stage, only first stage is considered.<br>"))
7979
}
8080
if (anyNA(dataset[[stages]])) {

inst/help/processCapabilityStudies.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ The size of the subgroups is relevant for the calculation of the process varianc
141141
- FAdist
142142
- goftest
143143
- fitdistrplus
144-
- mle.tools
145144
- tidyr
146145
- tibble
147146
- EnvStats

inst/help/variablesChartsSubgroups.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,3 @@ Select manually which tests you want to apply and modify them as desired:
9393
- ggrepel
9494
- tidyr
9595
- tibble
96-
- mle.tools

0 commit comments

Comments
 (0)