Skip to content

Commit

Permalink
fix bug with adding scores and listwise deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuspfadt committed Jan 21, 2025
1 parent d299c6a commit c26c673
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
14 changes: 12 additions & 2 deletions R/exploratoryfactoranalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...
colNamesR <- paste0(options[["addedScoresPrefix"]], "_", seq_len(length(options$variables)))

container <- createJaspContainer()
container$dependOn(optionsFromObject = modelContainer, options = c("addScores", "addedScoresPrefix"))
container$dependOn(optionsFromObject = modelContainer, options = c("addScores", "addedScoresPrefix", "naAction"))

scores <- modelContainer[["model"]][["object"]][["scores"]]

Expand All @@ -933,7 +933,17 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...
}

container[[colNameR]] <- jaspBase::createJaspColumn(colNameR)
container[[colNameR]]$setScale(scores[, ii])
if (options[["naAction"]] == "pairwise") {
container[[colNameR]]$setScale(scores[, ii])
} else { # for listwise we need to identify the complete cases
# so we need to temporarily load the raw data with the NAs
dataTmp <- .readDataSetToEnd(columns.as.numeric = unlist(options$variables))
scoresTmp <- rep(NA, nrow(dataTmp))
scoresTmp[complete.cases(dataTmp)] <- scores[, ii]
container[[colNameR]]$setScale(scoresTmp)

}

}

jaspResults[["addedScoresContainer"]] <- container
Expand Down
2 changes: 1 addition & 1 deletion R/principalcomponentanalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..

dataset <- .pcaAndEfaDataCovariance(dataset, options, ready)


if (ready)
.pcaCheckErrors(dataset, options)

Expand Down Expand Up @@ -59,7 +60,6 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
if (options[["naAction"]] == "listwise") {
return(.readDataSetToEnd(columns.as.numeric = unlist(options$variables), exclude.na.listwise = unlist(options$variables)))
} else {

return(.readDataSetToEnd(columns.as.numeric = unlist(options$variables)))
}
} else { # if variance covariance matrix as input
Expand Down
3 changes: 2 additions & 1 deletion inst/Description.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Description
website : "jasp-stats.org"
license : "GPL (>= 2)"
hasWrappers : true
preloadData : false

Analysis
{
Expand All @@ -31,7 +32,7 @@ Description
Analysis
{
title: qsTr("Confirmatory Factor Analysis")
func: "confirmatoryFactorAnalysis"
func: "confirmatoryFactorAnalysis"
qml: "ConfirmatoryFactorAnalysis.qml"
}
}
1 change: 1 addition & 0 deletions jaspFactor.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 5cc9ddfa-69dc-44cb-b072-af7608690805

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down

0 comments on commit c26c673

Please sign in to comment.