Skip to content

Commit 760a663

Browse files
authored
Merge branch 'main' into strengejacke/issue1135
2 parents 6d1817f + d5a363d commit 760a663

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

.github/workflows/format-suggest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
pull-requests: write
2929

3030
steps:
31-
- uses: actions/checkout@v5
31+
- uses: actions/checkout@v6
3232
with:
3333
ref: ${{ github.event.pull_request.head.sha }}
3434

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.2.8
4+
Version: 0.28.2.10
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# parameters (devel)
22

3+
* fixed bug in `standardize_info(<fixest>)` that was preventing
4+
`standardise_parameters()` from working for `fixest` models.
5+
36
* `equivalence_test()` gets methods for objects from the *modelbased* package.
47

58
* Improved support for objects from package *survey*.

R/standardize_info.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ standardize_info.default <- function(model,
5050
insight::find_parameters(model, effects = "fixed", flatten = TRUE, ...)
5151
}
5252
types <- parameters_type(model)
53-
# model_matrix <- as.data.frame(stats::model.matrix(model))
5453
model_matrix <- as.data.frame(insight::get_modelmatrix(model))
5554
model_data <- insight::get_data(model, source = "mf", verbose = FALSE)
5655
wgts <- insight::get_weights(model, remove_na = TRUE)
@@ -323,9 +322,12 @@ standardize_info.default <- function(model,
323322
if (info$is_linear) {
324323
if (inherits(model, c("gls", "lme"))) {
325324
response <- insight::get_response(model)
325+
} else if (inherits(model, "fixest")) {
326+
response <- stats::model.matrix(model, type = "lhs")
326327
} else {
327328
response <- stats::model.frame(model)[[1]]
328329
}
330+
329331
means <- deviations <- rep(NA_real_, length = length(names(model_matrix)))
330332
for (i in seq_along(names(model_matrix))) {
331333
variable <- names(model_matrix)[i]
@@ -367,6 +369,8 @@ standardize_info.default <- function(model,
367369
.std_info_response_basic <- function(model, info, params, robust = FALSE, w = NULL, ...) {
368370
if (inherits(model, c("gls", "lme"))) {
369371
response <- insight::get_response(model)
372+
} else if (inherits(model, "fixest")) {
373+
response <- stats::model.matrix(model, type = "lhs")
370374
} else {
371375
response <- stats::model.frame(model)[[1]]
372376
}

tests/testthat/test-standardize_parameters.R

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,22 @@ test_that("standardize_parameters (with functions / interactions)", {
178178
m1 <- lm(Y ~ X * Z)
179179
m2 <- lm(Y ~ X * scale(Z))
180180
m3 <- lm(Y ~ scale(X) * Z)
181-
m4 <- lm(Y ~ scale(X) * scale(Z))
181+
m4 <- lm(scale(Y) ~ scale(X) + scale(Z) + scale(scale(X) * scale(Z))) # ground truth
182182

183183
expect_equal(
184184
standardize_parameters(m1, method = "basic")$Std_Coefficient,
185+
model_parameters(m4)$Coefficient,
186+
ignore_attr = TRUE
187+
)
188+
expect_equal(
185189
standardize_parameters(m2, method = "basic")$Std_Coefficient,
190+
model_parameters(m4)$Coefficient,
186191
ignore_attr = TRUE
187192
)
188193
expect_equal(
189-
standardize_parameters(m1, method = "basic")$Std_Coefficient,
190194
standardize_parameters(m3, method = "basic")$Std_Coefficient,
191-
ignore_attr = TRUE
195+
model_parameters(m4)$Coefficient
192196
)
193-
# expect_equal(
194-
# standardize_parameters(m1, method = "basic")$Std_Coefficient,
195-
# standardize_parameters(m4, method = "basic")$Std_Coefficient
196-
# )
197-
198197

199198
# transformed resp or pred should not affect
200199
mtcars$cyl_exp <- exp(mtcars$cyl)

0 commit comments

Comments
 (0)