Skip to content

Commit

Permalink
Fix missing value handling options
Browse files Browse the repository at this point in the history
  • Loading branch information
maltelueken committed Oct 10, 2023
1 parent 1a3cab4 commit bb4a918
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
37 changes: 20 additions & 17 deletions R/classicProcess.R
Original file line number Diff line number Diff line change
Expand Up @@ -990,20 +990,9 @@ procModelGraphSingleModel <- function(modelOptions, globalDependent, options) {
summaryTable$dependOn(c(.procGetDependencies(), "processModels", "aicWeights", "bicWeights", "naAction"))
summaryTable$position <- 1

modelNumbers <- lapply(options[["processModels"]], function(mod) {
if (mod[["inputType"]] == "inputModelNumber") {
if (!mod[["modelNumber"]] %in% .procHardCodedModelNumbers()) {
modelNumberTable$setError(gettextf("Hayes model number %s for %s not implemented", mod[["modelNumber"]], mod[["name"]]))
}
return(mod[["modelNumber"]])
}

return(.procRecognizeModelNumber(modelsContainer[[mod[["name"]]]][["graph"]]$object))
}
)

modelNames <- sapply(options[["processModels"]], function(mod) mod[["name"]])
isInvalid <- sapply(procResults, is.character)
if (options[["naAction"]] == "fiml" && !options[["estimator"]] %in% c("auto", "ml")) {
summaryTable$setError("Full Information Maximum Likelihood estimation only available with 'ML' or 'Auto' estimators. Please choose a different estimator or option for missing value handling.")
}

summaryTable$addColumnInfo(name = "Model", title = "", type = "string" )
summaryTable$addColumnInfo(name = "modelNumber", title = "Hayes model number", type = "integer" )
Expand All @@ -1021,14 +1010,28 @@ procModelGraphSingleModel <- function(modelOptions, globalDependent, options) {

jaspResults[["modelSummaryTable"]] <- summaryTable

if (length(procResults) == 0) return()
isInvalid <- sapply(procResults, is.character)

if (any(isInvalid)) {
errmsg <- gettextf("Model fit could not be assessed because one or more models were not estimated: %s", names(procResults)[isInvalid])
summaryTable$setError(errmsg)
return()
}

if (length(procResults) == 0) return()

modelNumbers <- lapply(options[["processModels"]], function(mod) {
if (mod[["inputType"]] == "inputModelNumber") {
if (!mod[["modelNumber"]] %in% .procHardCodedModelNumbers()) {
modelNumberTable$setError(gettextf("Hayes model number %s for %s not implemented", mod[["modelNumber"]], mod[["name"]]))
}
return(mod[["modelNumber"]])
}

return(.procRecognizeModelNumber(modelsContainer[[mod[["name"]]]][["graph"]]$object))
})

modelNames <- sapply(options[["processModels"]], function(mod) mod[["name"]])

aic <- sapply(procResults, AIC)
bic <- sapply(procResults, BIC)
df <- sapply(procResults, lavaan::fitMeasures, fit.measures = "df")
Expand All @@ -1053,7 +1056,7 @@ procModelGraphSingleModel <- function(modelOptions, globalDependent, options) {
}

if (options$estimator %in% c("dwls", "gls", "wls", "uls")) {
summaryTable$addFootnote(message = gettext("The AIC, BIC and additional information criteria are only available with ML-type estimators"))
summaryTable$addFootnote(message = gettext("The AIC, BIC and additional information criteria are only available with ML-type estimators."))
}
}

Expand Down
4 changes: 2 additions & 2 deletions inst/qml/ClassicProcess.qml
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ Form
{
title: qsTr("Missing Value Handling")
name: "naAction"
RadioButton { text: qsTr("Full Information Maximum Likelihood") ; name: "fiml" ; checked: true }
RadioButton { text: qsTr("Exclude cases listwise") ; name: "listwise" }
RadioButton { text: qsTr("Exclude cases listwise") ; name: "listwise" ; checked: true }
RadioButton { text: qsTr("Full Information Maximum Likelihood") ; name: "fiml" }
}
RadioButtonGroup
{
Expand Down

0 comments on commit bb4a918

Please sign in to comment.