diff --git a/R/regressionlinear.R b/R/regressionlinear.R index 30c4f511..f33ac7f8 100755 --- a/R/regressionlinear.R +++ b/R/regressionlinear.R @@ -111,6 +111,11 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) { is.factor(var) && nlevels(var) > 2 } +.linregCheckIfInteractionWithFactors <- function(modelTerm, factorVariables) { + # Custom function to check if interaction contains more than 1 factor + sum(modelTerm[["components"]] %in% factorVariables) > 1 +} + .linregCheckErrors <- function(dataset, options) { stepwiseProcedureChecks <- NULL if (options$method %in% c("backward", "forward", "stepwise")) { @@ -121,6 +126,12 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) { return(gettext("Stepwise procedures are not supported for models containing factors with more than 2 levels; retry the analysis using dummy variables")) } }, + + checkIfFactorInteractions = function() { + if (any(vapply(options[["modelTerms"]], .linregCheckIfInteractionWithFactors, logical(1L), factorVariables = options[["factors"]]))) { + return(gettext("Stepwise procedures are not supported for interactions containing more than 1 factor")) + } + }, checkIfPEntryIsValid = function() { if (options$steppingMethodCriteriaType == "pValue" && options$steppingMethodCriteriaPEntry > options$steppingMethodCriteriaPRemoval) @@ -2027,7 +2038,7 @@ RegressionLinearInternal <- function(jaspResults, dataset = NULL, options) { ans <- character(length(params)) for (i in seq_along(params)) { - ans[i] <- if (levels[i] == "") params[i] else paste0(params[i], " (", levels[i], ")") + ans[i] <- if (is.na(levels[i]) || levels[i] == "") params[i] else paste0(params[i], " (", levels[i], ")") } title[j] <- paste(ans, collapse = " \u2009\u273b\u2009 ") }