Skip to content

Commit

Permalink
Refactor model fitting check function
Browse files Browse the repository at this point in the history
  • Loading branch information
maltelueken committed Oct 23, 2023
1 parent 79431ba commit 8eaafb5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions R/classicProcess.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,6 @@ ClassicProcess <- function(jaspResults, dataset = NULL, options) {
return(varNames)
}

.procCheckRegListVars <- function(vars) {
# Check if vector of var names contains encoded X, W, Z, or M (not Y!!)
encoding <- .procVarEncoding()
return(!any(c(encoding[["X"]], encoding[["W"]], encoding[["Z"]]) %in% vars) && !any(grepl(encoding[["M"]], vars)))
}

.procReplaceDummyVars <- function(vars, modelOptions, globalDependent) {
# Get encoding
encoding <- .procVarEncoding()
Expand Down Expand Up @@ -866,11 +860,17 @@ ClassicProcess <- function(jaspResults, dataset = NULL, options) {
}

# Results functions ----
.procCheckFitModelVars <- function(vars) {
# Check if vector of var names contains encoded X, W, Z, or M (not Y!!)
encoding <- .procVarEncoding()
return(!any(unlist(encoding) %in% vars) && !any(grepl(encoding[["M"]], vars)))
}

.procCheckFitModel <- function(graph) {
if (inherits(graph, "try-error")) return(FALSE)
return(all(sapply(igraph::V(graph)$intVars, function(v) {
return(all(sapply(v, .procCheckRegListVars)))
})))
allSourcesValid <- .procCheckFitModelVars(igraph::E(graph)$source)
allTargetsValid <- .procCheckFitModelVars(igraph::E(graph)$target)
return(allSourcesValid && allTargetsValid)
}

.procGraphAddEstimates <- function(graph, fittedModel, type = "effects") {
Expand Down

0 comments on commit 8eaafb5

Please sign in to comment.