Skip to content

Commit

Permalink
Fix test release issues jaspFactor (#248)
Browse files Browse the repository at this point in the history
* add seed stuff

* add varCovData to check Errors

* also adjust the tests

* renv lock file
  • Loading branch information
juliuspfadt authored Dec 6, 2024
1 parent 49db5b1 commit 418b2c7
Show file tree
Hide file tree
Showing 8 changed files with 969 additions and 439 deletions.
22 changes: 14 additions & 8 deletions R/exploratoryfactoranalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...
)

if (options[["dataType"]] == "raw") {
error <- .hasErrors(dataset = dataset, type = c("infinity", "variance"), custom = customChecksEFA,
error <- .hasErrors(dataset = dataset, type = c("infinity", "variance", "varCovData"), custom = customChecksEFA,
exitAnalysisIfErrors = TRUE)
}

Expand Down Expand Up @@ -192,15 +192,17 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...

if (options[["analysisBasedOn"]] == "polyTetrachoricCorrelationMatrix") {
polyTetraCor <- psych::mixedCor(dataset)
set.seed(options[["parallelAnalysisSeed"]])
.setSeedJASP(options)

parallelResult <- try(psych::fa.parallel(polyTetraCor$rho,
plot = FALSE,
fa = ifelse(options[["parallelAnalysisMethod"]] == "principalComponentBased",
"pc", "fa"),
n.obs = nrow(dataset)))
}
else {
set.seed(options[["parallelAnalysisSeed"]])
.setSeedJASP(options)

parallelResult <- try(psych::fa.parallel(dataset, plot = FALSE,
fa = ifelse(options[["parallelAnalysisMethod"]] == "principalComponentBased",
"pc", "fa")))
Expand Down Expand Up @@ -600,14 +602,16 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...

if (options[["analysisBasedOn"]] == "polyTetrachoricCorrelationMatrix") {
polyTetraCor <- psych::mixedCor(dataset)
set.seed(options[["parallelAnalysisSeed"]])
.setSeedJASP(options)

parallelResult <- try(psych::fa.parallel(polyTetraCor$rho,
plot = FALSE,
fa = ifelse(options[["parallelAnalysisTableMethod"]] == "principalComponentBased",
"pc", "fa"),
n.obs = nrow(dataset)))
} else {
set.seed(options[["parallelAnalysisSeed"]])
.setSeedJASP(options)

parallelResult <- try(psych::fa.parallel(dataset, plot = FALSE,
fa = ifelse(options[["parallelAnalysisTableMethod"]] == "principalComponentBased",
"pc", "fa")))
Expand All @@ -628,7 +632,7 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...
}

parallelTable <- createJaspTable(gettext("Parallel Analysis"))
parallelTable$dependOn(c("parallelAnalysisTable", "parallelAnalysisTableMethod", "parallelAnalysisSeed"))
parallelTable$dependOn(c("parallelAnalysisTable", "parallelAnalysisTableMethod"))
parallelTable$addColumnInfo(name = "col", title = "", type = "string")

parallelTable$addColumnInfo(name = "val1", title = eigTitle, type = "number", format = "dp:3")
Expand Down Expand Up @@ -679,14 +683,16 @@ exploratoryFactorAnalysisInternal <- function(jaspResults, dataset, options, ...

if (options[["analysisBasedOn"]] == "polyTetrachoricCorrelationMatrix") {
polyTetraCor <- psych::mixedCor(dataset)
set.seed(options[["parallelAnalysisSeed"]])
.setSeedJASP(options)

parallelResult <- try(psych::fa.parallel(polyTetraCor$rho,
plot = FALSE,
fa = ifelse(options[["parallelAnalysisTableMethod"]] == "principalComponentBased",
"pc", "fa"),
n.obs = nrow(dataset)))
} else {
set.seed(options[["parallelAnalysisSeed"]])
.setSeedJASP(options)

parallelResult <- try(psych::fa.parallel(dataset, plot = FALSE,
fa = ifelse(options[["parallelAnalysisTableMethod"]] == "principalComponentBased",
"pc", "fa")))
Expand Down
2 changes: 1 addition & 1 deletion R/principalcomponentanalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ principalComponentAnalysisInternal <- function(jaspResults, dataset, options, ..
)

if (options[["dataType"]] == "raw") {
error <- .hasErrors(dataset = dataset, type = c("infinity", "variance"), custom = customChecksPCAEFA,
error <- .hasErrors(dataset = dataset, type = c("infinity", "variance", "varCovData"), custom = customChecksPCAEFA,
exitAnalysisIfErrors = TRUE)
}

Expand Down
12 changes: 3 additions & 9 deletions inst/qml/ExploratoryFactorAnalysis.qml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,9 @@ Form
label: qsTr("Based on FA")
}
}
IntegerField
{
name: "parallelAnalysisSeed"
label: "Seed"
defaultValue: 1234
fieldWidth: 60
min: 1
max: 1e6
}

SetSeed{}

}

RadioButton
Expand Down
11 changes: 2 additions & 9 deletions inst/qml/PrincipalComponentAnalysis.qml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,8 @@ Form
label: qsTr("Based on factors")
}
}
IntegerField
{
name: "parallelAnalysisSeed"
label: "Seed"
defaultValue: 1234
fieldWidth: 60
min: 1
max: 1e6
}
SetSeed{}

}
RadioButton
{
Expand Down
Loading

0 comments on commit 418b2c7

Please sign in to comment.