Skip to content

Commit

Permalink
add back ega
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 26, 2023
1 parent 4297d00 commit 9de0d04
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 44 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Suggests:
drc,
DRR,
effectsize (>= 0.8.2),
EGAnet,
emmeans (>= 1.7.0),
estimatr,
factoextra,
Expand Down
3 changes: 0 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
* `print_md()` for `compare_parameters()` now gains more arguments, similar to
the `print()` method.

* `n_factors()` no longer supports `package = "EGAnet"`, as package *EGAnet* was
removed from CRAN.

* `bootstrap_parameters()` and `model_parameters()` now accept bootstrapped
samples returned by `bootstrap_model()`.

Expand Down
78 changes: 37 additions & 41 deletions R/n_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,27 +245,25 @@ n_factors <- function(x,
}
}

# EGAnet was removed from CRAN

# EGAnet -------------------------------------------
# if ("EGAnet" %in% package) {
# insight::check_if_installed("EGAnet")

# if (safe) {
# out <- rbind(
# out,
# tryCatch(.n_factors_ega(x, cor, nobs, eigen_values, type),
# # warning = function(w) data.frame(),
# error = function(e) data.frame()
# )
# )
# } else {
# out <- rbind(
# out,
# .n_factors_ega(x, cor, nobs, eigen_values, type)
# )
# }
# }
if ("EGAnet" %in% package) {
insight::check_if_installed("EGAnet")

if (safe) {
out <- rbind(
out,
tryCatch(.n_factors_ega(x, cor, nobs, eigen_values, type),
# warning = function(w) data.frame(),
error = function(e) data.frame()
)
)
} else {
out <- rbind(
out,
.n_factors_ega(x, cor, nobs, eigen_values, type)
)
}
}


# psych -------------------------------------------
Expand Down Expand Up @@ -545,28 +543,26 @@ print.n_clusters <- print.n_factors
}


# EGAnet was removed from CRAN

# EGAnet ------------------------
# .n_factors_ega <- function(x = NULL,
# cor = NULL,
# nobs = NULL,
# eigen_values = NULL,
# type = "FA") {
# # Replace with own correlation matrix
# junk <- utils::capture.output(suppressWarnings(suppressMessages(
# nfac_glasso <- EGAnet::EGA(cor, n = nobs, model = "glasso", plot.EGA = FALSE)$n.dim # nolint
# )))
# junk <- utils::capture.output(suppressWarnings(suppressMessages(
# nfac_TMFG <- EGAnet::EGA(cor, n = nobs, model = "TMFG", plot.EGA = FALSE)$n.dim # nolint
# )))

# .data_frame(
# n_Factors = as.numeric(c(nfac_glasso, nfac_TMFG)),
# Method = c("EGA (glasso)", "EGA (TMFG)"),
# Family = "EGA"
# )
# }
.n_factors_ega <- function(x = NULL,
cor = NULL,
nobs = NULL,
eigen_values = NULL,
type = "FA") {
# Replace with own correlation matrix
junk <- utils::capture.output(suppressWarnings(suppressMessages(
nfac_glasso <- EGAnet::EGA(cor, n = nobs, model = "glasso", plot.EGA = FALSE)$n.dim # nolint
)))
junk <- utils::capture.output(suppressWarnings(suppressMessages(
nfac_TMFG <- EGAnet::EGA(cor, n = nobs, model = "TMFG", plot.EGA = FALSE)$n.dim # nolint
)))

.data_frame(
n_Factors = as.numeric(c(nfac_glasso, nfac_TMFG)),
Method = c("EGA (glasso)", "EGA (TMFG)"),
Family = "EGA"
)
}


# psych ------------------------
Expand Down

0 comments on commit 9de0d04

Please sign in to comment.