Skip to content

Commit

Permalink
add seed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuspfadt committed Nov 25, 2024
1 parent dfd60df commit ae2a1f2
Show file tree
Hide file tree
Showing 4 changed files with 968 additions and 427 deletions.
20 changes: 13 additions & 7 deletions R/exploratoryfactoranalysis.R
Original file line number Diff line number Diff line change
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
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 ae2a1f2

Please sign in to comment.