Skip to content

Commit 6ad82d6

Browse files
authored
Support for {lcmm} (#1170)
* Support for `{lcmm}` Fixes #1169 * fix warnings in examples * add tests * update tests * styler * rfeactor * news, desc
1 parent 7cd9d0f commit 6ad82d6

File tree

13 files changed

+538
-126
lines changed

13 files changed

+538
-126
lines changed

DESCRIPTION

Lines changed: 2 additions & 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.3
4+
Version: 0.28.2.4
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -148,6 +148,7 @@ Suggests:
148148
ivreg,
149149
knitr,
150150
lavaan,
151+
lcmm,
151152
lfe,
152153
lm.beta,
153154
lme4,

NAMESPACE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ S3method(model_parameters,draws)
243243
S3method(model_parameters,emmGrid)
244244
S3method(model_parameters,emm_list)
245245
S3method(model_parameters,epi.2by2)
246+
S3method(model_parameters,externVar)
247+
S3method(model_parameters,externX)
246248
S3method(model_parameters,estimate_contrasts)
247249
S3method(model_parameters,estimate_means)
248250
S3method(model_parameters,estimate_slopes)
@@ -275,6 +277,7 @@ S3method(model_parameters,ivFixed)
275277
S3method(model_parameters,ivprobit)
276278
S3method(model_parameters,kmeans)
277279
S3method(model_parameters,lavaan)
280+
S3method(model_parameters,lcmm)
278281
S3method(model_parameters,list)
279282
S3method(model_parameters,lm_robust)
280283
S3method(model_parameters,lme)
@@ -457,6 +460,8 @@ S3method(p_value,draws)
457460
S3method(p_value,eglm)
458461
S3method(p_value,emmGrid)
459462
S3method(p_value,emm_list)
463+
S3method(p_value,externVar)
464+
S3method(p_value,externX)
460465
S3method(p_value,feglm)
461466
S3method(p_value,fixest_multi)
462467
S3method(p_value,flac)
@@ -482,6 +487,7 @@ S3method(p_value,ivFixed)
482487
S3method(p_value,ivprobit)
483488
S3method(p_value,ivreg)
484489
S3method(p_value,lavaan)
490+
S3method(p_value,lcmm)
485491
S3method(p_value,list)
486492
S3method(p_value,lm)
487493
S3method(p_value,lm_robust)
@@ -797,6 +803,8 @@ S3method(standard_error,draws)
797803
S3method(standard_error,effectsize_table)
798804
S3method(standard_error,emmGrid)
799805
S3method(standard_error,emm_list)
806+
S3method(standard_error,externVar)
807+
S3method(standard_error,externX)
800808
S3method(standard_error,estimate_contrasts)
801809
S3method(standard_error,estimate_means)
802810
S3method(standard_error,estimate_slopes)
@@ -829,6 +837,7 @@ S3method(standard_error,ivFixed)
829837
S3method(standard_error,ivprobit)
830838
S3method(standard_error,ivreg)
831839
S3method(standard_error,lavaan)
840+
S3method(standard_error,lcmm)
832841
S3method(standard_error,list)
833842
S3method(standard_error,lm_robust)
834843
S3method(standard_error,lme)

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# parameters 0.28.2.1
1+
# parameters (devel)
22

33
* `equivalence_test()` gets methods for objects from the *modelbased* package.
44

5+
* Added support for package *lcmm*.
6+
57
# parameters 0.28.2
68

79
## Bug fixes

R/ci_generic.R

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,19 @@
6464

6565

6666
#' @keywords internal
67-
.ci_dof <- function(model,
68-
ci,
69-
dof,
70-
effects,
71-
component,
72-
method = "wald",
73-
se = NULL,
74-
vcov = NULL,
75-
vcov_args = NULL,
76-
verbose = TRUE,
77-
...) {
67+
.ci_dof <- function(
68+
model,
69+
ci,
70+
dof,
71+
effects,
72+
component,
73+
method = "wald",
74+
se = NULL,
75+
vcov = NULL,
76+
vcov_args = NULL,
77+
verbose = TRUE,
78+
...
79+
) {
7880
# need parameters to calculate the CIs
7981
if (inherits(model, "emmGrid")) {
8082
params <- insight::get_parameters(
@@ -84,7 +86,8 @@
8486
merge_parameters = TRUE
8587
)
8688
} else {
87-
params <- insight::get_parameters(model,
89+
params <- insight::get_parameters(
90+
model,
8891
effects = effects,
8992
component = component,
9093
verbose = FALSE
@@ -110,7 +113,8 @@
110113
if (is.null(se)) {
111114
if (!is.null(vcov) || isTRUE(list(...)[["robust"]])) {
112115
# robust (HC) standard errors?
113-
stderror <- standard_error(model,
116+
stderror <- standard_error(
117+
model,
114118
component = component,
115119
vcov = vcov,
116120
vcov_args = vcov_args,
@@ -119,7 +123,8 @@
119123
)
120124
} else {
121125
# normal standard errors, including small-sample approximations
122-
stderror <- switch(method,
126+
stderror <- switch(
127+
method,
123128
kenward = se_kenward(model),
124129
kr = se_kenward(model),
125130
satterthwaite = se_satterthwaite(model),
@@ -134,9 +139,11 @@
134139

135140
# filter non-matching parameters, resp. sort stderror and parameters,
136141
# so both have the identical order of values
137-
if (nrow(stderror) != nrow(params) ||
138-
!all(stderror$Parameter %in% params$Parameter) ||
139-
!all(order(stderror$Parameter) == order(params$Parameter))) {
142+
if (
143+
nrow(stderror) != nrow(params) ||
144+
!all(stderror$Parameter %in% params$Parameter) ||
145+
!all(order(stderror$Parameter) == order(params$Parameter))
146+
) {
140147
params <- stderror <- merge(stderror, params, sort = FALSE)
141148
}
142149

@@ -164,19 +171,25 @@
164171

165172
alpha <- (1 + ci) / 2
166173
fac <- suppressWarnings(stats::qt(alpha, df = dof))
167-
out <- cbind(
168-
CI_low = params$Estimate - se * fac,
169-
CI_high = params$Estimate + se * fac
170-
)
174+
out <- cbind(CI_low = params$Estimate - se * fac, CI_high = params$Estimate + se * fac)
171175

172176
out <- as.data.frame(out)
173177
out$CI <- ci
174178
out$Parameter <- params$Parameter
175179

176180
out <- out[c("Parameter", "CI", "CI_low", "CI_high")]
177-
if ("Component" %in% names(params)) out$Component <- params$Component
178-
if ("Effects" %in% names(params) && effects != "fixed") out$Effects <- params$Effects
179-
if ("Response" %in% names(params)) out$Response <- params$Response
181+
if ("Component" %in% names(params)) {
182+
out$Component <- params$Component
183+
}
184+
if ("Effects" %in% names(params) && effects != "fixed") {
185+
out$Effects <- params$Effects
186+
}
187+
if ("Response" %in% names(params)) {
188+
out$Response <- params$Response
189+
}
190+
if ("Group" %in% names(params) && inherits(model, c("lcmm", "externX", "externVar"))) {
191+
out$Group <- params$Group
192+
}
180193

181194
# for cox-panel models, we have non-linear parameters with NA coefficient,
182195
# but test statistic and p-value - don't check for NA estimates in this case

0 commit comments

Comments
 (0)