Skip to content

Commit 92af4a1

Browse files
mattansbgithub-actions[bot]strengejacke
authored
Don't return the intercept when include_response = FALSE (#1185)
* Update standardize_parameters.R * fix test * Update R/standardize_parameters.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update tests/testthat/test-standardize_parameters.R Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * air * version bump + news * remove p etc from unstantdardized intercept * Update standardize_parameters.R * always NA inferential stats for NA std coef * Update NEWS.md * fix tests * air * fix and add tests --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Daniel <mail@danielluedecke.de>
1 parent 0a911a3 commit 92af4a1

7 files changed

Lines changed: 368 additions & 149 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: parameters
33
Title: Processing of Model Parameters
4-
Version: 0.28.3.2
4+
Version: 0.28.3.3
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Changes
44

5+
* `standardize_parameters()` (and by extension `model_parameters()`) with any of
6+
the _post-hoc_ standardization methods no longer standardizes the
7+
`"(Intercept)"` parameter - instead setting it to `NA`.
8+
* `standardize_parameters()` with any of the _post-hoc_ standardization methods
9+
sets all inferential statistics (z, p, etc...) for the `"(Intercept)"` and any
10+
other `NA` parameters to `NA`.
511
* `model_parameters()` now supports objects from the *lavaan.mi* package.
612

713
## Bug fixes

R/extract_parameters.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@
306306
parameters$CI_high <- std_parms$CI_high
307307
}
308308

309+
parameters <- .NA_inferential_cols(parameters)
310+
309311
coef_col <- "Std_Coefficient"
310312
}
311313

@@ -648,6 +650,7 @@
648650

649651
# Std Coefficients for other methods than "refit"
650652
if (!is.null(standardize)) {
653+
# give minimal attributes required for standardization
651654
temp_pars <- parameters
652655
class(temp_pars) <- c("parameters_model", class(temp_pars))
653656
attr(temp_pars, "ci") <- ci
@@ -662,6 +665,8 @@
662665
parameters$CI_high <- std_parms$CI_high
663666
}
664667

668+
parameters <- .NA_inferential_cols(parameters)
669+
665670
coef_col <- "Std_Coefficient"
666671
}
667672

@@ -1048,3 +1053,17 @@
10481053
}
10491054
p
10501055
}
1056+
1057+
.NA_inferential_cols <- function(pr) {
1058+
# For models where the response is NOT standardized, the (Intercept) is set
1059+
# to NA and so we also need to set all inferential statistics to NA
1060+
rows_to_NA <- pr$Parameter %in% "(Intercept)" | is.na(pr$Std_Coefficient)
1061+
if (any(rows_to_NA)) {
1062+
# fmt: skip
1063+
cols_not_to_NA <- c(".id", "Parameter", "Component", "Response", "Effects", "Group",
1064+
"CI", "Std_Coefficient")
1065+
cols_to_NA <- setdiff(colnames(pr), cols_not_to_NA)
1066+
pr[rows_to_NA, cols_to_NA] <- NA
1067+
}
1068+
pr
1069+
}

0 commit comments

Comments
 (0)