diff --git a/.Rbuildignore b/.Rbuildignore index d8213028..e4e5d139 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^renv\.lock$ ^.*\.Rproj$ ^\.Rproj\.user$ +^tests/upgrades$ diff --git a/R/abtestbayesian.R b/R/abtestbayesian.R index 70107247..207d6b4e 100644 --- a/R/abtestbayesian.R +++ b/R/abtestbayesian.R @@ -36,23 +36,23 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { .abTestBayesianTableMain(jaspResults, ab_obj, options, ready, position = 1) ### DESCRIPTIVES TABLE ### - if (options$descriptives) + if (options$descriptivesTable) .abTestBayesianDescriptivesTable(jaspResults, dataset, options, ready, position = 2) ### PRIOR AND POSTERIOR PLOT ### - if (options$plotPriorAndPosterior) + if (options$priorPosteriorPlot) .abTestPlotPriorPosterior(jaspResults, ab_obj, options, ready, position = 3) ### SEQUENTIAL PLOT ### - if (options$plotSequentialAnalysis) + if (options$bfSequentialPlot) .abTestPlotSequential(jaspResults, ab_obj, ready, position = 4) ### ROBUSTNESS PLOT ### - if (options$plotRobustness) + if (options$bfRobustnessPlot) .abTestPlotRobustness(jaspResults, ab_obj, options, ready, position = 5) ### PRIOR PLOT ### - if (options$plotPriorOnly) + if (options$priorPlot) .abTestPlotPriorOnly(jaspResults, options, position = 6) } @@ -119,11 +119,11 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { .abTestBayesianFillTableMain <- function(abTestBayesianTable, ab_obj, options) { # Normalize prior probabilities - sum_logor <- options$orGreaterThan1Prob + options$orLessThan1Prob + options$orEqualTo1Prob + options$orNotEqualTo1Prob - orGreaterThan1Prob <- options$orGreaterThan1Prob / sum_logor - orLessThan1Prob <- options$orLessThan1Prob / sum_logor - orEqualTo1Prob <- options$orEqualTo1Prob / sum_logor - orNotEqualTo1Prob <- options$orNotEqualTo1Prob / sum_logor + sum_logor <- options$priorModelProbabilityGreater + options$priorModelProbabilityLess + options$priorModelProbabilityEqual + options$priorModelProbabilityTwoSided + priorModelProbabilityGreater <- options$priorModelProbabilityGreater / sum_logor + priorModelProbabilityLess <- options$priorModelProbabilityLess / sum_logor + priorModelProbabilityEqual <- options$priorModelProbabilityEqual / sum_logor + priorModelProbabilityTwoSided <- options$priorModelProbabilityTwoSided / sum_logor if (inherits(ab_obj, "try-error")) { errorMessage <- as.character(ab_obj) @@ -135,43 +135,43 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { output.rows <- list() rowCount <- 0 - if (orEqualTo1Prob > 0) { + if (priorModelProbabilityEqual > 0) { rowCount = rowCount + 1 output.rows[[rowCount]] <- list( "Models" = gettext("Log odds ratio = 0"), "BF" = 1.00, "P(M|data)" = ab_obj$post_prob[["H0"]], - "P(M)" = orEqualTo1Prob + "P(M)" = priorModelProbabilityEqual ) } - if (orGreaterThan1Prob > 0) { + if (priorModelProbabilityGreater > 0) { rowCount = rowCount + 1 output.rows[[rowCount]] <- list( "Models" = gettext("Log odds ratio > 0"), "BF" = ab_obj$bf[["bfplus0"]], "P(M|data)" = ab_obj$post_prob[["H+"]], - "P(M)" = orGreaterThan1Prob + "P(M)" = priorModelProbabilityGreater ) } - if (orLessThan1Prob > 0) { + if (priorModelProbabilityLess > 0) { rowCount = rowCount + 1 output.rows[[rowCount]] <- list( "Models" = gettext("Log odds ratio < 0"), "BF" = ab_obj$bf[["bfminus0"]], "P(M|data)" = ab_obj$post_prob[["H-"]], - "P(M)" = orLessThan1Prob + "P(M)" = priorModelProbabilityLess ) } - if (orNotEqualTo1Prob > 0) { + if (priorModelProbabilityTwoSided > 0) { rowCount = rowCount + 1 output.rows[[rowCount]] <- list( "Models" = gettextf("Log odds ratio %s 0","\u2260"), "BF" = ab_obj$bf[["bf10"]], "P(M|data)" = ab_obj$post_prob[["H1"]], - "P(M)" = orNotEqualTo1Prob + "P(M)" = priorModelProbabilityTwoSided ) } @@ -205,27 +205,27 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { # we copy dependencies from this state object in a few places, so it must always exist jaspResults[["model"]] <- createJaspState() - jaspResults[["model"]]$dependOn(c("n1", "y1", "n2", "y2", "normal_mu", "normal_sigma", "orEqualTo1Prob", - "orLessThan1Prob", "orGreaterThan1Prob", "orNotEqualTo1Prob", "numSamples", "setSeed", "seed")) + jaspResults[["model"]]$dependOn(c("n1", "y1", "n2", "y2", "normalPriorMean", "normalPriorSd", "priorModelProbabilityEqual", + "priorModelProbabilityLess", "priorModelProbabilityGreater", "priorModelProbabilityTwoSided", "samples", "setSeed", "seed")) if (!ready) return(NULL) - prior_par <- list(mu_psi = options$normal_mu, sigma_psi = options$normal_sigma, mu_beta = 0, sigma_beta = 1) + prior_par <- list(mu_psi = options$normalPriorMean, sigma_psi = options$normalPriorSd, mu_beta = 0, sigma_beta = 1) # Normalize prior probabilities - sum_logor <- options$orGreaterThan1Prob + options$orLessThan1Prob + options$orEqualTo1Prob + options$orNotEqualTo1Prob - orGreaterThan1Prob <- options$orGreaterThan1Prob / sum_logor - orLessThan1Prob <- options$orLessThan1Prob / sum_logor - orEqualTo1Prob <- options$orEqualTo1Prob / sum_logor - orNotEqualTo1Prob <- options$orNotEqualTo1Prob / sum_logor + sum_logor <- options$priorModelProbabilityGreater + options$priorModelProbabilityLess + options$priorModelProbabilityEqual + options$priorModelProbabilityTwoSided + priorModelProbabilityGreater <- options$priorModelProbabilityGreater / sum_logor + priorModelProbabilityLess <- options$priorModelProbabilityLess / sum_logor + priorModelProbabilityEqual <- options$priorModelProbabilityEqual / sum_logor + priorModelProbabilityTwoSided <- options$priorModelProbabilityTwoSided / sum_logor - prior_prob <- c(orNotEqualTo1Prob, orGreaterThan1Prob, orLessThan1Prob, orEqualTo1Prob) + prior_prob <- c(priorModelProbabilityTwoSided, priorModelProbabilityGreater, priorModelProbabilityLess, priorModelProbabilityEqual) names(prior_prob) <- c("H1", "H+", "H-", "H0") .setSeedJASP(options) ab <- try(abtest::ab_test(data = dataset, prior_par = prior_par, prior_prob = prior_prob, - posterior = TRUE, nsamples = options$numSamples)) + posterior = TRUE, nsamples = options$samples)) jaspResults[["model"]]$object <- ab @@ -240,7 +240,7 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { abTestBayesianDescriptivesTable <- createJaspTable(title = gettext("Descriptives")) - abTestBayesianDescriptivesTable$dependOn(c("n1", "y1", "n2", "y2", "descriptives")) + abTestBayesianDescriptivesTable$dependOn(c("n1", "y1", "n2", "y2", "descriptivesTable")) abTestBayesianDescriptivesTable$position <- position abTestBayesianDescriptivesTable$addColumnInfo(name = "group", title = "", type = "string") @@ -279,7 +279,7 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { .abTestPlotPriorPosterior <- function(jaspResults, ab_obj, options, ready, position) { abTestPriorAndPosteriorPlot <- createJaspPlot(title = gettext("Prior and Posterior"), width = 530, height = 400) - abTestPriorAndPosteriorPlot$dependOn(c("n1", "y1", "n2", "y2", "normal_mu", "normal_sigma", "numSamples", "plotPosteriorType", "plotPriorAndPosterior", + abTestPriorAndPosteriorPlot$dependOn(c("n1", "y1", "n2", "y2", "normalPriorMean", "normalPriorSd", "samples", "priorPosteriorPlotType", "priorPosteriorPlot", "setSeed", "seed")) abTestPriorAndPosteriorPlot$position <- position @@ -288,7 +288,7 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { if (!ready) return() - abTestPriorAndPosteriorPlot$plotObject <- .plotPosterior.abTest(ab_obj, options$plotPosteriorType) + abTestPriorAndPosteriorPlot$plotObject <- .plotPosterior.abTest(ab_obj, options$priorPosteriorPlotType) } @@ -300,11 +300,11 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { # posteriorPlotType what <- switch( posteriorPlotType, - "LogOddsRatio" = "logor", - "OddsRatio" = "or", - "RelativeRisk" = "rrisk", - "AbsoluteRisk" = "arisk", - "p1&p2" = "p1p2" + "logOddsRatio" = "logor", + "oddsRatio" = "or", + "relativeRisk" = "rrisk", + "absoluteRisk" = "arisk", + "p1P2" = "p1p2" ) plotFunc <- function() { @@ -318,7 +318,7 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { .abTestPlotSequential <- function(jaspResults, ab_obj, ready, position) { abTestSequentialPlot <- createJaspPlot(title = gettext("Sequential Analysis"), width = 530, height = 400) - abTestSequentialPlot$dependOn(options = "plotSequentialAnalysis", optionsFromObject = jaspResults[["model"]]) + abTestSequentialPlot$dependOn(options = "bfSequentialPlot", optionsFromObject = jaspResults[["model"]]) abTestSequentialPlot$position <- position jaspResults[["abTestSequentialPlot"]] <- abTestSequentialPlot @@ -338,7 +338,7 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { .abTestPlotRobustness <- function(jaspResults, ab_obj, options, ready, position) { abTestRobustnessPlot <- createJaspPlot(title = gettext("Bayes Factor Robustness Check"), width = 530, height = 400) - abTestRobustnessPlot$dependOn(c("n1", "y1", "n2", "y2", "normal_mu", "normal_sigma", "mu_stepsize", "sigma_stepsize", "mu_stepsize_lower", "mu_stepsize_upper", "sigma_stepsize_lower", "sigma_stepsize_upper", "plotRobustnessBFType", "numSamples", "plotRobustness", "setSeed", "seed")) + abTestRobustnessPlot$dependOn(c("n1", "y1", "n2", "y2", "normalPriorMean", "normalPriorSd", "bfRobustnessPlotStepsPriorMean", "bfRobustnessPlotStepsPriorSd", "bfRobustnessPlotLowerPriorMean", "bfRobustnessPlotUpperPriorMean", "bfRobustnessPlotLowerPriorSd", "bfRobustnessPlotUpperPriorSd", "bfRobustnessPlotType", "samples", "bfRobustnessPlot", "setSeed", "seed")) abTestRobustnessPlot$position <- position jaspResults[["abTestRobustnessPlot"]] <- abTestRobustnessPlot @@ -354,18 +354,18 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { # Args: # ab_obj: ab test object - mu_range = c(options$mu_stepsize_lower, options$mu_stepsize_upper) - sigma_range = c(options$sigma_stepsize_lower, options$sigma_stepsize_upper) + mu_range = c(options$bfRobustnessPlotLowerPriorMean, options$bfRobustnessPlotUpperPriorMean) + sigma_range = c(options$bfRobustnessPlotLowerPriorSd, options$bfRobustnessPlotUpperPriorSd) plotFunc <- function() { abtest::plot_robustness( x = ab_obj, - mu_steps = options$mu_stepsize, - sigma_steps = options$sigma_stepsize, + mu_steps = options$bfRobustnessPlotStepsPriorMean, + sigma_steps = options$bfRobustnessPlotStepsPriorSd, mu_range = mu_range, sigma_range = sigma_range, - bftype = options$plotRobustnessBFType + bftype = options$bfRobustnessPlotType ) } @@ -376,7 +376,7 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { .abTestPlotPriorOnly <- function(jaspResults, options, position) { abTestPriorPlot <- createJaspPlot(title = gettext("Prior"), width = 530, height = 400) - abTestPriorPlot$dependOn(c("normal_mu", "normal_sigma", "plotPriorType", "plotPriorOnly")) + abTestPriorPlot$dependOn(c("normalPriorMean", "normalPriorSd", "priorPlotType", "priorPlot")) abTestPriorPlot$position <- position jaspResults[["abTestPriorPlot"]] <- abTestPriorPlot @@ -391,15 +391,15 @@ ABTestBayesian <- function(jaspResults, dataset = NULL, options) { # Args: # options - prior_par <- list(mu_psi = options$normal_mu, sigma_psi = options$normal_sigma, mu_beta = 0, sigma_beta = 1) + prior_par <- list(mu_psi = options$normalPriorMean, sigma_psi = options$normalPriorSd, mu_beta = 0, sigma_beta = 1) what <- switch( - options$plotPriorType, - "LogOddsRatio" = "logor", - "OddsRatio" = "or", - "RelativeRisk" = "rrisk", - "AbsoluteRisk" = "arisk", - "p1&p2" = "p1p2", + options$priorPlotType, + "logOddsRatio" = "logor", + "oddsRatio" = "or", + "relativeRisk" = "rrisk", + "absoluteRisk" = "arisk", + "p1P2" = "p1p2", "p1" = "p1", "p2" = "p2" ) diff --git a/R/binomialtest.R b/R/binomialtest.R index bf2a8ae7..af6d5b5c 100644 --- a/R/binomialtest.R +++ b/R/binomialtest.R @@ -50,12 +50,12 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { # perform a check on the hypothesis custom <- function() { - if (options$testValue == 1 && options$hypothesis == "greaterThanTestValue") + if (options$testValue == 1 && options$alternative == "greater") return(gettext("Cannot test the hypothesis that the test value is greater than 1.")) - else if (options$testValue == 0 && options$hypothesis == "lessThanTestValue") + else if (options$testValue == 0 && options$alternative == "less") return(gettext("Cannot test the hypothesis that the test value is less than 0.")) } - + # Error Check 1: Number of levels of the variables and the hypothesis .hasErrors( dataset = dataset, @@ -75,7 +75,7 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { # This will be the object that we fill with results results <- list() - hyp <- .binomTransformHypothesis(options$hypothesis) + hyp <- .binomTransformHypothesis(options$alternative) for (variable in options$variables) { @@ -84,14 +84,14 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { data <- na.omit(dataset[[.v(variable)]]) for (level in levels(data)) { - + counts <- sum(data == level) tableResults <- stats::binom.test( x = counts, n = length(data), p = options$testValue, alternative = hyp, - conf.level = options$confidenceIntervalInterval + conf.level = options$ciLevel ) # sometimes p.value becomes true or false, convert this to 1 or 0 @@ -105,19 +105,19 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { total = length(data), proportion = counts / length(data), p = p, - VovkSellkeMPR = VovkSellkeMPR(p), + vovkSellke = VovkSellkeMPR(p), lowerCI = tableResults$conf.int[1], upperCI = tableResults$conf.int[2] ) - + } - + } # Save results to state jaspResults[["binomTableResults"]] <- createJaspState(results) jaspResults[["binomTableResults"]]$dependOn( - c("variables", "testValue", "hypothesis", "confidenceIntervalInterval") + c("variables", "testValue", "alternative", "ciLevel") ) # Return results object @@ -129,7 +129,7 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { data <- na.omit(dataset[[.v(variable)]]) for (level in levels(data)) { - + counts <- sum(data == level) plotResults <- stats::binom.test( x = counts, @@ -146,19 +146,18 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { lowerCI = plotResults$conf.int[1], upperCI = plotResults$conf.int[2] ) - + } return(results) } -.binomTransformHypothesis <- function(hypothesis) { - if (hypothesis == "greaterThanTestValue") - return("greater") - else if (hypothesis == "lessThanTestValue") - return("less") - else +.binomTransformHypothesis <- function(alternative) { + if (alternative == "twoSided") { return("two.sided") + } else { + return(alternative) + } } # Output functions ---- @@ -168,8 +167,8 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { # Create table binomialTable <- createJaspTable(title = gettext("Binomial Test")) - binomialTable$dependOn(c("variables", "testValue", "hypothesis", "confidenceInterval", - "confidenceIntervalInterval", "VovkSellkeMPR")) + binomialTable$dependOn(c("variables", "testValue", "alternative", "ci", + "ciLevel", "vovkSellke")) binomialTable$showSpecifiedColumnsOnly <- TRUE @@ -181,37 +180,37 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { binomialTable$addColumnInfo(name = "proportion", title = gettext("Proportion"), type = "number") binomialTable$addColumnInfo(name = "p", title = gettext("p"), type = "pvalue") - if (options$VovkSellkeMPR) - binomialTable$addColumnInfo(name = "VovkSellkeMPR", title = gettext("VS-MPR"), type = "number") + if (options$vovkSellke) + binomialTable$addColumnInfo(name = "vovkSellke", title = gettext("VS-MPR"), type = "number") - if (options$confidenceInterval) { + if (options$ci) { binomialTable$addColumnInfo(name = "lowerCI", title = gettext("Lower"), type = "number", - overtitle = gettextf("%s%% CI for Proportion", 100 * options$confidenceIntervalInterval)) + overtitle = gettextf("%s%% CI for Proportion", 100 * options$ciLevel)) binomialTable$addColumnInfo(name = "upperCI", title = gettext("Upper"), type = "number", - overtitle = gettextf("%s%% CI for Proportion", 100 * options$confidenceIntervalInterval)) + overtitle = gettextf("%s%% CI for Proportion", 100 * options$ciLevel)) } - + # Add footnote: VovkSellkeMPR - if (options$VovkSellkeMPR) - binomialTable$addFootnote(message = .messages("footnote", "VovkSellkeMPR"), symbol = "\u002A", colNames="VovkSellkeMPR") - + if (options$vovkSellke) + binomialTable$addFootnote(message = .messages("footnote", "VovkSellkeMPR"), symbol = "\u002A", colNames="vovkSellke") + # Add footnote: Alternative hypothesis - if (options$hypothesis == "lessThanTestValue") + if (options$alternative == "less") note <- gettextf("For all tests, the alternative hypothesis specifies that the proportion is less than %s.", options$testValueUnparsed) - else if (options$hypothesis == "greaterThanTestValue") + else if (options$alternative == "greater") note <- gettextf("For all tests, the alternative hypothesis specifies that the proportion is greater than %s.", options$testValueUnparsed) else note <- gettextf("Proportions tested against value: %s.", options$testValueUnparsed) - + binomialTable$addFootnote(message = note) - + jaspResults[["binomialTable"]] <- binomialTable if (!ready) return() - + binomialTable$setExpectedSize(sum(unlist(lapply(dataset, nlevels)))) - + # Compute the results and fill the table binomResults <- .binomComputeTableResults(jaspResults, dataset, options) .binomFillTableMain(binomialTable, binomResults) @@ -219,7 +218,7 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { .binomFillTableMain <- function(binomialTable, binomResults) { for (variable in names(binomResults)) { - + isNewGroup <- TRUE for (level in names(binomResults[[variable]])) { row <- binomResults[[variable]][[level]] @@ -227,21 +226,21 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { isNewGroup <- FALSE binomialTable$addRows(row) } - + } } -.binomPlotsDescriptive <- function(jaspResults, dataset, options, ready, ciName = "descriptivesPlotsConfidenceInterval") { - if (!options$descriptivesPlots) +.binomPlotsDescriptive <- function(jaspResults, dataset, options, ready, ciName = "descriptivesPlotCiLevel") { + if (!options$descriptivesPlot) return() if (is.null(jaspResults[["containerPlots"]])) { jaspResults[["containerPlots"]] <- createJaspContainer(gettext("Descriptives Plots")) - jaspResults[["containerPlots"]]$dependOn(c("descriptivesPlots", "testValue", ciName)) + jaspResults[["containerPlots"]]$dependOn(c("descriptivesPlot", "testValue", ciName)) } - + plotContainer <- jaspResults[["containerPlots"]] - + if (!ready) { # show a placeholder plot if someone says he wants a plot but does not enter any variables plotContainer[["placeholder"]] <- createJaspPlot(width = 320, height = 320, dependencies = "variables") @@ -259,7 +258,7 @@ BinomialTest <- function(jaspResults, dataset = NULL, options, ...) { plotContainer[[variable]]$dependOn(optionContainsValue = list(variables=variable)) plotResults <- .binomComputePlotResults(variable, dataset, options[["testValue"]], options[[ciName]]) - + for (level in names(plotResults)) { plot <- createJaspPlot(title = level, width = 160, height = 320) plotContainer[[variable]][[level]] <- plot diff --git a/R/binomialtestbayesian.R b/R/binomialtestbayesian.R index 81142413..61384988 100644 --- a/R/binomialtestbayesian.R +++ b/R/binomialtestbayesian.R @@ -30,7 +30,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { # Output tables and plots .bayesBinomTableMain( jaspResults, dataset, options, ready) .bayesBinomInferentialPlots(jaspResults, dataset, options, ready) - .binomPlotsDescriptive( jaspResults, dataset, options, ready, ciName = "descriptivesPlotsCredibleInterval") + .binomPlotsDescriptive( jaspResults, dataset, options, ready, ciName = "descriptivesPlotCiLevel") } # Results function ---- @@ -40,7 +40,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { # This will be the object that we fill with results results <- list() - hyp <- .binomTransformHypothesis(options$hypothesis) + hyp <- .binomTransformHypothesis(options$alternative) for (variable in options$variables) { @@ -51,7 +51,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { for (level in levels(data)) { counts <- sum(data == level) - BF10 <- .bayesBinomialTest(counts, length(data), theta0=options$testValue, hypothesis = hyp, a = options$priorA, b = options$priorB) + BF10 <- .bayesBinomialTest(counts, length(data), theta0=options$testValue, alternative = hyp, a = options$priorA, b = options$priorB) # Add results for each level of each variable to results object results[[variable]][[level]] <- list( @@ -71,7 +71,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { # Save results to state jaspResults[["binomResults"]] <- createJaspState(results) jaspResults[["binomResults"]]$dependOn( - c("variables", "testValue", "hypothesis", "priorA", "priorB") + c("variables", "testValue", "alternative", "priorA", "priorB") ) # Return results object @@ -84,7 +84,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { return() binomTable <- createJaspTable(gettext("Bayesian Binomial Test")) - binomTable$dependOn(c("variables", "testValue", "hypothesis", "bayesFactorType", "priorA", "priorB")) + binomTable$dependOn(c("variables", "testValue", "alternative", "bayesFactorType", "priorA", "priorB")) binomTable$position <- 1 binomTable$showSpecifiedColumnsOnly <- TRUE @@ -95,11 +95,11 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { )) bfTitleSpec <- list(null="\u2080") - if (options$hypothesis == "notEqualToTestValue") + if (options$alternative == "twoSided") bfTitleSpec[["other"]] <- "\u2081" - else if (options$hypothesis == "greaterThanTestValue") + else if (options$alternative == "greater") bfTitleSpec[["other"]] <- "\u208A" - else if (options$hypothesis == "lessThanTestValue") + else if (options$alternative == "less") bfTitleSpec[["other"]] <- "\u208B" bfType <- options$bayesFactorType @@ -118,9 +118,9 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { binomTable$addColumnInfo(name = "proportion", title = gettext("Proportion"), type = "number") binomTable$addColumnInfo(name = bfType, title = bfTitle, type = "number") - if (options$hypothesis == "lessThanTestValue") + if (options$alternative == "less") note <- gettextf("For all tests, the alternative hypothesis specifies that the proportion is less than %s.", options$testValueUnparsed) - else if (options$hypothesis == "greaterThanTestValue") + else if (options$alternative == "greater") note <- gettextf("For all tests, the alternative hypothesis specifies that the proportion is greater than %s.", options$testValueUnparsed) else note <- gettextf("Proportions tested against value: %s.", options$testValueUnparsed) @@ -168,13 +168,13 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } -.bayesBinomialTest.oneSided <- function(counts, n, theta0, a, b, hypothesis) { +.bayesBinomialTest.oneSided <- function(counts, n, theta0, a, b, alternative) { - if (hypothesis == "less") { + if (alternative == "less") { lowerTail <- TRUE - } else if (hypothesis == "greater") { + } else if (alternative == "greater") { lowerTail <- FALSE @@ -206,9 +206,9 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } -.bayesBinomialTest <- function(counts, n, theta0, hypothesis, a, b) { +.bayesBinomialTest <- function(counts, n, theta0, alternative, a, b) { - if (hypothesis == "two.sided") { + if (alternative == "two.sided") { BF10 <- try(.bayesBinomialTest.twoSided(counts, n, theta0, a, b), silent = TRUE) @@ -220,7 +220,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { # #} else { - BF10 <- try(.bayesBinomialTest.oneSided(counts, n, theta0, a, b, hypothesis), silent = TRUE) + BF10 <- try(.bayesBinomialTest.oneSided(counts, n, theta0, a, b, alternative), silent = TRUE) #} } @@ -232,10 +232,10 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } -.bayesBinomGetSubscript <- function(hypothesis) { - if (hypothesis == "notEqualToTestValue") +.bayesBinomGetSubscript <- function(alternative) { + if (alternative == "twoSided") return("BF[1][0]") - else if (hypothesis == "greaterThanTestValue") + else if (alternative == "greater") return("BF['+'][0]") else return("BF['-'][0]") @@ -243,12 +243,12 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { #plots ---- .bayesBinomInferentialPlots <- function(jaspResults, dataset, options, ready) { - if (!options$plotPriorAndPosterior && !options$plotSequentialAnalysis) + if (!options$priorPosteriorPlot && !options$bfSequentialPlot) return() if (is.null(jaspResults[["inferentialPlots"]])) { inferentialPlots <- createJaspContainer(gettext("Inferential Plots")) - inferentialPlots$dependOn(c("testValue", "priorA", "priorB", "hypothesis")) + inferentialPlots$dependOn(c("testValue", "priorA", "priorB", "alternative")) inferentialPlots$position <- 2 jaspResults[["inferentialPlots"]] <- inferentialPlots } else { @@ -261,7 +261,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { return() } - hyp <- .binomTransformHypothesis(options$hypothesis) + hyp <- .binomTransformHypothesis(options$alternative) for (var in options$variables) { @@ -281,7 +281,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } counts <- sum(data == level) - BF10 <- .bayesBinomialTest(counts, length(data), options$testValue, hypothesis = hyp, a = options$priorA, b = options$priorB) + BF10 <- .bayesBinomialTest(counts, length(data), options$testValue, alternative = hyp, a = options$priorA, b = options$priorB) plotName <- paste0(var, level, "priorposterior") .bayesBinomPriorPosteriorPlot(levelPlotContainer, plotName, options, BF10, counts, length(data), hyp) @@ -294,23 +294,23 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } .bayesBinomPriorPosteriorPlot <- function(container, plotName, options, BF10, counts, n, hyp) { - if (!options$plotPriorAndPosterior || !is.null(container[[plotName]])) + if (!options$priorPosteriorPlot || !is.null(container[[plotName]])) return() plot <- createJaspPlot(title = gettext("Prior and Posterior"), width = 530, height = 400, aspectRatio = 0.7) - plot$dependOn(c("plotPriorAndPosterior", "plotPriorAndPosteriorAdditionalInfo")) + plot$dependOn(c("priorPosteriorPlot", "priorPosteriorPlotAdditionalInfo")) container[[plotName]] <- plot - bfSubscripts <- .bayesBinomGetSubscript(options$hypothesis) - quantiles <- .credibleIntervalPlusMedian(credibleIntervalInterval = .95, options$priorA, options$priorB, counts, n, hypothesis=hyp, theta0 = options$testValue) + bfSubscripts <- .bayesBinomGetSubscript(options$alternative) + quantiles <- .credibleIntervalPlusMedian(credibleIntervalInterval = .95, options$priorA, options$priorB, counts, n, alternative=hyp, theta0 = options$testValue) dfLinesPP <- .dfLinesPP(a=options$priorA, b=options$priorB, hyp = hyp, theta0 = options$testValue, counts = counts, n = n) dfPointsPP <- .dfPointsPP(a=options$priorA, b=options$priorB, hyp = hyp, theta0 = options$testValue, counts = counts, n = n) xName <- bquote(paste(.(gettext("Population proportion")), ~theta)) hypForPlots <- .binomHypothesisForPlots(hyp) - if (!options$plotPriorAndPosteriorAdditionalInfo) + if (!options$priorPosteriorPlotAdditionalInfo) p <- jaspGraphs::PlotPriorAndPosterior(dfLines = dfLinesPP, dfPoints = dfPointsPP, xName = xName) else p <- jaspGraphs::PlotPriorAndPosterior(dfLines = dfLinesPP, dfPoints = dfPointsPP, xName = xName, BF = BF10, bfType = "BF10", @@ -320,11 +320,11 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } .bayesBinomSequentialPlot <- function(container, plotName, options, BF10, counts, n, hyp, var, data, level) { - if (!options$plotSequentialAnalysis || !is.null(container[[plotName]])) + if (!options$bfSequentialPlot || !is.null(container[[plotName]])) return() plot <- createJaspPlot(title = gettext("Sequential Analysis"), width = 530, height = 400, aspectRatio = 0.7) - plot$dependOn(c("plotSequentialAnalysis", "bayesFactorType")) + plot$dependOn(c("bfSequentialPlot", "bayesFactorType")) container[[plotName]] <- plot @@ -333,7 +333,7 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { p <- try({ bfTypeIgnoreLog <- if(options[["bayesFactorType"]] == "BF01") "BF01" else "BF10" # see https://github.com/jasp-stats/INTERNAL-jasp/issues/1101 bf <- if(bfTypeIgnoreLog == "BF01") 1 / BF10 else BF10 - bfSubscripts <- .bayesBinomGetSubscript(options$hypothesis) + bfSubscripts <- .bayesBinomGetSubscript(options$alternative) dfLinesSR <- .dfLinesSR(d = data, var = var, split = level, a = options$priorA, b = options$priorB, hyp = hyp, theta0 = options$testValue, bfType = bfTypeIgnoreLog) jaspGraphs::PlotRobustnessSequential(dfLines = dfLinesSR, xName = "n", BF = bf, bfType = bfTypeIgnoreLog, hypothesis = hypForPlots) }) @@ -427,22 +427,22 @@ BinomialTestBayesian <- function(jaspResults, dataset = NULL, options, ...) { } #CRI and Median ---- -.credibleIntervalPlusMedian <- function(credibleIntervalInterval = .95, a = 1, b = 1, counts = 10, n = 20, hypothesis = "two.sided", theta0 = .5) { +.credibleIntervalPlusMedian <- function(credibleIntervalInterval = .95, a = 1, b = 1, counts = 10, n = 20, alternative = "two.sided", theta0 = .5) { lower <- (1 - credibleIntervalInterval) / 2 upper <- 1 - lower - if (hypothesis == "two.sided") { + if (alternative == "two.sided") { quantiles <- qbeta(c(lower, .5, upper), a + counts , b + n - counts) - } else if (hypothesis == "greater") { + } else if (alternative == "greater") { rightArea <- pbeta(theta0, a + counts , b + n - counts, lower.tail = FALSE) leftArea <- 1 - rightArea quantiles <- qbeta(leftArea + rightArea * c(lower, .5, upper), a + counts , b + n - counts) - } else if (hypothesis == "less") { + } else if (alternative == "less") { leftArea <- pbeta(theta0, a + counts , b + n - counts) quantiles <- qbeta(leftArea * c(lower, .5, upper), a + counts , b + n - counts) diff --git a/R/contingencytables.R b/R/contingencytables.R index 7b0a988d..4d1b5514 100644 --- a/R/contingencytables.R +++ b/R/contingencytables.R @@ -198,7 +198,7 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { # Create table crossTabChisq <- createJaspTable(title = gettext("Chi-Squared Tests")) - crossTabChisq$dependOn(c("chiSquared", "chiSquaredContinuityCorrection", "likelihoodRatio", "VovkSellkeMPR")) + crossTabChisq$dependOn(c("chiSquared", "chiSquaredContinuityCorrection", "likelihoodRatio", "vovkSellke")) crossTabChisq$showSpecifiedColumnsOnly <- TRUE crossTabChisq$position <- 2 @@ -212,7 +212,7 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { if (options$likelihoodRatio) .crossTabChisqAddColInfo(fold = "likelihood", crossTabChisq, options) .crossTabChisqAddColInfo(fold = "N", crossTabChisq, options, counts.fp) - if(options$VovkSellkeMPR){ + if(options$vovkSellke){ message <- gettextf("Vovk-Sellke Maximum p-Ratio: Based the p-value, the maximum possible odds in favor of H%1$s over H%2$s equals %3$s (Sellke, Bayarri, & Berger, 2001).", "\u2081", "\u2080", "1/(-e p log(p)) for p \u2264 .37") @@ -239,14 +239,14 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { next # Create table - title <- if (options[["LogOdds"]]) gettext("Log Odds Ratio") else gettext("Odds Ratio") + title <- if (options[["oddsRatioAsLogOdds"]]) gettext("Log Odds Ratio") else gettext("Odds Ratio") crossTabOdds <- createJaspTable(title = title) - crossTabOdds$dependOn(c("LogOdds","oddsRatio", "oddsRatioConfidenceIntervalInterval", - "oddsRatioHypothesis", "rowOrder", "columnOrder")) + crossTabOdds$dependOn(c("oddsRatioAsLogOdds","oddsRatio", "oddsRatioCiLevel", + "oddsRatioAlternative", "rowOrder", "columnOrder")) crossTabOdds$showSpecifiedColumnsOnly <- TRUE crossTabOdds$position <- 3 - ci.label <- gettextf("%.0f%% Confidence Intervals", 100*options$oddsRatioConfidenceIntervalInterval) + ci.label <- gettextf("%.0f%% Confidence Intervals", 100*options$oddsRatioCiLevel) # Add columns to table .crossTabLayersColumns( crossTabOdds, analysis) @@ -352,7 +352,7 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { # Create table crossTabKendallTau <- createJaspTable(title = "Kendall's Tau") - crossTabKendallTau$dependOn(c("kendallsTauB", "VovkSellkeMPR", "rowOrder", "columnOrder")) + crossTabKendallTau$dependOn(c("kendallsTauB", "vovkSellke", "rowOrder", "columnOrder")) crossTabKendallTau$showSpecifiedColumnsOnly <- TRUE crossTabKendallTau$position <- 6 @@ -361,7 +361,7 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { crossTabKendallTau$addColumnInfo(name = "value[kTauB]", title = gettext("Kendall's Tau-b "), type = "number") crossTabKendallTau$addColumnInfo(name = "statistic[kTauB]", title = gettext("Z"), type = "number", format = "dp:3") crossTabKendallTau$addColumnInfo(name = "p[kTauB]", title = gettext("p"), type = "pvalue") - if (options$VovkSellkeMPR) crossTabKendallTau$addColumnInfo(name = "MPR[kTauB]", title = gettextf("VS-MPR%s", "\u002A"), type = "number") + if (options$vovkSellke) crossTabKendallTau$addColumnInfo(name = "MPR[kTauB]", title = gettextf("VS-MPR%s", "\u002A"), type = "number") analysisContainer[["crossTabKendallTau"]] <- crossTabKendallTau analysis <- as.list(analysis) @@ -440,7 +440,7 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { table$addColumnInfo(name = paste0("value[", fold, "]"), title = gettext("Value"), type = valueFoldType) table$addColumnInfo(name = paste0("df[", fold, "]"), title = gettext("df"), type = "integer") table$addColumnInfo(name = paste0("p[", fold, "]"), title = gettext("p"), type = "pvalue") - if (options$VovkSellkeMPR) table$addColumnInfo(name = paste0("MPR[", fold, "]"), title = gettextf("VS-MPR%s", "\u002A"), type = "number") + if (options$vovkSellke) table$addColumnInfo(name = paste0("MPR[", fold, "]"), title = gettextf("VS-MPR%s", "\u002A"), type = "number") } .crossTabOddsAddColInfo <- function(table, fold, ci.label, oddsTitle) { @@ -690,12 +690,12 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { .crossTabOddsNote <- function(crossTabOdds, groupList, options, ready){ if(ready){ - if(length(groupList$group.matrices) >= 1 & options[["oddsRatioHypothesis"]] != "two.sided"){ + if(length(groupList$group.matrices) >= 1 & options[["oddsRatioAlternative"]] != "twoSided"){ gp1 <- dimnames(groupList$group.matrices[[1]])[[1]][1] gp2 <- dimnames(groupList$group.matrices[[1]])[[1]][2] - if(options[["oddsRatioHypothesis"]] == "less") lessIsMore <- gettext("is less than") + if(options[["oddsRatioAlternative"]] == "less") lessIsMore <- gettext("is less than") else lessIsMore <- gettext("is greater than") message <- gettextf("For all tests, the alternative hypothesis specifies that group %1$s %2$s %3$s.", gp1, lessIsMore, gp2) @@ -1096,14 +1096,14 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { row[["value[likelihood]"]] <- NaN row[["df[likelihood]"]] <- "" row[["p[likelihood]"]] <- "" - if (options$VovkSellkeMPR) + if (options$vovkSellke) row[["MPR[likelihood]"]] <- "" } else { row[["value[likelihood]"]] <- chi.result$chisq_tests[1] row[["df[likelihood]"]] <- chi.result$chisq_tests[3] pVal <- chi.result$chisq_tests[5] row[["p[likelihood]"]] <- pVal - if (options$VovkSellkeMPR) + if (options$vovkSellke) row[["MPR[likelihood]"]] <- VovkSellkeMPR(pVal) } } else @@ -1140,9 +1140,9 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { } else { chi.result <- try({ chi.result <- vcd::oddsratio(counts.matrix) - level <- options$oddsRatioConfidenceIntervalInterval + level <- options$oddsRatioCiLevel CI <- stats::confint(chi.result, level = level) - if (options[["LogOdds"]]){ + if (options[["oddsRatioAsLogOdds"]]){ OR <- unname(chi.result$coefficients) CI.low <- CI[1] CI.high <- CI[2] @@ -1180,10 +1180,10 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { row[["p[FisherTest]"]] <- "" } else { chi.result <- try({ - conf.level <- options$oddsRatioConfidenceIntervalInterval - chi.result <- stats::fisher.test(counts.matrix, conf.level = conf.level, - alternative = options$oddsRatioHypothesis) - if (options[["LogOdds"]]){ + conf.level <- options$oddsRatioCiLevel + alternative <- if(options[["oddsRatioAlternative"]] == "twoSided") "two.sided" else options[["oddsRatioAlternative"]] + chi.result <- stats::fisher.test(counts.matrix, conf.level = conf.level, alternative = alternative) + if (options[["oddsRatioAsLogOdds"]]){ OR <- log(unname(chi.result$estimate)) CI.low <- log(chi.result$conf.int[1]) CI.high <- log(chi.result$conf.int[2]) @@ -1315,13 +1315,13 @@ ContingencyTables <- function(jaspResults, dataset, options, ...) { else { row[["value[kTauB]"]] <- unname(chi.result$estimate) row[["p[kTauB]"]] <- chi.result$p.value - if (options$VovkSellkeMPR) row[["MPR[kTauB]"]] <- VovkSellkeMPR(row[["p[kTauB]"]]) + if (options$vovkSellke) row[["MPR[kTauB]"]] <- VovkSellkeMPR(row[["p[kTauB]"]]) row[["statistic[kTauB]"]] <- unname(chi.result$statistic) } } else { row[["value[kTauB]"]] <- "." row[["p[kTauB]"]] <- "." - if (options$VovkSellkeMPR) row[["MPR[kTauB]"]] <- "." + if (options$vovkSellke) row[["MPR[kTauB]"]] <- "." row[["statistic[kTauB]"]] <- "." } diff --git a/R/contingencytablesbayesian.R b/R/contingencytablesbayesian.R index 0fb07f40..91f9b207 100644 --- a/R/contingencytablesbayesian.R +++ b/R/contingencytablesbayesian.R @@ -48,7 +48,7 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) # Create table contTabBasBF <- createJaspTable(title = gettext("Bayesian Contingency Tables Tests")) - dependList <- c("samplingModel", "hypothesis", "bayesFactorType", "priorConcentration", "setSeed", "seed") + dependList <- c("samplingModel", "alternative", "bayesFactorType", "priorConcentration", "setSeed", "seed") contTabBasBF$dependOn(dependList) contTabBasBF$showSpecifiedColumnsOnly <- TRUE contTabBasBF$position <- 2 @@ -83,12 +83,12 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) # Create table contTabBasLogOdds <- createJaspTable(title = gettext("Log Odds Ratio")) - dependList <- c("oddsRatio", "oddsRatioCredibleIntervalInterval", "hypothesis", "samplingModel", "priorConcentration", "setSeed", "seed") + dependList <- c("oddsRatio", "oddsRatioCiLevel", "alternative", "samplingModel", "priorConcentration", "setSeed", "seed") contTabBasLogOdds$dependOn(dependList) contTabBasLogOdds$showSpecifiedColumnsOnly <- TRUE contTabBasLogOdds$position <- 3 - ci.label <- gettextf("%.0f%% Credible Interval", 100*options$oddsRatioCredibleIntervalInterval) + ci.label <- gettextf("%.0f%% Credible Interval", 100*options$oddsRatioCiLevel) # Add columns to table .crossTabLayersColumns(contTabBasLogOdds, analysis) @@ -111,7 +111,7 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) } .contTabBasCramersV <- function(jaspResults, options, analyses, ready) { - if(!options$effectSize) + if(!options$cramersV) return() for (i in 1:nrow(analyses)){ @@ -121,11 +121,11 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) next # Create table - contTabBasCramersV <- createJaspTable(title = gettext("Cramer's V"), dependencies="effectSize") + contTabBasCramersV <- createJaspTable(title = gettext("Cramer's V"), dependencies="cramersV") contTabBasCramersV$showSpecifiedColumnsOnly <- TRUE contTabBasCramersV$position <- 4 - ci <- gettextf("%.0f%% Credible Interval", 100 * options$effectSizeCredibleIntervalInterval) + ci <- gettextf("%.0f%% Credible Interval", 100 * options$cramersVCiLevel) # Add columns to table .crossTabLayersColumns(contTabBasCramersV, analysis) @@ -147,13 +147,13 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) # Log Odds Plot .contTabBasLogOddsPlot <- function(jaspResults, options, analyses, ready) { - if(!options$plotPosteriorOddsRatio) + if(!options$posteriorOddsRatioPlot) return() if (is.null(jaspResults[["oddsRatioPlots"]])) { oddsRatioPlots <- createJaspContainer(gettext("Log Odds Ratio Plots")) - oddsRatioPlots$dependOn(c("layers", "counts", "plotPosteriorOddsRatio", "hypothesis", "samplingModel", - "plotPosteriorOddsRatioAdditionalInfo", "priorConcentration", + oddsRatioPlots$dependOn(c("layers", "counts", "posteriorOddsRatioPlot", "alternative", "samplingModel", + "posteriorOddsRatioPlotAdditionalInfo", "priorConcentration", "counts", "layers", "setSeed", "seed")) oddsRatioPlots$position <- 2 .contTablesBayesianCitations(oddsRatioPlots) @@ -222,16 +222,16 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) else if (is.infinite(BF10)) stop(gettext("The Bayes factor is infinite")) } - switch(options$hypothesis, - groupTwoGreater = { + switch(options$alternative, + less = { oneSided <- "left" bfSubscripts <- c("BF['-'][0]", "BF[0]['-']") }, - groupOneGreater = { + greater = { oneSided <- "right" bfSubscripts <- c("BF['+'][0]", "BF[0]['+']") }, - groupsNotEqual = { + twoSided = { oneSided <- "notABoolean" bfSubscripts <- c("BF[1][0]", "BF[0][1]") } @@ -260,13 +260,13 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) logOR <- seq(min(xticks), max(xticks),length.out = 10000) dfLines <- .dposteriorOR(logOR, mean(samples), sd(samples), oneSided) ppCri <- c(result$lower.ci, result$upper.ci) - CriInterval <- options$oddsRatioCredibleIntervalInterval # todo: need this implemented + CriInterval <- options$oddsRatioCiLevel # todo: need this implemented CRItxt <- paste0(100*CriInterval, "% CI: ") median <- result$median medianTxt <- gettext("median Log OR = ") xName <- gettext("Log Odds Ratio") - if(options$plotPosteriorOddsRatioAdditionalInfo) + if(options$posteriorOddsRatioPlotAdditionalInfo) p <- jaspGraphs::PlotPriorAndPosterior(dfLines = dfLines, xName = xName, BF = BF10, bfType = "BF10", CRI = ppCri, median = median, bfSubscripts = bfSubscripts, CRItxt = CRItxt, medianTxt = medianTxt) @@ -305,7 +305,7 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) bfList[[g]] <- .contTabBasComputeBF(options, grp.mat[[g]], ready) analysisContainer[["bfList"]] <- createJaspState(bfList) analysisContainer[["bfList"]]$dependOn(c("samplingModel", "priorConcentration", - "hypothesis", "bayesFactorType", "setSeed", "seed")) + "alternative", "bayesFactorType", "setSeed", "seed")) return(bfList) } @@ -356,13 +356,13 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) } - if(options$hypothesis %in% c("groupOneGreater", "groupTwoGreater")){ + if(options$alternative %in% c("greater", "less")){ if(options$samplingModel %in% c("poisson", "jointMultinomial")){ theta <- as.data.frame(ch.result) odds.ratio <- (theta[,1]*theta[,4])/(theta[,2]*theta[,3]) logOR <- log(odds.ratio) - if(options$hypothesis == "groupOneGreater") prop.consistent <- 1 - mean(logOR < 0) + if(options$alternative == "greater") prop.consistent <- 1 - mean(logOR < 0) else prop.consistent <- mean(logOR < 0) } else if(options$samplingModel %in% rowsOrCols) { @@ -371,11 +371,11 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) switch(options$samplingModel, independentMultinomialRowsFixed = { - if(options$hypothesis == "groupOneGreater") prop.consistent <- mean(theta[,1] > theta[,2]) + if(options$alternative == "greater") prop.consistent <- mean(theta[,1] > theta[,2]) else prop.consistent <- mean(theta[,1] < theta[,2]) }, independentMultinomialColumnsFixed = { - if(options$hypothesis == "groupOneGreater") prop.consistent <- mean(theta[,1] > theta[,3]) + if(options$alternative == "greater") prop.consistent <- mean(theta[,1] > theta[,3]) else prop.consistent <- mean(theta[,1] < theta[,3]) } ) @@ -386,10 +386,10 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) } } - switch(options$hypothesis, - groupOneGreater = { bfTitleUniquePart <- "\u208A" }, #On my system these code points seem to be rendered as B+0, B0+ etc. Probably wrong then? - groupTwoGreater = { bfTitleUniquePart <- "\u208B" }, - groupsNotEqual = { bfTitleUniquePart <- "\u2081" }) # || options$samplingModel == "hypergeometric" used to be added here, but because it was an if - else if - else if covering all possibilities this was quite pointless. Maybe there is a bug here as well. I don't know about that. + switch(options$alternative, + greater = { bfTitleUniquePart <- "\u208A" }, #On my system these code points seem to be rendered as B+0, B0+ etc. Probably wrong then? + less = { bfTitleUniquePart <- "\u208B" }, + twoSided = { bfTitleUniquePart <- "\u2081" }) # || options$samplingModel == "hypergeometric" used to be added here, but because it was an if - else if - else if covering all possibilities this was quite pointless. Maybe there is a bug here as well. I don't know about that. #I am not adding the following bfTitle's to the translation strings because there is not a lot to translate and it would be neigh incomprehensible if all those unicode chars were %s... switch(options$bayesFactorType, @@ -442,10 +442,10 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) gp2 <- colnames(counts.matrix)[2] } - switch(options$hypothesis, - groupOneGreater = { equality <- gettext("is greater than") }, - groupTwoGreater = { equality <- gettext("is less than") }, - groupsNotEqual = { equality <- gettext("is not equal to") }, + switch(options$alternative, + greater = { equality <- gettext("is greater than") }, + less = { equality <- gettext("is less than") }, + twoSided = { equality <- gettext("is not equal to") }, ) message <- gettextf("For all tests, the alternative hypothesis specifies that group %1$s %2$s %3$s.", gp1, equality, gp2) @@ -492,11 +492,11 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) stop(gettext("Invalid sampling model selected")) samples <- log(odds.ratio.samples) - sig <- options$oddsRatioCredibleIntervalInterval + sig <- options$oddsRatioCiLevel alpha <- (1 - sig) / 2 quantiles <- .crossTabCIPlusMedian(credibleIntervalInterval = sig, mean = mean(samples), sd = sd(samples), - hypothesis = options$hypothesis) + alternative = options$alternative) median <- quantiles$ci.median lower <- quantiles$ci.lower upper <- quantiles$ci.upper @@ -654,7 +654,7 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) CramersV.samples <- Cramer CramersV.median <- stats::median(CramersV.samples) - sig <- options$effectSizeCredibleIntervalInterval + sig <- options$cramersVCiLevel alpha <- (1 - sig) / 2 lower <- unname(stats::quantile(Cramer, p = alpha)) upper <- unname(stats::quantile(Cramer, p = (1-alpha))) @@ -703,21 +703,21 @@ ContingencyTablesBayesian <- function(jaspResults, dataset = NULL, options, ...) } #CRI and Median -.crossTabCIPlusMedian <- function(credibleIntervalInterval = .95, mean, sd, hypothesis = "groupsNotEqual") { +.crossTabCIPlusMedian <- function(credibleIntervalInterval = .95, mean, sd, alternative = "twoSided") { lower <- (1 - credibleIntervalInterval) / 2 upper <- 1 - lower - switch(hypothesis, - groupsNotEqual={ + switch(alternative, + twoSided={ quantiles <- qnorm(c(lower, .5, upper), mean, sd) }, - groupOneGreater = { + greater = { rightArea <- pnorm(0, mean, sd, lower.tail = FALSE) leftArea <- 1 - rightArea quantiles <- qnorm(leftArea + rightArea * c(lower, .5, upper), mean, sd) }, - groupTwoGreater = { + less = { leftArea <- pnorm(0, mean, sd) quantiles <- qnorm(leftArea * c(lower, .5, upper), mean, sd) } diff --git a/R/multinomialtest.R b/R/multinomialtest.R index 2f9898a6..f9c8d5c0 100644 --- a/R/multinomialtest.R +++ b/R/multinomialtest.R @@ -37,10 +37,10 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { fact <- asnum <- NULL if (options$factor != "") { fact <- options$factor - if (options$counts != "") { - asnum <- options$counts - if (options$exProbVar != "") - asnum <- c(asnum, options$exProbVar) + if (options$count != "") { + asnum <- options$count + if (options$expectedCount != "") + asnum <- c(asnum, options$expectedCount) } } @@ -53,21 +53,21 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { # Reorder the rows of the factor and the counts (and expected probabilities) if the user changes the factor level order in JASP. # This ensures the ordering in tables and plots also changes appropriately. - if (options$factor != "" && options$counts != "") { + if (options$factor != "" && options$count != "") { factLevelOrder <- as.character(dataset[[.v(options$factor)]]) - # the following condition holds when `counts` are specified but the data set is not in aggregated form + # the following condition holds when `count` are specified but the data set is not in aggregated form # the error is subsequently caught in .multinomCheckErrors # we need to escape this function early because the operations under this check assume that the data set is already in aggregated form if(length(unique(factLevelOrder)) != length(factLevelOrder)) return(dataset) - levelOrderUserWants <- options$tableWidget[[1]]$levels + levelOrderUserWants <- options$testValuesCustom[[1]]$levels whatUserWantsToWhatIs <- match(levelOrderUserWants, factLevelOrder) if (!identical(sort(whatUserWantsToWhatIs), whatUserWantsToWhatIs)) dataset[seq_along(factLevelOrder), ] <- dataset[whatUserWantsToWhatIs, ] - # For syntax mode the analysis will be called from RStudio and the factor levels may not match the tableWidget. + # For syntax mode the analysis will be called from RStudio and the factor levels may not match the testValuesCustom. factValues <- as.character(dataset[[.v(options$factor)]]) facLevels <- levels(dataset[[.v(options$factor)]]) if (length(facLevels) == length(factValues) && !identical(factValues, facLevels)) @@ -83,26 +83,26 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { customChecks <- list( checkExpecAndObs = function() { - if (options$exProbVar != "" && options$counts == "") + if (options$expectedCount != "" && options$count == "") return(gettext("Expected counts not supported without observed counts.")) }, checkExpecNeeded = function() { - if (options$exProbVar != "" || options$hypothesis != "multinomialTest") - if (options$exProbVar == "" && length(options$tableWidget) == 0) + if (options$expectedCount != "" || options$testValues != "equal") + if (options$expectedCount == "" && length(options$testValuesCustom) == 0) return(gettext("No expected counts entered.")) }, checkCounts = function() { - if (options$counts != "") { + if (options$count != "") { dataset <- na.omit(dataset) nlevels <- nlevels(as.factor(dataset[[.v(options$factor)]])) - counts <- dataset[[.v(options$counts)]] + counts <- dataset[[.v(options$count)]] if (nlevels != length(counts)) return(gettext("Invalid counts: variable does not match the number of levels of the factor. When counts are specified, each row of the data set must represent a unique level of the factor.")) - if (options$exProbVar != "" && nlevels != length(dataset[[.v(options$exProbVar)]])) + if (options$expectedCount != "" && nlevels != length(dataset[[.v(options$expectedCount)]])) return(gettext("Invalid expected counts: variable does not match the number of levels of the factor.")) # only applies for observed counts, expected counts can be proportions @@ -117,8 +117,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { .hasErrors(dataset, type = c("factorLevels", "negativeValues", "infinity"), - negativeValues.target = c(options$counts, options$exProbVar), - infinity.target = c(options$counts, options$exProbVar), + negativeValues.target = c(options$count, options$expectedCount), + infinity.target = c(options$count, options$expectedCount), factorLevels.target = options$factor, factorLevels.amount = "< 1", custom = customChecks, @@ -151,11 +151,11 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { factorVariable <- as.factor(factorVariable) nlev <- nlevels(factorVariable) - if (options$counts != "") { - counts <- dataset[[.v(options$counts)]] + if (options$count != "") { + counts <- dataset[[.v(options$count)]] # omit count entries for which factor variable is NA counts <- counts[!is.na(factorVariable)] - c <- dataset[[.v(options$counts)]] + c <- dataset[[.v(options$count)]] factorVariable <- factor(rep(factorVariable, c), levels = levels(factorVariable)) } @@ -171,7 +171,7 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { # need to improve this try statement csr <- withCallingHandlers( chisq.test(x = dataTable, p = h, rescale.p = TRUE, - simulate.p.value = options$simulatepval), + simulate.p.value = FALSE), warning = function(w) warn <<- w$message ) csr[["warn"]] <- warn @@ -180,8 +180,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { } # Save results to state jaspResults[["stateChisqResults"]] <- createJaspState(chisqResults) - jaspResults[["stateChisqResults"]]$dependOn(c("factor", "counts", "hypothesis", - "exProbVar", "tableWidget", "simulatepval")) + jaspResults[["stateChisqResults"]]$dependOn(c("factor", "count", "testValues", + "expectedCount", "testValuesCustom")) return(chisqResults) } @@ -211,8 +211,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { colnames(dataframe) <- c("chisquare", "df", "p") dataframe <- cbind(case = names(chisqResults), dataframe) - if (options$VovkSellkeMPR) - dataframe <- cbind(dataframe, VovkSellkeMPR = VovkSellkeMPR(dataframe$p)) + if (options$vovkSellke) + dataframe <- cbind(dataframe, vovkSellke = VovkSellkeMPR(dataframe$p)) jaspResults[["chisqTable"]]$setData(dataframe) @@ -239,7 +239,7 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { footnotes <- list() observed <- chisqResults[[1]][["observed"]] - if (options$countProp == "descCounts") + if (options$descriptivesType == "counts") observed <- as.integer(observed) else observed <- as.numeric(observed)/sum(observed) @@ -250,7 +250,7 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { observed = observed, stringsAsFactors = FALSE ) - if (options$countProp == "descCounts") + if (options$descriptivesType == "counts") for (r in chisqResults) tableFrame <- cbind(tableFrame, r[["expected"]]) else @@ -265,10 +265,10 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { colnames(tableFrame)[-(1:2)] <- nms # Add confidenceInterval to the tableFrame - if (options$confidenceInterval){ + if (options$descriptivesTableCi){ ciDf <- .multComputeCIs(chisqResults[[1]][["observed"]], - options$confidenceIntervalInterval, - scale = options$countProp) + options$descriptivesTableCiLevel, + scale = options$descriptivesType) tableFrame <- cbind(tableFrame, ciDf) message <- gettext("Confidence intervals are based on independent binomial distributions.") results[["footnotes"]][["CImessage"]] <- message @@ -298,8 +298,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { # Create table chisqTable <- createJaspTable(title = "Multinomial Test") - chisqTable$dependOn(c("factor", "counts", "exProbVar", "tableWidget", - "VovkSellkeMPR", "hypothesis")) + chisqTable$dependOn(c("factor", "count", "expectedCount", "testValuesCustom", + "vovkSellke", "testValues")) chisqTable$showSpecifiedColumnsOnly <- TRUE # Add columns to table @@ -309,8 +309,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { chisqTable$addColumnInfo(name = "p", title = gettext("p"), type = "pvalue") # include Vovk-Selke p-ratio as columns - if (options$VovkSellkeMPR) { - chisqTable$addColumnInfo(name = "VovkSellkeMPR", title = gettextf("VS-MPR%s", "\u002A"), type = "number") + if (options$vovkSellke) { + chisqTable$addColumnInfo(name = "vovkSellke", title = gettextf("VS-MPR%s", "\u002A"), type = "number") chisqTable$addFootnote(.messages("footnote", "VovkSellkeMPR"), symbol = "\u002A") } @@ -332,25 +332,25 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { # Return: # Descriptives table - if(!options$descriptives || !is.null(jaspResults[["descriptivesTable"]])) + if(!options$descriptivesTable || !is.null(jaspResults[["descriptivesTable"]])) return() # Compute/get Results chisqResults <- .chisquareTest(jaspResults, dataset, options) descriptivesTable <- createJaspTable(title = gettext("Descriptives")) - descriptivesTable$dependOn(c("factor", "counts", "exProbVar", "hypothesis", "countProp", "descriptives", - "confidenceInterval", "tableWidget", "confidenceIntervalInterval")) + descriptivesTable$dependOn(c("factor", "count", "expectedCount", "testValues", "descriptivesType", "descriptivesTable", + "descriptivesTableCi", "testValuesCustom", "descriptivesTableCiLevel")) if(options$factor == ""){ descriptivesTable$addColumnInfo(name = "factor", title = gettext("Factor"), type = "string") - if (options$countProp == "descCounts") + if (options$descriptivesType == "counts") descriptivesTable$addColumnInfo(name = "observed", title = gettext("Observed"), type = "integer") else descriptivesTable$addColumnInfo(name = "observed", title = gettext("Observed"), type = "number") } else { descriptivesTable$addColumnInfo(name = "factor", title = options$factor, type = "string") - if (options$countProp == "descCounts") + if (options$descriptivesType == "counts") descriptivesTable$addColumnInfo(name = "observed", title = gettext("Observed"), type = "integer") else descriptivesTable$addColumnInfo(name = "observed", title = gettext("Observed"), type = "number") @@ -367,8 +367,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { } } } - if (options$confidenceInterval){ - interval <- 100 * options$confidenceIntervalInterval + if (options$descriptivesTableCi){ + interval <- 100 * options$descriptivesTableCiLevel title <- gettextf("%s%% Confidence Interval", interval) descriptivesTable$addColumnInfo(name = "lowerCI", title = gettext("Lower"), type = "number", overtitle = title) @@ -380,7 +380,7 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { return() res <- try(.multinomDescriptivesTableFill(jaspResults, options, chisqResults)) .multinomialSetError(res, descriptivesTable) - if(options$confidenceInterval) { + if(options$descriptivesTableCi) { message <- gettext("Confidence intervals are based on independent binomial distributions.") descriptivesTable$addFootnote(message) if (anyNA(unlist(descriptivesTable[["data"]][, c('lowerCI', 'upperCI')]))){ @@ -395,8 +395,8 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { return() descriptivesPlot <- createJaspPlot(title = gettext("Descriptives Plot"), width = 500, aspectRatio = 0.7) - descriptivesPlot$dependOn(c("factor", "counts", "descriptivesPlotConfidenceInterval", - "countProp", "descriptivesPlot")) + descriptivesPlot$dependOn(c("factor", "count", "descriptivesPlotCiLevel", + "descriptivesType", "descriptivesPlot")) jaspResults[["descriptivesPlot"]] <- descriptivesPlot @@ -415,7 +415,7 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { f <- names(chisqResults[[1]][["observed"]]) plotFrame <- data.frame(factor = factor(f, levels = rev(f))) # Counts or props - if (options$countProp == "descCounts") { + if (options$descriptivesType == "counts") { yname <- gettext("Observed counts") obs <- as.integer(chisqResults[[1]][["observed"]]) } else { @@ -426,10 +426,10 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { plotFrame <- cbind(plotFrame, obs) # Calculate confidence interval - if (options$descriptivesPlotConfidenceInterval){ + if (options$descriptivesPlotCiLevel){ ciDf <- .multComputeCIs(chisqResults[[1]][["observed"]], - options$descriptivesPlotConfidenceInterval, - ifErrorReturn = 0, scale = options$countProp) + options$descriptivesPlotCiLevel, + ifErrorReturn = 0, scale = options$descriptivesType) plotFrame <- cbind(plotFrame, ciDf) } @@ -470,7 +470,7 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { # hypotheses hyps <- list() - if (options$exProbVar == "" && options$hypothesis == "multinomialTest") { + if (options$expectedCount == "" && options$testValues == "equal") { # Expected probabilities are simple now hyps[["Multinomial"]] <- rep(1/nlevels, nlevels) } else { @@ -495,26 +495,26 @@ MultinomialTest <- function(jaspResults, dataset, options, ...) { # Return: # expected Probabilities - if (options$exProbVar != "") { - # use only exProbVar + if (options$expectedCount != "") { + # use only expectedCount fact <- dataset[[.v(options$factor)]] - eProps <- dataset[.v(options$exProbVar)] - colnames(eProps) <- options$exProbVar + eProps <- dataset[.v(options$expectedCount)] + colnames(eProps) <- options$expectedCount rownames(eProps) <- fact return(na.omit(eProps)) - } else if (length(options$tableWidget) > 0) { - eProps <- sapply(options$tableWidget, function(x) { + } else if (length(options$testValuesCustom) > 0) { + eProps <- sapply(options$testValuesCustom, function(x) { vals <- unlist(x$values) if (sum(vals) == 0) vals <- rep(1, length(vals)) return(vals) }) - colnames(eProps) <- sapply(seq_along(options$tableWidget), + colnames(eProps) <- sapply(seq_along(options$testValuesCustom), function(x) paste0("H\u2080 (", letters[x], ")")) - rownames(eProps) <- options$tableWidget[[1]]$levels + rownames(eProps) <- options$testValuesCustom[[1]]$levels return(as.data.frame(eProps)) } diff --git a/R/multinomialtestbayesian.R b/R/multinomialtestbayesian.R index c6f88817..115f3d2d 100644 --- a/R/multinomialtestbayesian.R +++ b/R/multinomialtestbayesian.R @@ -65,8 +65,8 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { a <- setNames(prior$values, prior$levels) factNms <- levels(fact) - if (options$counts != "") { - counts <- dataset[[.v(options$counts)]] + if (options$count != "") { + counts <- dataset[[.v(options$count)]] # omit count entries for which factor variable is NA counts <- counts[!is.na(fact)] dataTable <- counts @@ -97,28 +97,28 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { multinomialResults$mainTable[["nhyps"]] <- nhyps # Results for descriptives plot - multinomialResults$descriptivesPlot[["descProps"]] <- .multComputeCIs(dataTable, options$descriptivesPlotCredibleInterval, ifErrorReturn = 0, scale = 'descProbs') - multinomialResults$descriptivesPlot[["descCounts"]] <- multinomialResults$descriptivesPlot[["descProps"]] * N - multinomialResults$descriptivesPlot[["descProps"]][["observed"]] <- as.numeric(dataTable)/N - multinomialResults$descriptivesPlot[["descCounts"]][["observed"]] <- as.numeric(dataTable) - multinomialResults$descriptivesPlot[["descProps"]][["fact"]] <- factNms - multinomialResults$descriptivesPlot[["descCounts"]][["fact"]] <- factNms + multinomialResults$descriptivesPlot[["proportions"]] <- .multComputeCIs(dataTable, options$descriptivesPlotCiLevel, ifErrorReturn = 0, scale = "proportions") + multinomialResults$descriptivesPlot[["counts"]] <- multinomialResults$descriptivesPlot[["proportions"]] * N + multinomialResults$descriptivesPlot[["proportions"]][["observed"]] <- as.numeric(dataTable)/N + multinomialResults$descriptivesPlot[["counts"]][["observed"]] <- as.numeric(dataTable) + multinomialResults$descriptivesPlot[["proportions"]][["fact"]] <- factNms + multinomialResults$descriptivesPlot[["counts"]][["fact"]] <- factNms # Results for descriptives table - multinomialResults$descriptivesTable[["descProps"]][["fact"]] <- factNms - multinomialResults$descriptivesTable[["descCounts"]][["fact"]] <- factNms - multinomialResults$descriptivesTable[["descProps"]][["observed"]] <- as.numeric(dataTable)/N - multinomialResults$descriptivesTable[["descCounts"]][["observed"]] <- as.numeric(dataTable) + multinomialResults$descriptivesTable[["proportions"]][["fact"]] <- factNms + multinomialResults$descriptivesTable[["counts"]][["fact"]] <- factNms + multinomialResults$descriptivesTable[["proportions"]][["observed"]] <- as.numeric(dataTable)/N + multinomialResults$descriptivesTable[["counts"]][["observed"]] <- as.numeric(dataTable) for(h in 1:nhyps) { - multinomialResults$descriptivesTable[["descProps"]][[nms[h]]] <- multinomialResults$mainTable[[nms[h]]]$expected/N - multinomialResults$descriptivesTable[["descCounts"]][[nms[h]]] <- multinomialResults$mainTable[[nms[h]]]$expected + multinomialResults$descriptivesTable[["proportions"]][[nms[h]]] <- multinomialResults$mainTable[[nms[h]]]$expected/N + multinomialResults$descriptivesTable[["counts"]][[nms[h]]] <- multinomialResults$mainTable[[nms[h]]]$expected } - multinomialResults$descriptivesTable[["descProps"]] <- setNames(as.data.frame(multinomialResults$descriptivesTable[["descProps"]]), c("fact", "observed", nms)) - multinomialResults$descriptivesTable[["descCounts"]] <- setNames(as.data.frame(multinomialResults$descriptivesTable[["descCounts"]]), c("fact", "observed", nms)) - multinomialResults$descriptivesTable[["descPropsCI"]] <- .multComputeCIs(dataTable, options$credibleIntervalInterval, scale = "descProbs") - multinomialResults$descriptivesTable[["descCountsCI"]] <- .multComputeCIs(dataTable, options$credibleIntervalInterval, scale = "descCounts") + multinomialResults$descriptivesTable[["proportions"]] <- setNames(as.data.frame(multinomialResults$descriptivesTable[["proportions"]]), c("fact", "observed", nms)) + multinomialResults$descriptivesTable[["counts"]] <- setNames(as.data.frame(multinomialResults$descriptivesTable[["counts"]]), c("fact", "observed", nms)) + multinomialResults$descriptivesTable[["proportionsCI"]] <- .multComputeCIs(dataTable, options$descriptivesTableCiLevel, scale = "proportions") + multinomialResults$descriptivesTable[["countsCI"]] <- .multComputeCIs(dataTable, options$descriptivesTableCiLevel, scale = "counts") # Save results to state defaultOptions <- multinomialResults$specs$defaultOptions @@ -185,7 +185,7 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { #' @return descriptivesTable descriptives table .createMultBayesDescriptivesTable <- function(jaspResults, options, multinomialResults, bayesianAnalysis = TRUE){ - if(!options[["descriptives"]]) + if(!options[["descriptivesTable"]]) return() # Create table @@ -193,17 +193,17 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { # settings for Bayesian and frequentist analysis if(bayesianAnalysis){ - ciRequested <- options$credibleInterval - ciInterval <- options$credibleIntervalInterval + ciRequested <- options$descriptivesTableCi + ciInterval <- options$descriptivesTableCiLevel ciType <- gettext("Credible") tableFootnote <- gettext("Credible intervals are based on independent binomial distributions with flat priors.") - descriptivesTable$dependOn(c("countProp", "descriptives", "credibleIntervalInterval")) + descriptivesTable$dependOn(c("descriptivesType", "descriptivesTable", "descriptivesTableCiLevel")) } else { - ciRequested <- options$confidenceInterval - ciInterval <- options$confidenceIntervalInterval + ciRequested <- options$descriptivesTableCi + ciInterval <- options$descriptivesTableCiLevel ciType <- gettext("Confidence") tableFootnote <- gettext("Confidence intervals are based on independent binomial distributions.") - descriptivesTable$dependOn(c("countProp", "descriptives", "confidenceIntervalInterval")) + descriptivesTable$dependOn(c("descriptivesType", "descriptivesTable", "descriptivesTableCiLevel")) } descriptivesTable$showSpecifiedColumnsOnly <- TRUE @@ -211,7 +211,7 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { factorVariable <- multinomialResults[["specs"]][["factorVariable"]] - if(options$countProp == "descCounts") + if(options$descriptivesType == "counts") numberType <- "integer" else numberType <- "number" @@ -249,10 +249,10 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { return() # Add rows - descDF <- multinomialResults[["descriptivesTable"]][[options$countProp]] + descDF <- multinomialResults[["descriptivesTable"]][[options$descriptivesType]] if(ciRequested){ - ciInfo <- multinomialResults[["descriptivesTable"]][[paste0(options$countProp, "CI")]] + ciInfo <- multinomialResults[["descriptivesTable"]][[paste0(options$descriptivesType, "CI")]] descDF <- cbind(descDF, ciInfo) descriptivesTable$addFootnote(tableFootnote) @@ -280,7 +280,7 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { descriptivesPlot <- .multBayesPlotHelper(factorVariable, options, multinomialResults) jaspResults[["descriptivesPlot"]] <- createJaspPlot(plot = descriptivesPlot, title = gettext("Descriptives plot"), width = 480, height = 320) - jaspResults[["descriptivesPlot"]]$dependOn(c("descriptivesPlot", "factor", "counts", "descriptivesPlotsCredibleInterval")) + jaspResults[["descriptivesPlot"]]$dependOn(c("descriptivesPlot", "factor", "count", "descriptivesPlotCiLevel")) descriptivesPlot$position <- 2 } @@ -296,7 +296,7 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { # set function behaviour, if analysis crashes errorReturn <- rep(ifErrorReturn, 2) - div <- ifelse(scale == 'descCounts', sum(counts), 1) + div <- ifelse(scale == 'counts', sum(counts), 1) N <- sum(counts) ciDf <- data.frame(lowerCI = NA, upperCI = NA) @@ -334,14 +334,14 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { } # Counts or props - if (options$countProp == "descCounts") { + if (options$descriptivesType == "counts") { yname <- gettext("Observed Counts") } else { yname <- gettext("Observed Proportions") } # Prepare data for plotting - plotFrame <- multinomialResults[["descriptivesPlot"]][[options$countProp]] + plotFrame <- multinomialResults[["descriptivesPlot"]][[options$descriptivesType]] # We need to reverse the factor's levels because of the coord_flip later plotFrame$fact <- factor(plotFrame$fact, levels = rev(plotFrame$fact)) @@ -416,8 +416,8 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { specs <- list() # Default options - specs$defaultOptions <- c("tableWidget", "priorCounts","factor", "counts", "exProbVar", "hypothesis", - "credibleIntervalInterval") + specs$defaultOptions <- c("testValuesCustom", "priorCounts","factor", "count", "expectedCount", "testValues", + "descriptivesTableCiLevel") # Ready statement specs$ready <- options$factor != "" && !is.null(dataset) @@ -429,20 +429,20 @@ MultinomialTestBayesian <- function(jaspResults, dataset, options, ...) { if (options$factor != "") { specs$factorVariable <- options$factor # Specify count variable - if (options$counts != "") { - specs$countVariable <- options$counts + if (options$count != "") { + specs$countVariable <- options$count } - if (options$exProbVar != "") { - specs$exProbVariable <- options$exProbVar + if (options$expectedCount != "") { + specs$exProbVariable <- options$expectedCount } } - if(options$exProbVar != "") { + if(options$expectedCount != "") { specs$hypNames <- specs$exProbVariable - } else if(options$hypothesis == "multinomialTest") { + } else if(options$testValues == "equal") { specs$hypNames <- "Multinomial" - } else if(options$hypothesis == "expectedProbs") { - specs$hypNames <- sapply(seq_along(options$tableWidget), function(x) paste0("H\u2080 (", letters[x], ")")) + } else if(options$testValues == "custom") { + specs$hypNames <- sapply(seq_along(options$testValuesCustom), function(x) paste0("H\u2080 (", letters[x], ")")) } else if(!is.null(specs$exProbVariable)) { specs$hypNames <- specs$exProbVariable } diff --git a/R/regressionloglinear.R b/R/regressionloglinear.R index 2fc07146..62d0c615 100644 --- a/R/regressionloglinear.R +++ b/R/regressionloglinear.R @@ -35,8 +35,8 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { return(dataset) else { counts <- factors <- NULL - if(options$counts != "") - counts <- options$counts + if(options$count != "") + counts <- options$count if(length(options$modelTerms) > 0) factors <- options$modelTerms return(.readDataSetToEnd(columns.as.factor = factors, @@ -54,9 +54,9 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { exitAnalysisIfErrors = TRUE ) - if (options$counts != "") { + if (options$count != "") { args$type <- c(args$type, "infinity", "negativeValues") - args$missingValues.target <- c(options$counts, options$factors) + args$missingValues.target <- c(options$count, options$factors) } do.call(.hasErrors, args) } @@ -67,16 +67,16 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { return(jaspResults[["Model"]]$object) modelTerms <- unlist(options$modelTerms) - if (options$counts == "") + if (options$count == "") dataset <- plyr::count(dataset) loglm.model <- list() empty.model <- list(loglm.fit = NULL, variables = NULL) - if (options$counts == "") + if (options$count == "") dependent.variable <- "freq" else - dependent.variable <- unlist(options$counts) + dependent.variable <- unlist(options$count) if (length(options$modelTerms) > 0) { @@ -113,7 +113,7 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { model.formula <- as.formula(model.definition) - if (options$counts == "") + if (options$count == "") names(dataset)[names(dataset) == "freq"] <- dependent.base64 loglm.fit <- try(stats::glm(model.formula, family = poisson(), @@ -129,7 +129,7 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { loglm.model <- empty.model jaspResults[["Model"]] <- createJaspState(loglm.model) - jaspResults[["Model"]]$dependOn(c("counts","modelTerms")) + jaspResults[["Model"]]$dependOn(c("count","modelTerms")) return(loglm.model) } @@ -161,16 +161,16 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { results[[ len.logreg ]]$df <- " " results[[ len.logreg ]]$dev <- " " results[[ len.logreg ]]$p <- " " - if (options$VovkSellkeMPR) - results[[ len.logreg ]]$VovkSellkeMPR <- " " + if (options$vovkSellke) + results[[ len.logreg ]]$vovkSellke <- " " } else { results[[ len.logreg ]]$name <- model.name[var] results[[ len.logreg ]]$df <- as.integer(loglm.estimates$Df[var]) results[[ len.logreg ]]$dev <- as.numeric(loglm.estimates$Deviance[var]) pVal <- as.numeric(loglm.estimates$"Pr(>Chi)"[var]) results[[ len.logreg ]]$p <- pVal - if (options$VovkSellkeMPR) - results[[ len.logreg ]]$VovkSellkeMPR <- VovkSellkeMPR(pVal) + if (options$vovkSellke) + results[[ len.logreg ]]$vovkSellke <- VovkSellkeMPR(pVal) } results[[ len.logreg ]]$resDf <- as.integer(loglm.estimates$"Resid. Df"[var]) res <- as.numeric(loglm.estimates$"Resid. Dev"[var]) @@ -198,7 +198,7 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { loglm.estimates <- loglm.summary$coefficients loglm.coeff <- loglm.estimates[,"Estimate"] loglm.estimates.SE <- loglm.estimates[,"Std. Error"] - sig <- options$regressionCoefficientsConfidenceIntervalsInterval + sig <- options$regressionCoefficientsCiLevel alpha <- (1 - sig) / 2 lower <- loglm.coeff + stats::qnorm(alpha)*loglm.estimates.SE upper <- loglm.coeff + stats::qnorm(1-alpha)*loglm.estimates.SE @@ -226,21 +226,21 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { Z <- as.numeric(loglm.estimates[i,3]) p <- as.numeric(loglm.estimates[i,4]) - if (options$VovkSellkeMPR) - VovkSellkeMPR <- VovkSellkeMPR(p) + if (options$vovkSellke) + vovkSellke <- VovkSellkeMPR(p) results[[len.logreg]] <- list( name = name, Coeff = Coefficient, SE = sd ) - if(options$regressionCoefficientsConfidenceIntervals){ + if(options$regressionCoefficientsCi){ results[[len.logreg]]$Lower <- as.numeric(lower[i]) results[[len.logreg]]$Upper <- as.numeric(upper[i]) } results[[len.logreg]]$Z <- Z results[[len.logreg]]$p <- p - if(options$VovkSellkeMPR) - results[[len.logreg]]$VovkSellkeMPR <- VovkSellkeMPR + if(options$vovkSellke) + results[[len.logreg]]$vovkSellke <- vovkSellke len.logreg <- len.logreg + 1 } @@ -256,7 +256,7 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { # Create table anovaTable <- createJaspTable(title = gettext("ANOVA")) - anovaTable$dependOn(c("counts", "modelTerms", "VovkSellkeMPR")) + anovaTable$dependOn(c("count", "modelTerms", "vovkSellke")) .regLogLinCitation(anovaTable) anovaTable$showSpecifiedColumnsOnly <- TRUE anovaTable$position <- 1 @@ -268,7 +268,7 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { anovaTable$addColumnInfo(name = "resDf", title = gettext("Residual df"), type = "integer") anovaTable$addColumnInfo(name = "resDev", title = gettext("Residual Deviance"), type = "number") anovaTable$addColumnInfo(name = "p", title = gettext("p"), type = "pvalue") - if (options$VovkSellkeMPR) + if (options$vovkSellke) .regLogLinAddVovkSellke(anovaTable) jaspResults[["AnovaTable"]] <- anovaTable @@ -290,9 +290,9 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { # Create table coefficientsTable <- createJaspTable(title = gettext("Coefficients")) - dependList <- c("counts", "modelTerms", "regressionCoefficientsEstimates", - "VovkSellkeMPR", "regressionCoefficientsConfidenceIntervals", - "regressionCoefficientsConfidenceIntervalsInterval") + dependList <- c("count", "modelTerms", "regressionCoefficientsEstimates", + "vovkSellke", "regressionCoefficientsCi", + "regressionCoefficientsCiLevel") coefficientsTable$dependOn(dependList) .regLogLinCitation(coefficientsTable) coefficientsTable$showSpecifiedColumnsOnly <- TRUE @@ -302,16 +302,16 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { coefficientsTable$addColumnInfo(name = "name", title = "", type = "string") coefficientsTable$addColumnInfo(name = "Coeff", title = gettext("Estimate"), type = "number", format = "dp:3") coefficientsTable$addColumnInfo(name = "SE", title = gettext("Standard Error"), type = "number", format = "dp:3") - if(options$regressionCoefficientsConfidenceIntervals){ - confIntVal <- options$regressionCoefficientsConfidenceIntervalsInterval + if(options$regressionCoefficientsCi){ + confIntVal <- options$regressionCoefficientsCiLevel ci <- gettextf("%s%% Confidence Intervals",100*confIntVal) coefficientsTable$addColumnInfo(name = "Lower", title = gettext("Lower"), type = "number", overtitle = ci) coefficientsTable$addColumnInfo(name = "Upper", title = gettext("Upper"), type = "number", overtitle = ci) } coefficientsTable$addColumnInfo(name = "Z", title = gettext("Z"), type = "number") coefficientsTable$addColumnInfo(name = "p", title = gettext("p"), type = "pvalue") - if (options$VovkSellkeMPR) - coefficientsTable$addColumnInfo(name = "VovkSellkeMPR", title = gettextf("VS-MPR%s", "\u002A"), type = "number") + if (options$vovkSellke) + coefficientsTable$addColumnInfo(name = "vovkSellke", title = gettextf("VS-MPR%s", "\u002A"), type = "number") jaspResults[["CoefficientsTable"]] <- coefficientsTable @@ -346,13 +346,15 @@ RegressionLogLinear <- function(jaspResults, dataset = NULL , options, ...) { "resDf" = char, "resDev" = char, "p" = char) - if (options$VovkSellkeMPR) - line$VovkSellkeMPR <- char + + if (options$vovkSellke) + line$vovkSellke <- char + return(line) } .regLogLinAddVovkSellke <- function(table) { - table$addColumnInfo(name = "VovkSellkeMPR", title = gettextf("VS-MPR%s","\u002A"), type = "number") + table$addColumnInfo(name = "vovkSellke", title = gettextf("VS-MPR%s","\u002A"), type = "number") message <- gettextf("Vovk-Sellke Maximum p-Ratio: Based the p-value, \ the maximum possible odds in favor of H%1$s over H%2$s equals \ 1/(-e p log(p)) for p %3$s .37 \ diff --git a/R/regressionloglinearbayesian.R b/R/regressionloglinearbayesian.R index a75edd7a..c5e70ef0 100644 --- a/R/regressionloglinearbayesian.R +++ b/R/regressionloglinearbayesian.R @@ -38,8 +38,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. return(dataset) else { counts <- factors <- NULL - if(options$counts != "") - counts <- options$counts + if(options$count != "") + counts <- options$count if(length(options$modelTerms) > 0) factors <- options$factors return(.readDataSetToEnd(columns.as.factor = factors, @@ -57,9 +57,10 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. exitAnalysisIfErrors = TRUE ) - if (options$counts != "") { + if (options$count != "") { + args$type <- c(args$type, "infinity", "negativeValues") - args$missingValues.target <- c(options$counts, options$factors) + args$missingValues.target <- c(options$count, options$factors) } do.call(.hasErrors, args) @@ -80,14 +81,14 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. numberOfModels <- length(options$modelTerms) variablesInModel <- bcctObj <- NULL - if (options$counts == "") + if (options$count == "") dataset <- plyr::count(dataset) # Extract models needed to be compared - if (options$counts == "") + if (options$count == "") dependentVariable <- "freq" else - dependentVariable <- unlist(options$counts) + dependentVariable <- unlist(options$count) dependentBase64 <- .v(dependentVariable) if (length(options$modelTerms) > 0) { @@ -116,10 +117,11 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. if (length(variablesInModel) == 0) { variablesInModel <- c("...", "... ") modelDefinition <- NULL #this model has no parameters - } else if (length(variablesInModel) == 1 && options$counts == "") { + } else if (length(variablesInModel) == 1 && options$count == "") { variablesInModel <- c(variablesInModel, "... ") modelDefinition <- NULL #this model has only one parameter - } else if (length(variablesInModel) > 1 || options$counts != "") { + + } else if (length(variablesInModel) > 1 || options$count != "") { modelDefinition <- paste(dependentBase64, "~", paste(variablesInModelBase64, collapse = "+")) } else { @@ -134,7 +136,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. if (!is.null(modelDefinition)) { modelFormula <- as.formula(modelDefinition) - if (options$counts == "") + if (options$count == "") names(dataset)[names(dataset) == "freq"] <- dependentBase64 # Calculate here #gives an object computed using Bayesian Analysis of Complete Contingency Tables @@ -146,12 +148,12 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. bfObject$nBurnIn <- 2000 * 0.2 # Always do auto and then manual adds additional samples - if (options$sampleMode == "manual"){ + if (options$samplingMethod == "manual"){ .setSeedJASP(options) bcctObj <- try(conting::bcctu(object = bcctObj, - n.sample = options$fixedSamplesNumber), + n.sample = options$samplingMethodManualSamples), silent = TRUE) - bfObject$nBurnIn <- (2000 + options$fixedSamplesNumber) * 0.2 + bfObject$nBurnIn <- (2000 + options$samplingMethodManualSamples) * 0.2 } # bcct object checking @@ -173,7 +175,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. # then nothing going on, resample # bcctSummary <- try(conting::mod_probs(bfObject$bcctObj, scale = 0, - best = options$maxModels), silent = TRUE) + best = options$modelCutOffBestDisplayed), silent = TRUE) if (inherits(bcctSummary, "modprobs")) { # Good case @@ -197,7 +199,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. } } container[["bfObject"]] <- createJaspState(bfObject) - container[["bfObject"]]$dependOn(c("fixedSamplesNumber", "sampleMode", "seed", "setSeed", "maxModels")) + container[["bfObject"]]$dependOn(c("samplingMethodManualSamples", "samplingMethod", "seed", "setSeed", "modelCutOffBestDisplayed")) return(bfObject) } @@ -208,7 +210,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. posteriorTableRows <- list() results <- list() - nModelsReport <- try(min(bfObject$nModelsVisited, options$maxModels)) + nModelsReport <- try(min(bfObject$nModelsVisited, options$modelCutOffBestDisplayed)) if (!is.null(bfObject$modelNames)) reportNames <- .unvf(bfObject$modelNames) else if (!is.null(bfObject$variables)) @@ -254,10 +256,10 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. lookup.table[["(Intercept)"]] <- gettext("(Intercept)") if(inherits(bfObject$bcctObj, "bcct")) { - probLevel <- options$regressionCoefficientsCredibleIntervalsInterval + probLevel <- options$regressionCoefficientsCiLevel logBlm.summary <- summary(bfObject$bcctObj, n.burnin = bfObject$nBurnIn, - cutoff = options$posteriorProbabilityCutOff, + cutoff = options$modelCutOffPosteriorProbability, prob.level = probLevel) logBlm.estimates <- logBlm.summary$int_stats @@ -285,7 +287,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. results[[ len.Blogreg ]]$"post_mean" <- as.numeric(logBlm.estimates$post_mean[var]) results[[ len.Blogreg ]]$"post_var" <- as.numeric(logBlm.estimates$post_var[var]) - if (options$regressionCoefficientsCredibleIntervals == TRUE){ + if (options$regressionCoefficientsCi == TRUE){ results[[ len.Blogreg ]]$"lower_lim" <- as.numeric(logBlm.estimates$lower[var]) results[[ len.Blogreg ]]$"upper_lim" <- as.numeric(logBlm.estimates$upper[var]) } @@ -336,7 +338,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. lookup.table[["(Intercept)"]] <- gettext("(Intercept)") if (!is.null(bfObject$bcctObj)) { - probLevel <- options$regressionCoefficientsSubmodelCredibleIntervalsInterval + probLevel <- options$regressionCoefficientsSubmodelCiLevel order <- options$regressionCoefficientsSubmodelNo logBlm.subestimates = try(conting::sub_model(bfObject$bcctObj, n.burnin = bfObject$nBurnIn, @@ -377,7 +379,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. results[[ len.Blogreg ]]$"post_mean" <- as.numeric(logBlm.subestimates$post_mean[var]) results[[ len.Blogreg ]]$"post_var" <- as.numeric(logBlm.subestimates$post_var[var]) - if (options$regressionCoefficientsSubmodelCredibleIntervals){ + + if (options$regressionCoefficientsSubmodelCi){ results[[ len.Blogreg ]]$"lower_lim" <- as.numeric(logBlm.subestimates$lower[var]) results[[ len.Blogreg ]]$"upper_lim" <- as.numeric(logBlm.subestimates$upper[var]) } @@ -427,8 +430,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. .basRegLogLinContainer <- function(jaspResults, dataset, options) { if(is.null(jaspResults[["Container"]])) { jaspResults[["Container"]] <- createJaspContainer() - jaspResults[["Container"]]$dependOn(c("counts", "modelTerms", "priorShape", - "priorScale", "sampleMode", "fixedSamplesNumber", "seed", "setSeed")) + jaspResults[["Container"]]$dependOn(c("count", "modelTerms", "priorShape", + "priorScale", "samplingMethod", "samplingMethodManualSamples", "seed", "setSeed")) } } @@ -439,7 +442,7 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. # Create table mainTable <- createJaspTable(title = gettext("Model Comparison")) - mainTable$dependOn(c("bayesFactorType", "maxModels", "posteriorProbabilityCutOff")) + mainTable$dependOn(c("bayesFactorType", "modelCutOffBestDisplayed", "modelCutOffPosteriorProbability")) .basRegLogLinCitation(mainTable) mainTable$showSpecifiedColumnsOnly <- TRUE mainTable$position <- 1 @@ -471,8 +474,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. # Create table summaryTable <- createJaspTable(title = gettext("Posterior Summary Statistics")) summaryTable$dependOn(c("regressionCoefficientsEstimates", - "regressionCoefficientsCredibleIntervals", - "regressionCoefficientsCredibleIntervalsInterval")) + "regressionCoefficientsCi", + "regressionCoefficientsCiLevel")) .basRegLogLinCitation(summaryTable) summaryTable$showSpecifiedColumnsOnly <- TRUE summaryTable$position <- 2 @@ -482,8 +485,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. summaryTable$addColumnInfo(name = "post_prob", title = gettext("P(incl|data)"), type = "number", format = "dp:3") summaryTable$addColumnInfo(name = "post_mean", title = gettext("Mean"), type = "number", format = "dp:3") summaryTable$addColumnInfo(name = "post_var", title = gettext("Variance"), type = "number", format = "dp:3") - if(options$regressionCoefficientsCredibleIntervals){ - ci.label <- gettextf("%s%% Credible intervals", 100*options$regressionCoefficientsCredibleIntervalsInterval) + if(options$regressionCoefficientsCi){ + ci.label <- gettextf("%s%% Credible intervals", 100*options$regressionCoefficientsCiLevel) summaryTable$addColumnInfo(name = "lower_lim", title = gettext("Lower"), type = "number", overtitle = ci.label) summaryTable$addColumnInfo(name = "upper_lim", title = gettext("Upper"), type = "number", overtitle = ci.label) } @@ -508,8 +511,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. subSummaryTable <- createJaspTable(title = title) subSummaryTable$dependOn(c("regressionCoefficientsSubmodel", - "regressionCoefficientsSubmodelCredibleIntervals", - "regressionCoefficientsSubmodelCredibleIntervalsInterval", + "regressionCoefficientsSubmodelCi", + "regressionCoefficientsSubmodelCiLevel", "regressionCoefficientsSubmodelNo")) .basRegLogLinCitation(subSummaryTable) subSummaryTable$showSpecifiedColumnsOnly <- TRUE @@ -520,8 +523,8 @@ RegressionLogLinearBayesian <- function(jaspResults, dataset = NULL, options, .. subSummaryTable$addColumnInfo(name = "post_mean", title = gettext("Mean"), type = "number", format = "dp:3") subSummaryTable$addColumnInfo(name = "post_var", title = gettext("Variance"), type = "number", format = "dp:3") - if(options$regressionCoefficientsSubmodelCredibleIntervals){ - ciVal <- options$regressionCoefficientsSubmodelCredibleIntervalsInterval + if(options$regressionCoefficientsSubmodelCi){ + ciVal <- options$regressionCoefficientsSubmodelCiLevel ci.label <- gettextf("%.0f%% Credible intervals", 100*ciVal) subSummaryTable$addColumnInfo(name = "lower_lim", title = gettext("Lower"), type = "number", overtitle = ci.label) diff --git a/inst/Upgrades.qml b/inst/Upgrades.qml new file mode 100644 index 00000000..6e6aa6c9 --- /dev/null +++ b/inst/Upgrades.qml @@ -0,0 +1,285 @@ +import QtQuick 2.12 +import JASP.Module 1.0 + +Upgrades +{ + Upgrade + { + functionName: "BinomialTest" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "hypothesis"; to: "alternative" } + ChangeJS + { + name: "alternative" + jsFunction: function(options) + { + switch(options["alternative"]) + { + case "notEqualToTestValue": return "twoSided"; + case "greaterThanTestValue": return "greater"; + case "lessThanTestValue": return "less"; + } + } + } + ChangeRename{ from: "confidenceInterval"; to: "ci" } + ChangeRename{ from: "confidenceIntervalInterval"; to: "ciLevel" } + ChangeRename{ from: "VovkSellkeMPR"; to: "vovkSellke" } + ChangeRename{ from: "descriptivesPlots"; to: "descriptivesPlot" } + ChangeRename{ from: "descriptivesPlotsConfidenceInterval"; to: "descriptivesPlotCiLevel" } + } + + Upgrade + { + functionName: "BinomialTestBayesian" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "hypothesis"; to: "alternative" } + ChangeJS + { + name: "alternative" + jsFunction: function(options) + { + switch(options["alternative"]) + { + case "notEqualToTestValue": return "twoSided"; + case "greaterThanTestValue": return "greater"; + case "lessThanTestValue": return "less"; + } + } + } + ChangeRename{ from: "plotPriorAndPosterior"; to: "priorPosteriorPlot" } + ChangeRename{ from: "plotPriorAndPosteriorAdditionalInfo"; to: "priorPosteriorPlotAdditionalInfo" } + ChangeRename{ from: "plotSequentialAnalysis"; to: "bfSequentialPlot" } + ChangeRename{ from: "descriptivesPlots"; to: "descriptivesPlot" } + ChangeRename{ from: "descriptivesPlotsCredibleInterval"; to: "descriptivesPlotCiLevel" } + } + + Upgrade + { + functionName: "MultinomialTest" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + // this option did not do anything and was always hidden so now it's removed + ChangeRemove{ name: "simulatepval" } + ChangeRename{ from: "counts"; to: "count" } + ChangeRename{ from: "exProbVar"; to: "expectedCount" } + ChangeRename{ from: "hypothesis"; to: "testValues" } + ChangeJS + { + name: "testValues" + jsFunction: function(options) + { + switch(options["testValues"]) + { + case "multinomialTest": return "equal"; + case "expectedProbs": return "custom"; + } + } + } + ChangeRename{ from: "tableWidget"; to: "testValuesCustom" } + ChangeRename{ from: "VovkSellkeMPR"; to: "vovkSellke" } + ChangeRename{ from: "descriptives"; to: "descriptivesTable" } + ChangeRename{ from: "confidenceInterval"; to: "descriptivesTableCi" } + ChangeRename{ from: "confidenceIntervalInterval"; to: "descriptivesTableCiLevel" } + ChangeRename{ from: "countProp"; to: "descriptivesType" } + ChangeJS + { + name: "descriptivesType" + jsFunction: function(options) + { + switch(options["descriptivesType"]) + { + case "descCounts": return "counts"; + case "descProps": return "proportions"; + } + } + } + ChangeRename{ from: "descriptivesPlotConfidenceInterval"; to: "descriptivesPlotCiLevel" } + } + + Upgrade + { + functionName: "MultinomialTestBayesian" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "counts"; to: "count" } + ChangeRename{ from: "exProbVar"; to: "expectedCount" } + ChangeRename{ from: "hypothesis"; to: "testValues" } + ChangeJS + { + name: "testValues" + jsFunction: function(options) + { + switch(options["testValues"]) + { + case "multinomialTest": return "equal"; + case "expectedProbs": return "custom"; + } + } + } + ChangeRename{ from: "tableWidget"; to: "testValuesCustom" } + ChangeRename{ from: "descriptives"; to: "descriptivesTable" } + ChangeRename{ from: "credibleInterval"; to: "descriptivesTableCi" } + ChangeRename{ from: "credibleIntervalInterval"; to: "descriptivesTableCiLevel" } + ChangeRename{ from: "countProp"; to: "descriptivesType" } + ChangeJS + { + name: "descriptivesType" + jsFunction: function(options) + { + switch(options["descriptivesType"]) + { + case "descCounts": return "counts"; + case "descProps": return "proportions"; + } + } + } + ChangeRename{ from: "descriptivesPlotCredibleInterval"; to: "descriptivesPlotCiLevel" } + } + + Upgrade + { + functionName: "ContingencyTables" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "VovkSellkeMPR"; to: "vovkSellke" } + ChangeRename{ from: "LogOdds"; to: "oddsRatioAsLogOdds" } + ChangeRename{ from: "oddsRatioConfidenceIntervalInterval"; to: "oddsRatioCiLevel" } + ChangeRename{ from: "oddsRatioHypothesis"; to: "oddsRatioAlternative" } + ChangeSetValue + { + name: "oddsRatioAlternative" + condition: function(options) { return options["oddsRatioAlternative"] === "two.sided" } + jsonValue: "twoSided" + } + ChangeRename{ from: "cochransAndMantel"; to: "cochranAndMantel" } + ChangeRename{ from: "testOddsRatioEquals"; to: "cochranAndMantelCommonOddsRatioTest" } + ChangeRename{ from: "hideSmallCounts"; to: "countsHiddenSmallCounts" } + ChangeRename{ from: "hideSmallCountsLessThan"; to: "countsHiddenSmallCountsThreshold" } + ChangeRename{ from: "zTestCompareColumns"; to: "zTestColumnComparison" } + ChangeRename{ from: "zTestAdjustPValues"; to: "zTestAdjustedPValues" } + } + + Upgrade + { + functionName: "ContingencyTablesBayesian" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "oddsRatioCredibleIntervalInterval"; to: "oddsRatioCiLevel" } + ChangeRename{ from: "effectSize"; to: "cramersV" } + ChangeRename{ from: "effectSizeCredibleIntervalInterval"; to: "cramersVCiLevel" } + ChangeRename{ from: "hypothesis"; to: "alternative" } + ChangeJS + { + name: "alternative" + jsFunction: function(options) + { + switch(options["alternative"]) + { + case "groupsNotEqual": return "twoSided"; + case "groupOneGreater": return "greater"; + case "groupTwoGreater": return "less"; + } + } + } + ChangeRename{ from: "plotPosteriorOddsRatio"; to: "posteriorOddsRatioPlot" } + ChangeRename{ from: "plotPosteriorOddsRatioAdditionalInfo"; to: "posteriorOddsRatioPlotAdditionalInfo" } + ChangeRename{ from: "plotPosteriorEffectSize"; to: "cramersVPlot" } + } + + Upgrade + { + functionName: "RegressionLogLinear" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "counts"; to: "count" } + ChangeRename{ from: "regressionCoefficientsConfidenceIntervals"; to: "regressionCoefficientsCi" } + ChangeRename{ from: "regressionCoefficientsConfidenceIntervalsInterval"; to: "regressionCoefficientsCiLevel" } + ChangeRename{ from: "VovkSellkeMPR"; to: "vovkSellke" } + } + + Upgrade + { + functionName: "RegressionLogLinearBayesian" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "counts"; to: "count" } + ChangeRename{ from: "maxModels"; to: "modelCutOffBestDisplayed" } + ChangeRename{ from: "posteriorProbabilityCutOff"; to: "modelCutOffPosteriorProbability" } + ChangeRename{ from: "regressionCoefficientsCredibleIntervals"; to: "regressionCoefficientsCi" } + ChangeRename{ from: "regressionCoefficientsCredibleIntervalsInterval"; to: "regressionCoefficientsCiLevel" } + ChangeRename{ from: "regressionCoefficientsSubmodelCredibleIntervals"; to: "regressionCoefficientsSubmodelCi" } + ChangeRename{ from: "regressionCoefficientsSubmodelCredibleIntervalsInterval"; to: "regressionCoefficientsSubmodelCiLevel" } + ChangeRename{ from: "sampleMode"; to: "samplingMethod" } + ChangeRename{ from: "fixedSamplesNumber"; to: "samplingMethodManualSamples" } + } + + Upgrade + { + functionName: "ABTestBayesian" + fromVersion: "0.16.4" + toVersion: "0.17.0" + + ChangeRename{ from: "normal_mu"; to: "normalPriorMean" } + ChangeRename{ from: "normal_sigma"; to: "normalPriorSd" } + ChangeRename{ from: "descriptives"; to: "descriptivesTable" } + ChangeRename{ from: "plotPriorAndPosterior"; to: "priorPosteriorPlot" } + ChangeRename{ from: "plotPosteriorType"; to: "priorPosteriorPlotType" } + ChangeJS + { + name: "priorPosteriorPlotType" + jsFunction: function(options) + { + switch(options["priorPosteriorPlotType"]) + { + case "LogOddsRatio": return "logOddsRatio"; + case "OddsRatio": return "oddsRatio"; + case "RelativeRisk": return "relativeRisk"; + case "AbsoluteRisk": return "absoluteRisk"; + case "p1&p2": return "p1P2"; + } + } + } + ChangeRename{ from: "plotSequentialAnalysis"; to: "bfSequentialPlot" } + ChangeRename{ from: "plotPriorOnly"; to: "priorPlot" } + ChangeRename{ from: "plotPriorType"; to: "priorPlotType" } + ChangeJS + { + name: "priorPlotType" + jsFunction: function(options) + { + switch(options["priorPlotType"]) + { + case "LogOddsRatio": return "logOddsRatio"; + case "OddsRatio": return "oddsRatio"; + case "RelativeRisk": return "relativeRisk"; + case "AbsoluteRisk": return "absoluteRisk"; + case "p1&p2": return "p1P2"; + default: return options["priorPlotType"]; + } + } + } + ChangeRename{ from: "plotRobustness"; to: "bfRobustnessPlot" } + ChangeRename{ from: "plotRobustnessBFType"; to: "bfRobustnessPlotType" } + ChangeRename{ from: "orEqualTo1Prob"; to: "priorModelProbabilityEqual" } + ChangeRename{ from: "orGreaterThan1Prob"; to: "priorModelProbabilityGreater" } + ChangeRename{ from: "orLessThan1Prob"; to: "priorModelProbabilityLess" } + ChangeRename{ from: "orNotEqualTo1Prob"; to: "priorModelProbabilityTwoSided" } + ChangeRename{ from: "numSamples"; to: "samples" } + ChangeRename{ from: "mu_stepsize"; to: "bfRobustnessPlotStepsPriorMean" } + ChangeRename{ from: "sigma_stepsize"; to: "bfRobustnessPlotStepsPriorSd" } + ChangeRename{ from: "mu_stepsize_lower"; to: "bfRobustnessPlotLowerPriorMean" } + ChangeRename{ from: "mu_stepsize_upper"; to: "bfRobustnessPlotUpperPriorMean" } + ChangeRename{ from: "sigma_stepsize_lower"; to: "bfRobustnessPlotLowerPriorSd" } + ChangeRename{ from: "sigma_stepsize_upper"; to: "bfRobustnessPlotUpperPriorSd" } + } +} diff --git a/inst/qml/ABTestBayesian.qml b/inst/qml/ABTestBayesian.qml index 9d2f3654..ee79ae72 100644 --- a/inst/qml/ABTestBayesian.qml +++ b/inst/qml/ABTestBayesian.qml @@ -25,7 +25,7 @@ import JASP 1.0 Form { - + VariablesForm { @@ -47,13 +47,13 @@ Form { title : qsTr("Normal Prior on Log Odds Ratio") - DoubleField { label: qsTr("\u03bc:"); name: "normal_mu"; defaultValue: 0; negativeValues: true} - DoubleField { label: qsTr("\u03c3:"); name: "normal_sigma"; defaultValue: 1 } + DoubleField { label: qsTr("\u03bc:"); name: "normalPriorMean"; defaultValue: 0; negativeValues: true} + DoubleField { label: qsTr("\u03c3:"); name: "normalPriorSd"; defaultValue: 1 } } CheckBox { - name : "descriptives"; + name : "descriptivesTable"; label : qsTr("Descriptives") } } @@ -65,48 +65,64 @@ Form title : qsTr("Plots") CheckBox { - name : "plotPriorAndPosterior" + name : "priorPosteriorPlot" label : qsTr("Prior and posterior") childrenOnSameRow: true DropDown { id: plotPosteriorType - name: "plotPosteriorType" - values: [ "LogOddsRatio", "OddsRatio", "RelativeRisk", "AbsoluteRisk", "p1&p2" ] + name: "priorPosteriorPlotType" + values: + [ + { value: "logOddsRatio", label: qsTr("Log Odds Ratio") }, + { value: "oddsRatio", label: qsTr("Odds Ratio") }, + { value: "relativeRisk", label: qsTr("Relative Risk") }, + { value: "absoluteRisk", label: qsTr("Absolute Risk") }, + { value: "p1P2", label: qsTr("p1 & p2") } + ] } } CheckBox { - name : "plotSequentialAnalysis" + name : "bfSequentialPlot" label : qsTr("Sequential analysis") } CheckBox { - name : "plotPriorOnly" + name : "priorPlot" label : qsTr("Prior") childrenOnSameRow: true DropDown { id: plotPriorType - name: "plotPriorType" - values: [ "LogOddsRatio", "OddsRatio", "RelativeRisk", "AbsoluteRisk", "p1&p2", "p1", "p2" ] + name: "priorPlotType" + values: + [ + { value: "logOddsRatio", label: qsTr("Log Odds Ratio") }, + { value: "oddsRatio", label: qsTr("Odds Ratio") }, + { value: "relativeRisk", label: qsTr("Relative Risk") }, + { value: "absoluteRisk", label: qsTr("Absolute Risk") }, + { value: "p1P2", label: qsTr("p1 & p2") }, + { value: "p1", label: qsTr("p1") }, + { value: "p1", label: qsTr("p1") }, + ] } } CheckBox { - name : "plotRobustness" + name : "bfRobustnessPlot" label : qsTr("Bayes factor robustness check") childrenOnSameRow : true DropDown { id : plotRobustnessBFType - name : "plotRobustnessBFType" + name : "bfRobustnessPlotType" values : bayesFactorType.value == "BF01" ? ['BF01', 'BF0+', 'BF0-'] : ['BF10', 'BF+0', 'BF-0'] } } @@ -131,16 +147,16 @@ Form Group { title: qsTr("Prior Model Probability") - DoubleField { name: "orEqualTo1Prob"; label: qsTr("Log odds ratio = 0"); defaultValue: 0.5; max: 1; min: 0; decimals: 3 } - DoubleField { name: "orGreaterThan1Prob"; label: qsTr("Log odds ratio > 0"); defaultValue: 0.25; max: 1; min: 0; decimals: 3 } - DoubleField { name: "orLessThan1Prob"; label: qsTr("Log odds ratio < 0"); defaultValue: 0.25; max: 1; min: 0; decimals: 3 } - DoubleField { name: "orNotEqualTo1Prob"; label: qsTr("Log odds ratio \u2260 0"); defaultValue: 0; max: 1; min: 0; decimals: 3 } + DoubleField { name: "priorModelProbabilityEqual"; label: qsTr("Log odds ratio = 0"); defaultValue: 0.5; max: 1; min: 0; decimals: 3 } + DoubleField { name: "priorModelProbabilityGreater"; label: qsTr("Log odds ratio > 0"); defaultValue: 0.25; max: 1; min: 0; decimals: 3 } + DoubleField { name: "priorModelProbabilityLess"; label: qsTr("Log odds ratio < 0"); defaultValue: 0.25; max: 1; min: 0; decimals: 3 } + DoubleField { name: "priorModelProbabilityTwoSided"; label: qsTr("Log odds ratio \u2260 0"); defaultValue: 0; max: 1; min: 0; decimals: 3 } } Group { title: qsTr("Sampling") - IntegerField { name: "numSamples"; label: qsTr("No. samples"); defaultValue: 10000; min: 100; fieldWidth: 50; } + IntegerField { name: "samples"; label: qsTr("No. samples"); defaultValue: 10000; min: 100; fieldWidth: 50; } } SetSeed {} @@ -155,8 +171,8 @@ Form Group { title : qsTr("No. Steps") - IntegerField { label: qsTr("\u03bc:"); name: "mu_stepsize"; defaultValue: 5; min: 3 } - IntegerField { label: qsTr("\u03c3:"); name: "sigma_stepsize"; defaultValue: 5; min: 3 } + IntegerField { label: qsTr("\u03bc:"); name: "bfRobustnessPlotStepsPriorMean"; defaultValue: 5; min: 3 } + IntegerField { label: qsTr("\u03c3:"); name: "bfRobustnessPlotStepsPriorSd"; defaultValue: 5; min: 3 } } Group @@ -169,7 +185,7 @@ Form { id : muLower label : qsTr("lower:") - name : "mu_stepsize_lower" + name : "bfRobustnessPlotLowerPriorMean" defaultValue : plotRobustnessBFType.currentText == "BF+0" ? 0 : -0.5 max : muUpper.value negativeValues : true @@ -180,7 +196,7 @@ Form { id : muUpper label : qsTr("upper:") - name : "mu_stepsize_upper" + name : "bfRobustnessPlotUpperPriorMean" defaultValue : plotRobustnessBFType.currentText == "BF-0" ? 0 : 0.5 min : muLower.value negativeValues : true @@ -192,7 +208,7 @@ Form { id : sigmaLower label : qsTr("lower:") - name : "sigma_stepsize_lower" + name : "bfRobustnessPlotLowerPriorSd" defaultValue : 0.1 max : sigmaUpper.value negativeValues : false @@ -202,7 +218,7 @@ Form { id : sigmaUpper label : qsTr("upper:") - name : "sigma_stepsize_upper" + name : "bfRobustnessPlotUpperPriorSd" defaultValue : 1.0 min : sigmaLower.value negativeValues : false diff --git a/inst/qml/BinomialTest.qml b/inst/qml/BinomialTest.qml index 46f65f0f..a2411c67 100644 --- a/inst/qml/BinomialTest.qml +++ b/inst/qml/BinomialTest.qml @@ -36,10 +36,10 @@ Form RadioButtonGroup { title: qsTr("Alt. Hypothesis") - name: "hypothesis" - RadioButton { value: "notEqualToTestValue"; label: qsTr("≠ Test value"); checked: true } - RadioButton { value: "greaterThanTestValue"; label: qsTr("> Test value") } - RadioButton { value: "lessThanTestValue"; label: qsTr("< Test value") } + name: "alternative" + RadioButton { value: "twoSided"; label: qsTr("≠ Test value"); checked: true } + RadioButton { value: "greater"; label: qsTr("> Test value") } + RadioButton { value: "less"; label: qsTr("< Test value") } } Group @@ -47,10 +47,11 @@ Form title: qsTr("Additional Statisics") CheckBox { - name: "confidenceInterval"; label: qsTr("Confidence interval") - CIField { name: "confidenceIntervalInterval"; label: qsTr("Interval") } + name: "ci" + label: qsTr("Confidence interval") + CIField { name: "ciLevel"; label: qsTr("Interval") } } - CheckBox { name: "VovkSellkeMPR"; label: qsTr("Vovk-Sellke maximum p-ratio") } + CheckBox { name: "vovkSellke"; label: qsTr("Vovk-Sellke maximum p-ratio") } } Group @@ -58,9 +59,8 @@ Form title: qsTr("Plots") CheckBox { - name: "descriptivesPlots"; label: qsTr("Descriptive plots") - CIField { name: "descriptivesPlotsConfidenceInterval"; label: qsTr("Confidence interval") } + name: "descriptivesPlot"; label: qsTr("Descriptive plots") + CIField { name: "descriptivesPlotCiLevel"; label: qsTr("Confidence interval") } } } - } diff --git a/inst/qml/BinomialTestBayesian.qml b/inst/qml/BinomialTestBayesian.qml index 0f956de5..c2bdf3ad 100644 --- a/inst/qml/BinomialTestBayesian.qml +++ b/inst/qml/BinomialTestBayesian.qml @@ -42,10 +42,10 @@ Form RadioButtonGroup { title: qsTr("Direction") - name: "hypothesis" - RadioButton { value: "notEqualToTestValue"; label: qsTr("≠ Test value"); checked: true } - RadioButton { value: "greaterThanTestValue"; label: qsTr("> Test value") } - RadioButton { value: "lessThanTestValue"; label: qsTr("< Test value") } + name: "alternative" + RadioButton { value: "twoSided"; label: qsTr("≠ Test value"); checked: true } + RadioButton { value: "greater"; label: qsTr("> Test value") } + RadioButton { value: "less"; label: qsTr("< Test value") } } Group @@ -60,15 +60,17 @@ Form title: qsTr("Plots") CheckBox { - name: "plotPriorAndPosterior"; label: qsTr("Prior and posterior") - CheckBox { name: "plotPriorAndPosteriorAdditionalInfo"; label: qsTr("Additional info"); checked: true } + name: "priorPosteriorPlot" + label: qsTr("Prior and posterior") + CheckBox { name: "priorPosteriorPlotAdditionalInfo"; label: qsTr("Additional info"); checked: true } + } + CheckBox { name: "bfSequentialPlot"; label: qsTr("Sequential analysis") } + CheckBox + { + name: "descriptivesPlot" + label: qsTr("Descriptive plots") + CIField { name: "descriptivesPlotCiLevel"; label: qsTr("Credible interval") } } - CheckBox { name: "plotSequentialAnalysis"; label: qsTr("Sequential analysis") } - CheckBox - { - name: "descriptivesPlots"; label: qsTr("Descriptive plots") - CIField { name: "descriptivesPlotsCredibleInterval"; label: qsTr("Credible interval") } - } } BayesFactorType {} diff --git a/inst/qml/ContingencyTables.qml b/inst/qml/ContingencyTables.qml index 461fc2a2..957462e2 100644 --- a/inst/qml/ContingencyTables.qml +++ b/inst/qml/ContingencyTables.qml @@ -40,7 +40,7 @@ Form CheckBox { name: "chiSquared"; label: qsTr("χ²"); checked: true } CheckBox { name: "chiSquaredContinuityCorrection"; label: qsTr("χ² continuity correction") } CheckBox { name: "likelihoodRatio"; label: qsTr("Likelihood ratio") } - CheckBox { name: "VovkSellkeMPR"; label: qsTr("Vovk-Sellke maximum p-ratio") } + CheckBox { name: "vovkSellke"; label: qsTr("Vovk-Sellke maximum p-ratio") } } Group @@ -50,14 +50,14 @@ Form name: "oddsRatio"; label: qsTr("Odds ratio (2x2 only)") CheckBox { - name: "LogOdds"; label: qsTr("Log Odds Ratio"); checked: true + name: "oddsRatioAsLogOdds"; label: qsTr("Log Odds Ratio"); checked: true } - CIField { name: "oddsRatioConfidenceIntervalInterval"; label: qsTr("Confidence interval") } + CIField { name: "oddsRatioCiLevel"; label: qsTr("Confidence interval") } RadioButtonGroup { title: qsTr("Alt. Hypothesis (Fisher's exact test)") - name: "oddsRatioHypothesis" - RadioButton { value: "two.sided"; label: qsTr("Group one ≠ Group two"); checked: true } + name: "oddsRatioAlternative" + RadioButton { value: "twoSided"; label: qsTr("Group one ≠ Group two"); checked: true } RadioButton { value: "greater"; label: qsTr("Group one > Group two") } RadioButton { value: "less"; label: qsTr("Group one < Group two") } } @@ -77,9 +77,9 @@ Form { title: qsTr("Ordinal") CheckBox { name: "gamma"; label: qsTr("Gamma") } - CheckBox { name: "somersD"; label: qsTr("Somers' d"); debug: true } + CheckBox { name: "somersD"; label: qsTr("Somers' d"); debug: true } CheckBox { name: "kendallsTauB"; label: qsTr("Kendall's tau-b") } - CheckBox { name: "kendallsTauC"; label: qsTr("Kendall's tau-c"); debug: true } + CheckBox { name: "kendallsTauC"; label: qsTr("Kendall's tau-c"); debug: true } } Group @@ -95,7 +95,7 @@ Form Layout.columnSpan: 2 CheckBox { - name: "cochransAndMantel"; label: qsTr("Cochran's and Mantel-Haenszel statistics") + name: "cochranAndMantel"; label: qsTr("Cochran's and Mantel-Haenszel statistics") DoubleField { name: "testOddsRatioEquals"; label: qsTr("Test common odds ratio equals"); defaultValue: 1 } } } @@ -111,8 +111,8 @@ Form CheckBox { name: "countsExpected"; label: qsTr("Expected") } CheckBox { - name: "hideSmallCounts"; label: qsTr("Hide small counts"); debug: true - IntegerField { name: "hideSmallCountsLessThan"; label: qsTr("Less than"); defaultValue: 5; debug: true } + name: "countsHiddenSmallCounts"; label: qsTr("Hide small counts"); debug: true + IntegerField { name: "countsHiddenSmallCountsThreshold"; label: qsTr("Less than"); defaultValue: 5; debug: true } } } @@ -122,8 +122,8 @@ Form debug: true CheckBox { - name: "zTestCompareColumns"; label: qsTr("Compare column proportions") - CheckBox { name: "zTestAdjustPValues"; label: qsTr("Adjust p-values") } + name: "zTestColumnComparison"; label: qsTr("Compare column proportions") + CheckBox { name: "zTestAdjustedPValues"; label: qsTr("Adjust p-values") } } } diff --git a/inst/qml/ContingencyTablesBayesian.qml b/inst/qml/ContingencyTablesBayesian.qml index 8b09afa8..15727921 100644 --- a/inst/qml/ContingencyTablesBayesian.qml +++ b/inst/qml/ContingencyTablesBayesian.qml @@ -27,17 +27,12 @@ Form plotWidth: 320 plotHeight: 240 - CheckBox { visible: false ; name: "countsExpected"; checked: false } - CheckBox { visible: false ; name: "residualsUnstandardized"; checked: false } - CheckBox { visible: false ; name: "residualsPearson"; checked: false } - CheckBox { visible: false ; name: "residualsStandardized"; checked: false } - VariablesForm { AvailableVariablesList { name: "allVariablesList" } AssignedVariablesList { name: "rows"; title: qsTr("Rows"); suggestedColumns: ["ordinal", "nominal"] } AssignedVariablesList { name: "columns"; title: qsTr("Columns"); suggestedColumns: ["ordinal", "nominal"] } - AssignedVariablesList { name: "counts"; title: qsTr("Counts"); suggestedColumns: ["scale", "ordinal"]; singleVariable: true } + AssignedVariablesList { name: "counts"; title: qsTr("Counts"); suggestedColumns: ["scale", "ordinal"]; singleVariable: true } AssignedVariablesList { name: "layers"; title: qsTr("Layers"); suggestedColumns: ["ordinal", "nominal"]; listViewType: JASP.Layers; preferredHeight: 120 } } @@ -49,11 +44,11 @@ Form { name: "samplingModel" title: qsTr("Sample") - RadioButton { value: "poisson"; label: qsTr("Poisson") } - RadioButton { value: "jointMultinomial"; label: qsTr("Joint multinomial") } - RadioButton { value: "independentMultinomialRowsFixed"; label: qsTr("Indep. multinomial, rows fixed"); checked: true } - RadioButton { value: "independentMultinomialColumnsFixed"; label: qsTr("Indep. multinomial, columns fixed") } - RadioButton { value: "hypergeometric"; label: qsTr("Hypergeometric (2x2 only)"); id: hypergeometric } + RadioButton { value: "poisson"; label: qsTr("Poisson") } + RadioButton { value: "jointMultinomial"; label: qsTr("Joint multinomial") } + RadioButton { value: "independentMultinomialRowsFixed"; label: qsTr("Indep. multinomial, rows fixed"); checked: true } + RadioButton { value: "independentMultinomialColumnsFixed"; label: qsTr("Indep. multinomial, columns fixed") } + RadioButton { value: "hypergeometric"; label: qsTr("Hypergeometric (2x2 only)"); id: hypergeometric } } Group @@ -62,23 +57,23 @@ Form CheckBox { name: "oddsRatio"; label: qsTr("Log odds ratio (2x2 only)") - CIField { name: "oddsRatioCredibleIntervalInterval"; label: qsTr("Credible interval") } + CIField { name: "oddsRatioCiLevel"; label: qsTr("Credible interval") } } CheckBox { - name: "effectSize"; label: qsTr("Cramer's V"); debug: true - CIField { name: "effectSizeCredibleIntervalInterval"; label: qsTr("Credible interval"); debug: true } + name: "cramersV"; label: qsTr("Cramer's V"); debug: true + CIField { name: "cramersVCiLevel"; label: qsTr("Credible interval"); debug: true } } } RadioButtonGroup { title: qsTr("Alt. Hypothesis") - name: "hypothesis" + name: "alternative" enabled: !hypergeometric.checked - RadioButton { value: "groupsNotEqual"; label: qsTr("Group one ≠ Group two"); checked: true } - RadioButton { value: "groupOneGreater"; label: qsTr("Group one > Group two") } - RadioButton { value: "groupTwoGreater"; label: qsTr("Group one < Group two") } + RadioButton { value: "twoSided"; label: qsTr("Group one ≠ Group two"); checked: true } + RadioButton { value: "greater"; label: qsTr("Group one > Group two") } + RadioButton { value: "less"; label: qsTr("Group one < Group two") } } Group @@ -86,10 +81,10 @@ Form title: qsTr("Plots") CheckBox { - name: "plotPosteriorOddsRatio"; label: qsTr("Log odds ratio (2x2 only)") - CheckBox { name: "plotPosteriorOddsRatioAdditionalInfo"; label: qsTr("Additional info"); checked: true } + name: "posteriorOddsRatioPlot"; label: qsTr("Log odds ratio (2x2 only)") + CheckBox { name: "posteriorOddsRatioPlotAdditionalInfo"; label: qsTr("Additional info"); checked: true } } - CheckBox { name: "plotPosteriorEffectSize"; label: qsTr("Cramer's V"); debug: true } + CheckBox { name: "cramersVPlot"; label: qsTr("Cramer's V"); debug: true } } BayesFactorType {} @@ -105,6 +100,22 @@ Form { title: qsTr("Cells") + Group + { + title: qsTr("Counts") + debug: true + CheckBox { name: "countsExpected"; label: qsTr("Expected") } + } + + Group + { + title: qsTr("Residuals") + debug: true + CheckBox { name: "residualsUnstandardized"; label: qsTr("Unstandardized") } + CheckBox { name: "residualsPearson"; label: qsTr("Pearson") } + CheckBox { name: "residualsStandardized"; label: qsTr("Standardized") } + } + Group { title: qsTr("Percentages") diff --git a/inst/qml/MultinomialTest.qml b/inst/qml/MultinomialTest.qml index 6a489ed3..1d4cb784 100644 --- a/inst/qml/MultinomialTest.qml +++ b/inst/qml/MultinomialTest.qml @@ -25,33 +25,32 @@ import JASP.Widgets 1.0 Form { - CheckBox { name: "simulatepval"; checked: false; visible: false } VariablesForm { preferredHeight: 190 * preferencesModel.uiScale marginBetweenVariablesLists: 15 AvailableVariablesList { name: "allVariablesList" } - AssignedVariablesList { id: factors; name: "factor"; title: qsTr("Factor"); singleVariable: true; suggestedColumns: ["ordinal", "nominal"] } - AssignedVariablesList { name: "counts"; title: qsTr("Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } - AssignedVariablesList { id: exProbVar; name: "exProbVar"; title: qsTr("Expected Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } + AssignedVariablesList { id: factors; name: "factor"; title: qsTr("Factor"); singleVariable: true; suggestedColumns: ["ordinal", "nominal"] } + AssignedVariablesList { name: "count"; title: qsTr("Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } + AssignedVariablesList { id: exProbVar; name: "expectedCount"; title: qsTr("Expected Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } } RadioButtonGroup { id : hypothesisGroup - name : "hypothesis" + name : "testValues" title : qsTr("Test Values") enabled : exProbVar.count == 0 Layout.columnSpan: 2 - RadioButton { value: "multinomialTest"; label: qsTr("Equal proportions (multinomial test)"); checked: true } - RadioButton { id: expectedProbs; value: "expectedProbs"; label: qsTr("Expected proportions (χ² test)"); } + RadioButton { value: "equal"; label: qsTr("Equal proportions (multinomial test)"); checked: true } + RadioButton { id: expectedProbs; value: "custom"; label: qsTr("Custom expected proportions (χ² test)"); } Chi2TestTableView { - name : "tableWidget" + name : "testValuesCustom" preferredWidth : form.availableWidth - hypothesisGroup.leftPadding visible : expectedProbs.checked && factors.count > 0 source : "factor" @@ -65,28 +64,29 @@ Form CheckBox { - name : "descriptives"; label: qsTr("Descriptives") + name : "descriptivesTable"; label: qsTr("Descriptives") CheckBox { - name : "confidenceInterval"; label: qsTr("Confidence interval") - childrenOnSameRow : true + name: "descriptivesTableCi" + label: qsTr("Confidence interval") + childrenOnSameRow : true - CIField { name: "confidenceIntervalInterval" } + CIField { name: "descriptivesTableCiLevel" } } } - CheckBox { name: "VovkSellkeMPR"; label: qsTr("Vovk-Sellke maximum p-ratio") } + CheckBox { name: "vovkSellke"; label: qsTr("Vovk-Sellke maximum p-ratio") } } ColumnLayout { RadioButtonGroup { - name : "countProp" + name : "descriptivesType" title : qsTr("Display") - RadioButton { value: "descCounts"; label: qsTr("Counts"); checked: true } - RadioButton { value: "descProps"; label: qsTr("Proportions") } + RadioButton { value: "counts"; label: qsTr("Counts"); checked: true } + RadioButton { value: "proportions"; label: qsTr("Proportions") } } Group @@ -98,7 +98,7 @@ Form name : "descriptivesPlot" label : qsTr("Descriptives plot") - CIField { name: "descriptivesPlotConfidenceInterval"; label: qsTr("Confidence interval") } + CIField { name: "descriptivesPlotCiLevel"; label: qsTr("Confidence interval") } } } } diff --git a/inst/qml/MultinomialTestBayesian.qml b/inst/qml/MultinomialTestBayesian.qml index 582ff459..3f2f1a05 100644 --- a/inst/qml/MultinomialTestBayesian.qml +++ b/inst/qml/MultinomialTestBayesian.qml @@ -31,26 +31,26 @@ Form preferredHeight: 190 * preferencesModel.uiScale marginBetweenVariablesLists : 15 AvailableVariablesList { name: "allVariablesList" } - AssignedVariablesList { id: factors; name: "factor"; title: qsTr("Factor"); singleVariable: true; suggestedColumns: ["ordinal", "nominal"] } - AssignedVariablesList { name: "counts"; title: qsTr("Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } - AssignedVariablesList { id: exProbVar; name: "exProbVar"; title: qsTr("Expected Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } + AssignedVariablesList { id: factors; name: "factor"; title: qsTr("Factor"); singleVariable: true; suggestedColumns: ["ordinal", "nominal"] } + AssignedVariablesList { name: "count"; title: qsTr("Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } + AssignedVariablesList { id: exProbVar; name: "expectedCount"; title: qsTr("Expected Counts"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } } RadioButtonGroup { id : hypothesisGroup - name : "hypothesis" + name : "testValues" title : qsTr("Test Values") enabled : exProbVar.count == 0 Layout.columnSpan: 2 - RadioButton { value: "multinomialTest"; label: qsTr("Equal proportions"); checked: true } - RadioButton { value: "expectedProbs"; label: qsTr("Expected proportions"); id: expectedProbs } + RadioButton { value: "equal"; label: qsTr("Equal proportions"); checked: true } + RadioButton { value: "custom"; label: qsTr("Custom expected proportions"); id: expectedProbs } Chi2TestTableView { - name : "tableWidget" + name : "testValuesCustom" preferredWidth : form.availableWidth - hypothesisGroup.leftPadding visible : expectedProbs.checked && factors.count > 0 source : "factor" @@ -68,14 +68,14 @@ Form title : qsTr("Additional Statistics") CheckBox { - name : "descriptives" + name : "descriptivesTable" label : qsTr("Descriptives") CheckBox { - name : "credibleInterval"; label: qsTr("Credible interval") + name : "descriptivesTableCi"; label: qsTr("Credible interval") childrenOnSameRow : true - CIField { name: "credibleIntervalInterval" } + CIField { name: "descriptivesTableCiLevel" } } } } @@ -85,11 +85,11 @@ Form { RadioButtonGroup { - name : "countProp" + name : "descriptivesType" title : qsTr("Display") - RadioButton { value: "descCounts"; label: qsTr("Counts"); checked: true } - RadioButton { value: "descProps"; label: qsTr("Proportions") } + RadioButton { value: "counts"; label: qsTr("Counts"); checked: true } + RadioButton { value: "proportions"; label: qsTr("Proportions") } } Group @@ -100,7 +100,7 @@ Form name : "descriptivesPlot" label : qsTr("Descriptives plot") - CIField { name: "descriptivesPlotCredibleInterval"; label: qsTr("Credible interval") } + CIField { name: "descriptivesPlotCiLevel"; label: qsTr("Credible interval") } } } } diff --git a/inst/qml/RegressionLogLinear.qml b/inst/qml/RegressionLogLinear.qml index 2386176e..eb63a285 100644 --- a/inst/qml/RegressionLogLinear.qml +++ b/inst/qml/RegressionLogLinear.qml @@ -25,7 +25,7 @@ Form VariablesForm { AvailableVariablesList { name: "allVariablesList" } - AssignedVariablesList { name: "counts"; title: qsTr("Counts (optional)"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } + AssignedVariablesList { name: "count"; title: qsTr("Counts (optional)"); singleVariable: true; suggestedColumns: ["scale", "ordinal"] } AssignedVariablesList { name: "factors"; title: qsTr("Factors"); itemType: "fixedFactors"; suggestedColumns: ["ordinal", "nominal"] } } @@ -48,16 +48,16 @@ Form Group { title: qsTr("Regression Coefficient") - CheckBox - { - name: "regressionCoefficientsEstimates"; label: qsTr("Estimates") - CheckBox - { - name: "regressionCoefficientsConfidenceIntervals"; label: qsTr("Confidence intervals") - CIField { name: "regressionCoefficientsConfidenceIntervalsInterval"; label: qsTr("Interval") } - } - } + CheckBox + { + name: "regressionCoefficientsEstimates"; label: qsTr("Estimates") + CheckBox + { + name: "regressionCoefficientsCi"; label: qsTr("Confidence intervals") + CIField { name: "regressionCoefficientsCiLevel"; label: qsTr("Interval") } + } + } } - CheckBox { name: "VovkSellkeMPR"; label: qsTr("Vovk-Sellke maximum p-ratio") } + CheckBox { name: "vovkSellke"; label: qsTr("Vovk-Sellke maximum p-ratio") } } } diff --git a/inst/qml/RegressionLogLinearBayesian.qml b/inst/qml/RegressionLogLinearBayesian.qml index 240701cc..da599761 100644 --- a/inst/qml/RegressionLogLinearBayesian.qml +++ b/inst/qml/RegressionLogLinearBayesian.qml @@ -26,7 +26,7 @@ Form VariablesForm { AvailableVariablesList { name: "allVariablesList" } - AssignedVariablesList { name: "counts"; title: qsTr("Counts (optional)"); singleVariable: true; suggestedColumns:["scale", "ordinal"]} + AssignedVariablesList { name: "count"; title: qsTr("Counts (optional)"); singleVariable: true; suggestedColumns:["scale", "ordinal"]} AssignedVariablesList { name: "factors"; title: qsTr("Factors"); itemType: "fixedFactors"; suggestedColumns: ["ordinal", "nominal"] } } @@ -43,8 +43,8 @@ Form Group { title: qsTr("Model Cut-offs") - IntegerField { name: "maxModels"; label: qsTr("Display best") ; defaultValue: 2; afterLabel: qsTr("models"); min: 2 } - DoubleField { name: "posteriorProbabilityCutOff"; label: qsTr("Posterior prob."); defaultValue: 0.1 ; max: 0.5 } + IntegerField { name: "modelCutOffBestDisplayed"; label: qsTr("Display best") ; defaultValue: 2; afterLabel: qsTr("models"); min: 2 } + DoubleField { name: "modelCutOffPosteriorProbability"; label: qsTr("Posterior prob."); defaultValue: 0.1 ; max: 0.5 } } Section @@ -70,8 +70,8 @@ Form CheckBox { name: "regressionCoefficientsEstimates"; label: qsTr("Estimates") } CheckBox { - name: "regressionCoefficientsCredibleIntervals"; label: qsTr("Credible intervals") - CIField { name: "regressionCoefficientsCredibleIntervalsInterval"; label: qsTr("Interval") } + name: "regressionCoefficientsCi"; label: qsTr("Credible intervals") + CIField { name: "regressionCoefficientsCiLevel"; label: qsTr("Interval") } } } @@ -90,8 +90,8 @@ Form enabled: regressionCoefficientsSubmodel.checked CheckBox { - name: "regressionCoefficientsSubmodelCredibleIntervals"; label: qsTr("Credible intervals") - CIField { name: "regressionCoefficientsSubmodelCredibleIntervalsInterval"; label: qsTr("Interval") } + name: "regressionCoefficientsSubmodelCi"; label: qsTr("Credible intervals") + CIField { name: "regressionCoefficientsSubmodelCiLevel"; label: qsTr("Interval") } } } } @@ -104,12 +104,12 @@ Form RadioButtonGroup { title: qsTr("Samples") - name: "sampleMode" + name: "samplingMethod" RadioButton { value: "auto"; label: qsTr("Auto"); checked: true } RadioButton { value: "manual"; label: qsTr("Manual") - IntegerField { name: "fixedSamplesNumber"; label: qsTr("No. samples"); defaultValue: 10000; fieldWidth: 60 } + IntegerField { name: "samplingMethodManualSamples"; label: qsTr("No. samples"); defaultValue: 10000; fieldWidth: 60 } } } diff --git a/tests/testthat/_snaps/abtestbayesian/sequential-subplot-1.svg b/tests/testthat/_snaps/abtestbayesian/sequential-subplot-1.svg index 0190ae09..eb398975 100644 --- a/tests/testthat/_snaps/abtestbayesian/sequential-subplot-1.svg +++ b/tests/testthat/_snaps/abtestbayesian/sequential-subplot-1.svg @@ -36,8 +36,8 @@ - - + + diff --git a/tests/testthat/_snaps/abtestbayesian/sequential-subplot-4.svg b/tests/testthat/_snaps/abtestbayesian/sequential-subplot-4.svg index 2677fae1..5ed63060 100644 --- a/tests/testthat/_snaps/abtestbayesian/sequential-subplot-4.svg +++ b/tests/testthat/_snaps/abtestbayesian/sequential-subplot-4.svg @@ -36,8 +36,8 @@ - - + + diff --git a/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-1-subplot-2.svg b/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-1-subplot-2.svg index 110d54c6..9f012d67 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-1-subplot-2.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-1-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-2-subplot-2.svg b/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-2-subplot-2.svg index e1f339af..0e1bacf6 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-2-subplot-2.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/prior-posterior-2-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-2.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-2.svg index f579a5e1..aed5075b 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-2.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-4.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-4.svg index de174954..4b862d39 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-4.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-1-subplot-4.svg @@ -88,22 +88,22 @@ - - - - - - - - - - - -Moderate -Anecdotal -Anecdotal -Moderate -Strong + + + + + + + + + + + +Moderate +Anecdotal +Anecdotal +Moderate +Strong diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-2.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-2.svg index 8ca19413..8e74ac03 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-2.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-4.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-4.svg index a7d3ce88..1e978280 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-4.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-2-subplot-4.svg @@ -88,22 +88,22 @@ - - - - - - - - - - - -Moderate -Anecdotal -Anecdotal -Moderate -Strong + + + + + + + + + + + +Moderate +Anecdotal +Anecdotal +Moderate +Strong diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-2.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-2.svg index a99d84b9..6e263f25 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-2.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-4.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-4.svg index 43757d9b..24045f54 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-4.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-3-subplot-4.svg @@ -90,22 +90,22 @@ - - - - - - - - - - - -Strong -Moderate -Anecdotal -Anecdotal -Moderate + + + + + + + + + + + +Strong +Moderate +Anecdotal +Anecdotal +Moderate diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-2.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-2.svg index c819e77e..f74ccc7d 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-2.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-4.svg b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-4.svg index 9941a727..a6a11ab8 100644 --- a/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-4.svg +++ b/tests/testthat/_snaps/binomialtestbayesian/sequential-analysis-4-subplot-4.svg @@ -90,22 +90,22 @@ - - - - - - - - - - - -Strong -Moderate -Anecdotal -Anecdotal -Moderate + + + + + + + + + + + +Strong +Moderate +Anecdotal +Anecdotal +Moderate diff --git a/tests/testthat/_snaps/contingencytablesbayesian/log-odds-ratio-subplot-2.svg b/tests/testthat/_snaps/contingencytablesbayesian/log-odds-ratio-subplot-2.svg index bbb8c255..b80d90bb 100644 --- a/tests/testthat/_snaps/contingencytablesbayesian/log-odds-ratio-subplot-2.svg +++ b/tests/testthat/_snaps/contingencytablesbayesian/log-odds-ratio-subplot-2.svg @@ -36,8 +36,8 @@ - - + + data | H0 data | H1 diff --git a/tests/testthat/_snaps/multinomialtest/descriptives-1.svg b/tests/testthat/_snaps/multinomialtest/descriptives-1.svg index f3d5cbb1..93975c14 100644 --- a/tests/testthat/_snaps/multinomialtest/descriptives-1.svg +++ b/tests/testthat/_snaps/multinomialtest/descriptives-1.svg @@ -27,11 +27,11 @@ - - - - - + + + + + diff --git a/tests/testthat/_snaps/multinomialtestbayesian/multinomialbayesiandescriptivesplot.svg b/tests/testthat/_snaps/multinomialtestbayesian/multinomialbayesiandescriptivesplot.svg index e2d963fa..a74a5404 100644 --- a/tests/testthat/_snaps/multinomialtestbayesian/multinomialbayesiandescriptivesplot.svg +++ b/tests/testthat/_snaps/multinomialtestbayesian/multinomialbayesiandescriptivesplot.svg @@ -27,8 +27,8 @@ - - + + diff --git a/tests/testthat/test-abtestbayesian.R b/tests/testthat/test-abtestbayesian.R index b83c6d2b..3b7c9734 100644 --- a/tests/testthat/test-abtestbayesian.R +++ b/tests/testthat/test-abtestbayesian.R @@ -37,7 +37,7 @@ test_that("Descriptives table results match", { options$y1 <- "y1" options$n2 <- "n2" options$y2 <- "y2" - options$descriptives <- TRUE + options$descriptivesTable <- TRUE results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) table <- results[["results"]][["abTestBayesianDescriptivesTable"]][["data"]] @@ -57,10 +57,10 @@ test_that("Main table results, log odds neq 0", { options$y1 <- "y1" options$n2 <- "n2" options$y2 <- "y2" - options$orEqualTo1Prob <- 0.495 - options$orGreaterThan1Prob <- 0.168 - options$orLessThan1Prob <- 0.168 - options$orNotEqualTo1Prob <- 0.168 + options$priorModelProbabilityEqual <- 0.495 + options$priorModelProbabilityGreater <- 0.168 + options$priorModelProbabilityLess <- 0.168 + options$priorModelProbabilityTwoSided <- 0.168 results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) table <- results[["results"]][["abTestBayesianTable"]][["data"]] @@ -82,10 +82,10 @@ test_that("Main table results, only 2 hypotheses", { options$y1 <- "y1" options$n2 <- "n2" options$y2 <- "y2" - options$orEqualTo1Prob <- 0.5 - options$orGreaterThan1Prob <- 0.5 - options$orLessThan1Prob <- 0 - options$orNotEqualTo1Prob <- 0 + options$priorModelProbabilityEqual <- 0.5 + options$priorModelProbabilityGreater <- 0.5 + options$priorModelProbabilityLess <- 0 + options$priorModelProbabilityTwoSided <- 0 results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) table <- results[["results"]][["abTestBayesianTable"]][["data"]] @@ -101,11 +101,12 @@ test_that("Prior plot matches", { set.seed(0) options <- jaspTools::analysisOptions("ABTestBayesian") - options$orEqualTo1Prob <- 0.5 - options$orGreaterThan1Prob <- 0.5 - options$orLessThan1Prob <- 0 - options$orNotEqualTo1Prob <- 0 - options$plotPriorOnly <- TRUE + options$priorModelProbabilityEqual <- 0.5 + options$priorModelProbabilityGreater <- 0.5 + options$priorModelProbabilityLess <- 0 + options$priorModelProbabilityTwoSided <- 0 + options$priorPlot <- TRUE + options$priorPlotType <- "logOddsRatio" results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) testPlot <- results[["state"]][["figures"]][[1]][["obj"]] @@ -123,11 +124,12 @@ test_that("Posterior plot matches", { options$y1 <- "y1" options$n2 <- "n2" options$y2 <- "y2" - options$orEqualTo1Prob <- 0.5 - options$orGreaterThan1Prob <- 0.5 - options$orLessThan1Prob <- 0 - options$orNotEqualTo1Prob <- 0 - options$plotPriorAndPosterior <- TRUE + options$priorModelProbabilityEqual <- 0.5 + options$priorModelProbabilityGreater <- 0.5 + options$priorModelProbabilityLess <- 0 + options$priorModelProbabilityTwoSided <- 0 + options$priorPosteriorPlot <- TRUE + options$priorPosteriorPlotType <- "logOddsRatio" results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) testPlot <- results[["state"]][["figures"]][[1]] @@ -144,11 +146,11 @@ test_that("Sequential plot matches", { options$y1 <- "y1" options$n2 <- "n2" options$y2 <- "y2" - options$orEqualTo1Prob <- 0.5 - options$orGreaterThan1Prob <- 0.5 - options$orLessThan1Prob <- 0 - options$orNotEqualTo1Prob <- 0 - options$plotSequentialAnalysis <- TRUE + options$priorModelProbabilityEqual <- 0.5 + options$priorModelProbabilityGreater <- 0.5 + options$priorModelProbabilityLess <- 0 + options$priorModelProbabilityTwoSided <- 0 + options$bfSequentialPlot <- TRUE results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) testPlot <- results[["state"]][["figures"]][[1]][["obj"]] @@ -166,11 +168,11 @@ test_that("plotRobustness plot matches", { options$y1 <- "y1" options$n2 <- "n2" options$y2 <- "y2" - options$orEqualTo1Prob <- 0.5 - options$orGreaterThan1Prob <- 0.5 - options$orLessThan1Prob <- 0 - options$orNotEqualTo1Prob <- 0 - options$plotRobustness <- TRUE + options$priorModelProbabilityEqual <- 0.5 + options$priorModelProbabilityGreater <- 0.5 + options$priorModelProbabilityLess <- 0 + options$priorModelProbabilityTwoSided <- 0 + options$bfRobustnessPlot <- TRUE results <- jaspTools::runAnalysis("ABTestBayesian", "ab_data.csv", options) testPlot <- results[["state"]][["figures"]][[1]] diff --git a/tests/testthat/test-binomialtest.R b/tests/testthat/test-binomialtest.R index a67141f5..e8ee0e5e 100644 --- a/tests/testthat/test-binomialtest.R +++ b/tests/testthat/test-binomialtest.R @@ -4,9 +4,9 @@ test_that("Main table results match", { options <- jaspTools::analysisOptions("BinomialTest") options$variables <- "contBinom" options$testValue <- 0.6 - options$hypothesis <- "greaterThanTestValue" - options$confidenceInterval <- TRUE - options$VovkSellkeMPR <- TRUE + options$alternative <- "greater" + options$ci <- TRUE + options$vovkSellke <- TRUE results <- jaspTools::runAnalysis("BinomialTest", "test.csv", options) table <- results[["results"]][["binomialTable"]][["data"]] jaspTools::expect_equal_tables(table, @@ -19,8 +19,8 @@ test_that("Descriptives plots match", { skip("This test need to be verified") options <- jaspTools::analysisOptions("BinomialTest") options$variables <- "contBinom" - options$descriptivesPlots <- TRUE - options$descriptivesPlotsConfidenceInterval <- 0.90 + options$descriptivesPlot <- TRUE + options$descriptivesPlotCiLevel <- 0.90 results <- jaspTools::runAnalysis("BinomialTest", "test.csv", options) testPlot <- results[["state"]][["figures"]][[1]][["obj"]] diff --git a/tests/testthat/test-binomialtestbayesian.R b/tests/testthat/test-binomialtestbayesian.R index fb8451ba..b8905c0e 100644 --- a/tests/testthat/test-binomialtestbayesian.R +++ b/tests/testthat/test-binomialtestbayesian.R @@ -4,7 +4,7 @@ test_that("Main table results match", { options <- jaspTools::analysisOptions("BinomialTestBayesian") options$variables <- "contBinom" options$bayesFactorType <- "BF01" - options$hypothesis <- "notEqualToTestValue" + options$alternative <- "twoSided" options$priorA <- 1 options$priorB <- 2 options$testValue <- 0.2 @@ -22,8 +22,8 @@ test_that("Prior posterior plots match", { options$priorB <- 1 options$testValue <- 0.5 options$variables <- "contBinom" - options$plotPriorAndPosterior <- TRUE - options$plotPriorAndPosteriorAdditionalInfo <- TRUE + options$priorPosteriorPlot <- TRUE + options$priorPosteriorPlotAdditionalInfo <- TRUE results <- jaspTools::runAnalysis("BinomialTestBayesian", "test.csv", options) testPlot <- results[["state"]][["figures"]][[1]][["obj"]] @@ -39,7 +39,7 @@ test_that("Sequential analysis plots match - BF10", { options$priorB <- 1 options$testValue <- 0.5 options$variables <- "contBinom" - options$plotSequentialAnalysis <- TRUE + options$bfSequentialPlot <- TRUE results <- jaspTools::runAnalysis("BinomialTestBayesian", "test.csv", options) testPlot <- results[["state"]][["figures"]][[1]][["obj"]] @@ -55,13 +55,13 @@ test_that("Sequential analysis plots match - BF01", { options$priorB <- 1 options$testValue <- 0.5 options$variables <- "contBinom" - options$plotSequentialAnalysis <- TRUE + options$bfSequentialPlot <- TRUE options$bayesFactorType <- "BF01" results <- jaspTools::runAnalysis("BinomialTestBayesian", "test.csv", options) - + testPlot <- results[["state"]][["figures"]][[1]][["obj"]] jaspTools::expect_equal_plots(testPlot, "sequential-analysis-3") - + testPlot <- results[["state"]][["figures"]][[2]][["obj"]] jaspTools::expect_equal_plots(testPlot, "sequential-analysis-4") }) diff --git a/tests/testthat/test-contingencytables.R b/tests/testthat/test-contingencytables.R index 02a40dc3..f2015907 100644 --- a/tests/testthat/test-contingencytables.R +++ b/tests/testthat/test-contingencytables.R @@ -101,7 +101,7 @@ test_that("Chi-Squared test table results match", { options$chiSquared <- TRUE options$chiSquaredContinuityCorrection <- TRUE options$likelihoodRatio <- TRUE - options$VovkSellkeMPR <- TRUE + options$vovkSellke <- TRUE results <- jaspTools::runAnalysis("ContingencyTables", "test.csv", options) table <- results[["results"]][["container_facExperim_contBinom"]][["collection"]][["container_facExperim_contBinom_crossTabChisq"]][["data"]] jaspTools::expect_equal_tables(table, @@ -131,7 +131,7 @@ test_that("Log Odds Ratio table results match", { options$rows <- "facExperim" options$columns <- "contBinom" options$oddsRatio <- TRUE - options$oddsRatioConfidenceIntervalInterval <- 0.90 + options$oddsRatioCiLevel <- 0.90 results <- jaspTools::runAnalysis("ContingencyTables", "test.csv", options) table <- results[["results"]][["container_facExperim_contBinom"]][["collection"]][["container_facExperim_contBinom_crossTabLogOdds"]][["data"]] jaspTools::expect_equal_tables(table, @@ -158,7 +158,7 @@ test_that("Kendall's Tau table results match", { options$rows <- "facExperim" options$columns <- "contBinom" options$kendallsTauB <- TRUE - options$VovkSellkeMPR <- TRUE + options$vovkSellke <- TRUE results <- jaspTools::runAnalysis("ContingencyTables", "test.csv", options) table <- results[["results"]][["container_facExperim_contBinom"]][["collection"]][["container_facExperim_contBinom_crossTabKendallTau"]][["data"]] jaspTools::expect_equal_tables(table, diff --git a/tests/testthat/test-contingencytablesbayesian.R b/tests/testthat/test-contingencytablesbayesian.R index ce07580e..3320df71 100644 --- a/tests/testthat/test-contingencytablesbayesian.R +++ b/tests/testthat/test-contingencytablesbayesian.R @@ -79,35 +79,35 @@ test_that("Bayesian Contingency Tables Tests table results match - different hyp samplingModels <- c("poisson", "jointMultinomial", "independentMultinomialRowsFixed", "independentMultinomialColumnsFixed") - hypotheses <- c("groupsNotEqual", "groupOneGreater", "groupTwoGreater") + alternatives <- c("twoSided", "greater", "less") refTables <- list( poisson = list( - groupsNotEqual = list("BF Poisson", "N", 100, 0.523118843924781), - groupOneGreater = list("BF Poisson", "N", 100, 0.224941102887656), - groupTwoGreater = list("BF Poisson", "N", 100, 0.818576366973497)), + twoSided = list("BF Poisson", "N", 100, 0.523118843924781), + greater = list("BF Poisson", "N", 100, 0.224941102887656), + less = list("BF Poisson", "N", 100, 0.818576366973497)), jointMultinomial = list( - groupsNotEqual = list("BF joint multinomial", "N", 100, 0.440084106793853), - groupOneGreater = list("BF joint multinomial", "N", 100, 0.181490685641785), - groupTwoGreater = list("BF joint multinomial", "N", 100, 0.683978718779006)), + twoSided = list("BF joint multinomial", "N", 100, 0.440084106793853), + greater = list("BF joint multinomial", "N", 100, 0.181490685641785), + less = list("BF joint multinomial", "N", 100, 0.683978718779006)), independentMultinomialRowsFixed = list( - groupsNotEqual = list("BF independent multinomial", "N", 100, 0.35545254779504), - groupOneGreater = list("BF independent multinomial", "N", 100, 0.149361160583476), - groupTwoGreater = list("BF independent multinomial", "N", 100, 0.560761939401455)), + twoSided = list("BF independent multinomial", "N", 100, 0.35545254779504), + greater = list("BF independent multinomial", "N", 100, 0.149361160583476), + less = list("BF independent multinomial", "N", 100, 0.560761939401455)), independentMultinomialColumnsFixed = list( - groupsNotEqual = list("BF independent multinomial", "N", 100, 0.364069579256729), - groupOneGreater = list("BF independent multinomial", "N", 100, 0.153564548530488), - groupTwoGreater = list("BF independent multinomial", "N", 100, 0.571734867264767)) + twoSided = list("BF independent multinomial", "N", 100, 0.364069579256729), + greater = list("BF independent multinomial", "N", 100, 0.153564548530488), + less = list("BF independent multinomial", "N", 100, 0.571734867264767)) ) for (samplingModel in samplingModels) { options$samplingModel <- samplingModel - for(hypothesis in hypotheses) { - options$hypothesis <- hypothesis + for(alternative in alternatives) { + options$alternative <- alternative results <- jaspTools::runAnalysis("ContingencyTablesBayesian", "test.csv", options, view = FALSE) table <- results[["results"]][["container_facExperim_contBinom"]][["collection"]][["container_facExperim_contBinom_contTabBasBF"]][["data"]] #makeTestTable(table) - jaspTools::expect_equal_tables(table, refTables[[samplingModel]][[hypothesis]], label=paste("Sampling model", samplingModel, "; hypothesis", hypothesis)) + jaspTools::expect_equal_tables(table, refTables[[samplingModel]][[alternative]], label=paste("Sampling model", samplingModel, "; hypothesis", alternative)) } } }) @@ -118,7 +118,7 @@ test_that("Log Odds Ratio table results match", { options$rows <- "facExperim" options$columns <- "contBinom" options$oddsRatio <- TRUE - options$oddsRatioCredibleIntervalInterval <- 0.90 + options$oddsRatioCiLevel <- 0.90 results <- jaspTools::runAnalysis("ContingencyTablesBayesian", "test.csv", options) table <- results[["results"]][["container_facExperim_contBinom"]][["collection"]][["container_facExperim_contBinom_contTabBasLogOdds"]][["data"]] jaspTools::expect_equal_tables(table, @@ -131,8 +131,8 @@ test_that("Cramer's V table results match", { options <- jaspTools::analysisOptions("ContingencyTablesBayesian") options$rows <- "facExperim" options$columns <- "contBinom" - options$effectSize <- TRUE - options$effectSizeCredibleIntervalInterval <- 0.90 + options$cramersV <- TRUE + options$cramersVCiLevel <- 0.90 results <- jaspTools::runAnalysis("ContingencyTablesBayesian", "test.csv", options) table <- results[["results"]][["container_facExperim_contBinom"]][["collection"]][["container_facExperim_contBinom_contTabBasCramersV"]][["data"]] jaspTools::expect_equal_tables(table, @@ -145,8 +145,8 @@ test_that("Log Odds Ratio Plot matches", { options <- jaspTools::analysisOptions("ContingencyTablesBayesian") options$rows <- "facExperim" options$columns <- "contBinom" - options$plotPosteriorOddsRatio <- TRUE - options$plotPosteriorOddsRatioAdditionalInfo <- TRUE + options$posteriorOddsRatioPlot <- TRUE + options$posteriorOddsRatioPlotAdditionalInfo <- TRUE results <- jaspTools::runAnalysis("ContingencyTablesBayesian", "test.csv", options) jaspTools::expect_equal_plots(results[["state"]][["figures"]][[1]][["obj"]], "log-odds-ratio") }) diff --git a/tests/testthat/test-multinomialtest.R b/tests/testthat/test-multinomialtest.R index 2ac87e2e..adf11916 100644 --- a/tests/testthat/test-multinomialtest.R +++ b/tests/testthat/test-multinomialtest.R @@ -2,12 +2,12 @@ context("Multinomial Test") test_that("Main table results match", { options <- jaspTools::analysisOptions("MultinomialTest") - options$VovkSellkeMPR <- TRUE - options$countProp <- "descProps" - options$descriptives <- TRUE + options$vovkSellke <- TRUE + options$descriptivesType <- "proportions" + options$descriptivesTable <- TRUE options$factor <- "facOutlier" - options$hypothesis <- "expectedProbs" - options$tableWidget <- list( + options$testValues <- "custom" + options$testValuesCustom <- list( list( levels = list("f1", "f2", "f3", "totallyridiculoussuperlongfactorme"), name = "H1", @@ -46,8 +46,8 @@ test_that("Descriptives plot matches", { test_that("Analysis handles errors - Negative Values", { options <- jaspTools::analysisOptions("MultinomialTest") options$factor <- "facExperim" - options$counts <- "contNormal" - options$tableWidget <- list( + options$count <- "contNormal" + options$testValuesCustom <- list( list( levels = list("control", "experimental"), name = "H1", @@ -62,8 +62,8 @@ test_that("Analysis handles errors - Negative Values", { test_that("Analysis handles errors - wrong levels", { options <- jaspTools::analysisOptions("MultinomialTest") options$factor <- "facExperim" - options$counts <- "debSame" - options$tableWidget <- list( + options$count <- "debSame" + options$testValluesCustom <- list( list( levels = list("control", "experimental"), name = "H1", @@ -78,8 +78,8 @@ test_that("Analysis handles errors - wrong levels", { test_that("Analysis handles errors - Infinities", { options <- jaspTools::analysisOptions("MultinomialTest") options$factor <- "facExperim" - options$counts <- "debInf" - options$tableWidget <- list( + options$count <- "debInf" + options$testValuesCustom <- list( list( levels = list("control", "experimental"), name = "H1", @@ -89,4 +89,4 @@ test_that("Analysis handles errors - Infinities", { results <- jaspTools::runAnalysis("MultinomialTest", "test.csv", options) status <- results[["status"]] expect_identical(status, "validationError") -}) \ No newline at end of file +}) diff --git a/tests/testthat/test-multinomialtestbayesian.R b/tests/testthat/test-multinomialtestbayesian.R index 10bc1d0c..e325c5f3 100644 --- a/tests/testthat/test-multinomialtestbayesian.R +++ b/tests/testthat/test-multinomialtestbayesian.R @@ -2,9 +2,9 @@ context("Multinomial Test Bayesian") test_that("Main table results match", { options <- jaspTools::analysisOptions("MultinomialTestBayesian") - options$factor <- "contBinom" + options$factor <- "contBinom" options$bayesFactorType <- "BF10" - options$hypothesis <- "multinomialTest" + options$testValues <- "equal" options$priorCounts <- list(list(levels = paste0('level', 1:2), name = c('Counts'), values = rep(1, 2))) @@ -18,10 +18,10 @@ test_that("Main table results match", { test_that("Descriptives table results match", { options <- jaspTools::analysisOptions("MultinomialTestBayesian") options$factor <- "debString" - options$countProp <- "descProps" - options$credibleInterval <- TRUE - options$descriptives <- TRUE - options$credibleIntervalInterval <- 0.10 + options$descriptivesType <- "proportions" + options$descriptivesTable <- TRUE + options$descriptivesTableCi <- TRUE + options$descriptivesTableCiLevel <- 0.10 options$priorCounts <- list(list(levels =letters, name = c('Counts'), values = rep(1, length(letters)))) @@ -35,8 +35,8 @@ test_that("Descriptives table results match", { test_that("Descriptives plots match", { options <- jaspTools::analysisOptions("MultinomialTestBayesian") options$factor <- "contBinom" - options$countProp <- "descProps" - options$credibleInterval <- TRUE + options$descriptivesType <- "proportions" + options$descriptivesTableCi <- TRUE options$descriptivesPlot <- TRUE options$priorCounts <- list(list(levels = c("0", "1"), name = c('Counts'), @@ -49,14 +49,14 @@ test_that("Descriptives plots match", { test_that("Bayesian Multinomial Test table results match in short data format", { options <- jaspTools::analysisOptions("MultinomialTestBayesian") options$factor <- "Month" - options$counts <- "Stress.frequency" - options$tableWidget <- list(list(levels = c("1", "2", "3", "4", "5", "6", "7", "8", - "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "H₀ (a)", - values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + options$count <- "Stress.frequency" + options$testValuesCustom <- list(list(levels = c("1", "2", "3", "4", "5", "6", "7", "8", + "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "H₀ (a)", + values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) - options$priorCounts <- list(list(levels = c("1", "2", "3", "4", "5", "6", "7", "8", - "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "Counts", - values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + options$priorCounts <- list(list(levels = c("1", "2", "3", "4", "5", "6", "7", "8", + "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "Counts", + values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) set.seed(1) results <- jaspTools::runAnalysis("MultinomialTestBayesian", "Memory of Life Stresses.csv", options) @@ -68,16 +68,16 @@ test_that("Bayesian Multinomial Test table results match in short data format", test_that("Descriptives table correctly shows reordered factor levels", { options <- jaspTools::analysisOptions("MultinomialTestBayesian") options$factor <- "Month" - options$counts <- "Stress.frequency" - options$exProbVar <- "Expected.counts" - options$descriptives <- TRUE - options$tableWidget <- list(list(levels = c("3", "1", "2", "4", "5", "6", "7", "8", - "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "H₀ (a)", - values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + options$count <- "Stress.frequency" + options$expectedCount <- "Expected.counts" + options$descriptivesTable <- TRUE + options$testValuesCustom <- list(list(levels = c("3", "1", "2", "4", "5", "6", "7", "8", + "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "H₀ (a)", + values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) - options$priorCounts <- list(list(levels = c("3", "1", "2", "4", "5", "6", "7", "8", - "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "Counts", - values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + options$priorCounts <- list(list(levels = c("3", "1", "2", "4", "5", "6", "7", "8", + "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"), name = "Counts", + values = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) results <- jaspTools::runAnalysis("MultinomialTestBayesian", "Memory of Life Stresses.csv", options) table <- results[["results"]][["multinomialDescriptivesTable"]][["data"]] diff --git a/tests/testthat/test-regressionloglinear.R b/tests/testthat/test-regressionloglinear.R index 57f4016d..c7c9d8df 100644 --- a/tests/testthat/test-regressionloglinear.R +++ b/tests/testthat/test-regressionloglinear.R @@ -2,7 +2,7 @@ context("Log-Linear Regression") test_that("Main table results match", { options <- jaspTools::analysisOptions("RegressionLogLinear") - options$counts <- "facFifty" + options$count <- "facFifty" options$factors <- c("contBinom", "facGender") options$modelTerms <- list( list(components="contBinom"), @@ -22,7 +22,7 @@ test_that("Main table results match", { test_that("Coefficients table matches", { options <- jaspTools::analysisOptions("RegressionLogLinear") - options$counts <- "facFifty" + options$count <- "facFifty" options$factors <- c("contBinom", "facFive") options$modelTerms <- list( list(components="contBinom"), @@ -30,8 +30,8 @@ test_that("Coefficients table matches", { list(components=c("contBinom", "facFive")) ) options$regressionCoefficientsEstimates <- TRUE - options$regressionCoefficientsConfidenceIntervals <- TRUE - options$regressionCoefficientsConfidenceIntervalsInterval <- 0.95 + options$regressionCoefficientsCi <- TRUE + options$regressionCoefficientsCiLevel <- 0.95 results <- jaspTools::runAnalysis("RegressionLogLinear", "test.csv", options) table <- results[["results"]][["CoefficientsTable"]][["data"]] jaspTools::expect_equal_tables(table, @@ -60,7 +60,7 @@ test_that("Coefficients table matches", { test_that("Analysis handles errors - infinity", { options <- jaspTools::analysisOptions("RegressionLogLinear") options$factors <- "facGender" - options$counts <- "debInf" + options$count <- "debInf" results <- jaspTools::runAnalysis("RegressionLogLinear", "test.csv", options) status <- results[["status"]] expect_identical(status, "validationError") @@ -80,7 +80,7 @@ test_that("Analysis handles errors - missing values (factors)", { test_that("Analysis handles errors - missing values (counts)", { options <- jaspTools::analysisOptions("RegressionLogLinear") options$factors <- "contBinom" - options$counts <- "debMiss30" + options$count <- "debMiss30" results <- jaspTools::runAnalysis("RegressionLogLinear", "test.csv", options) status <- results[["status"]] expect_identical(status, "validationError") @@ -89,8 +89,8 @@ test_that("Analysis handles errors - missing values (counts)", { test_that("Analysis handles errors - negatives", { options <- jaspTools::analysisOptions("RegressionLogLinear") options$factors <- "facGender" - options$counts <- "contNormal" + options$count <- "contNormal" results <- jaspTools::runAnalysis("RegressionLogLinear", "test.csv", options) status <- results[["status"]] expect_identical(status, "validationError") -}) \ No newline at end of file +}) diff --git a/tests/testthat/test-regressionloglinearbayesian.R b/tests/testthat/test-regressionloglinearbayesian.R index 317e8598..6375857b 100644 --- a/tests/testthat/test-regressionloglinearbayesian.R +++ b/tests/testthat/test-regressionloglinearbayesian.R @@ -2,15 +2,15 @@ context("Bayesian Log-Linear Regression") initOpts <- function() { options <- jaspTools::analysisOptions("RegressionLogLinearBayesian") - options$sampleMode <- "manual" - options$fixedSamplesNumber <- 100 + options$samplingMethod <- "manual" + options$samplingMethodManualSamples <- 100 return(options) } test_that("Main table results match", { set.seed(0) options <- initOpts() - options$counts <- "facFifty" + options$count <- "facFifty" options$factors <- c("contBinom", "facGender") options$modelTerms <- list( list(components="contBinom"), @@ -19,8 +19,8 @@ test_that("Main table results match", { ) options$priorScale <- 1 options$priorShape <- 0 - options$maxModels <- 2 - options$posteriorProbabilityCutOff <- 0.001 + options$modelCutOffBestDisplayed <- 2 + options$modelCutOffPosteriorProbability <- 0.001 results <- jaspTools::runAnalysis("RegressionLogLinearBayesian", "test.csv", options) table <- results[["results"]][["Container"]][["collection"]][["Container_MainTable"]][["data"]] jaspTools::expect_equal_tables(table, @@ -40,8 +40,8 @@ test_that("General summary statistics table matches", { list(components=c("contBinom", "facFive")) ) options$regressionCoefficientsEstimates <- TRUE - options$regressionCoefficientsCredibleIntervals <- TRUE - options$regressionCoefficientsCredibleIntervalsInterval <- 0.90 + options$regressionCoefficientsCi <- TRUE + options$regressionCoefficientsCiLevel <- 0.90 results <- jaspTools::runAnalysis("RegressionLogLinearBayesian", "test.csv", options) table <- results[["results"]][["Container"]][["collection"]][["Container_SummaryTable"]][["data"]] jaspTools::expect_equal_tables(table, @@ -75,7 +75,7 @@ test_that("Submodel summary statistics table matches", { list(components=c("contBinom", "facFive")) ) options$regressionCoefficientsSubmodel <- TRUE - options$regressionCoefficientsSubmodelCredibleIntervals <- TRUE + options$regressionCoefficientsSubmodelCi <- TRUE options$regressionCoefficientsSubmodelEstimates <- TRUE options$regressionCoefficientsSubmodelNo <- 2 results <- jaspTools::runAnalysis("RegressionLogLinearBayesian", "test.csv", options) @@ -96,7 +96,7 @@ test_that("Analysis handles errors - Infinity", { set.seed(0) options <- initOpts() options$factors <- c("contBinom", "facFive") - options$counts <- "debInf" + options$count <- "debInf" results <- jaspTools::runAnalysis("RegressionLogLinearBayesian", "test.csv", options) status <- results[["status"]] expect_identical(status, "validationError") diff --git a/tests/testthat/test-verified-multinomialtest.R b/tests/testthat/test-verified-multinomialtest.R index 9a166d5c..b446df25 100644 --- a/tests/testthat/test-verified-multinomialtest.R +++ b/tests/testthat/test-verified-multinomialtest.R @@ -3,34 +3,34 @@ context("Multinomial Test -- Verification project") # https://jasp-stats.github.io/jasp-verification-project/frequencies.html#multinomial-test-chi-square-goodness-of-fit-test test_that("Main table results match R, SPSS, SAS", { options <- jaspTools::analysisOptions("MultinomialTest") - - options$counts <- "Count" + + options$count <- "Count" options$factor <- "Color" - options$hypothesis <- "Expected" + options$testValues <- "custom" options$descriptivesPlot <- TRUE - options$tableWidget <- list( + options$testValuesCustom <- list( list( levels = list("Black", "Red", "White"), name = "H1", values = list(4, 3, 3) ) ) - + results <- jaspTools::runAnalysis("MultinomialTest", "MNT.csv", options) - + # Main table resultTable <- results$results$chisqTable$data - + refTable <- jaspTools:::collapseTestTable( list(list(case = "H\u2080 (a)", chisquare = 2.33333333333333, df = 2, p = 0.311403223914598)) ) - + jaspTools::expect_equal_tables("test"= resultTable, "ref"=refTable) - + # TODO(Alexander) Descriptive Plot put in separate tests resultPlot <- results[["state"]][["figures"]][[1]][["obj"]] -}) \ No newline at end of file +}) diff --git a/tests/upgrades/0.16.4/bayesian-ab-test.jasp b/tests/upgrades/0.16.4/bayesian-ab-test.jasp new file mode 100644 index 00000000..096e2190 Binary files /dev/null and b/tests/upgrades/0.16.4/bayesian-ab-test.jasp differ diff --git a/tests/upgrades/0.16.4/bayesian-binomial-test.jasp b/tests/upgrades/0.16.4/bayesian-binomial-test.jasp new file mode 100644 index 00000000..53dce3a0 Binary files /dev/null and b/tests/upgrades/0.16.4/bayesian-binomial-test.jasp differ diff --git a/tests/upgrades/0.16.4/bayesian-contingency-tables.jasp b/tests/upgrades/0.16.4/bayesian-contingency-tables.jasp new file mode 100644 index 00000000..ff274ea0 Binary files /dev/null and b/tests/upgrades/0.16.4/bayesian-contingency-tables.jasp differ diff --git a/tests/upgrades/0.16.4/bayesian-loglinear-regression.jasp b/tests/upgrades/0.16.4/bayesian-loglinear-regression.jasp new file mode 100644 index 00000000..55fd60a5 Binary files /dev/null and b/tests/upgrades/0.16.4/bayesian-loglinear-regression.jasp differ diff --git a/tests/upgrades/0.16.4/bayesian-loglinear-regression_aggregated.jasp b/tests/upgrades/0.16.4/bayesian-loglinear-regression_aggregated.jasp new file mode 100644 index 00000000..eb400571 Binary files /dev/null and b/tests/upgrades/0.16.4/bayesian-loglinear-regression_aggregated.jasp differ diff --git a/tests/upgrades/0.16.4/bayesian-multinomial-test.jasp b/tests/upgrades/0.16.4/bayesian-multinomial-test.jasp new file mode 100644 index 00000000..fc648511 Binary files /dev/null and b/tests/upgrades/0.16.4/bayesian-multinomial-test.jasp differ diff --git a/tests/upgrades/0.16.4/binomial-test.jasp b/tests/upgrades/0.16.4/binomial-test.jasp new file mode 100644 index 00000000..a6e89399 Binary files /dev/null and b/tests/upgrades/0.16.4/binomial-test.jasp differ diff --git a/tests/upgrades/0.16.4/contingency-tables.jasp b/tests/upgrades/0.16.4/contingency-tables.jasp new file mode 100644 index 00000000..a3232ab7 Binary files /dev/null and b/tests/upgrades/0.16.4/contingency-tables.jasp differ diff --git a/tests/upgrades/0.16.4/loglinear-regression.jasp b/tests/upgrades/0.16.4/loglinear-regression.jasp new file mode 100644 index 00000000..6ff0efaf Binary files /dev/null and b/tests/upgrades/0.16.4/loglinear-regression.jasp differ diff --git a/tests/upgrades/0.16.4/loglinear-regression_aggregated.jasp b/tests/upgrades/0.16.4/loglinear-regression_aggregated.jasp new file mode 100644 index 00000000..1384c074 Binary files /dev/null and b/tests/upgrades/0.16.4/loglinear-regression_aggregated.jasp differ diff --git a/tests/upgrades/0.16.4/multinomial-test.jasp b/tests/upgrades/0.16.4/multinomial-test.jasp new file mode 100644 index 00000000..a6eb3430 Binary files /dev/null and b/tests/upgrades/0.16.4/multinomial-test.jasp differ