Skip to content

Commit

Permalink
minor code style
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 28, 2024
1 parent ee2b43f commit 4cfaacb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions R/r2_mlm.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ r2_mlm <- function(model, ...) {

#' @export
r2_mlm.mlm <- function(model, verbose = TRUE, ...) {

rho2_vec <-
1 - stats::cancor(insight::get_predictors(model), insight::get_response(model))$cor^2
rho2_vec <- 1 - stats::cancor(
insight::get_predictors(model),
insight::get_response(model)
)$cor^2
R_xy <- 1 - Reduce(`*`, rho2_vec, 1)

resid_cov <- stats::cov(residuals(model))
Expand All @@ -80,8 +81,5 @@ r2_mlm.mlm <- function(model, verbose = TRUE, ...) {
V_xy <- qq - sum(diag(solve(resp_cov) %*% resid_cov))
P_xy <- V_xy / qq

c(
"Symmetric Rxy" = R_xy,
"Asymmetric Pxy" = P_xy
)
c("Symmetric Rxy" = R_xy, "Asymmetric Pxy" = P_xy)
}

0 comments on commit 4cfaacb

Please sign in to comment.