Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Suggests:
ivreg,
knitr,
lavaan,
lcmm,
lfe,
lm.beta,
lme4,
Expand Down
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ S3method(model_parameters,draws)
S3method(model_parameters,emmGrid)
S3method(model_parameters,emm_list)
S3method(model_parameters,epi.2by2)
S3method(model_parameters,externVar)
S3method(model_parameters,externX)
S3method(model_parameters,estimate_contrasts)
S3method(model_parameters,estimate_means)
S3method(model_parameters,estimate_slopes)
Expand Down Expand Up @@ -275,6 +277,7 @@ S3method(model_parameters,ivFixed)
S3method(model_parameters,ivprobit)
S3method(model_parameters,kmeans)
S3method(model_parameters,lavaan)
S3method(model_parameters,lcmm)
S3method(model_parameters,list)
S3method(model_parameters,lm_robust)
S3method(model_parameters,lme)
Expand Down Expand Up @@ -457,6 +460,8 @@ S3method(p_value,draws)
S3method(p_value,eglm)
S3method(p_value,emmGrid)
S3method(p_value,emm_list)
S3method(p_value,externVar)
S3method(p_value,externX)
S3method(p_value,feglm)
S3method(p_value,fixest_multi)
S3method(p_value,flac)
Expand All @@ -482,6 +487,7 @@ S3method(p_value,ivFixed)
S3method(p_value,ivprobit)
S3method(p_value,ivreg)
S3method(p_value,lavaan)
S3method(p_value,lcmm)
S3method(p_value,list)
S3method(p_value,lm)
S3method(p_value,lm_robust)
Expand Down Expand Up @@ -797,6 +803,8 @@ S3method(standard_error,draws)
S3method(standard_error,effectsize_table)
S3method(standard_error,emmGrid)
S3method(standard_error,emm_list)
S3method(standard_error,externVar)
S3method(standard_error,externX)
S3method(standard_error,estimate_contrasts)
S3method(standard_error,estimate_means)
S3method(standard_error,estimate_slopes)
Expand Down Expand Up @@ -829,6 +837,7 @@ S3method(standard_error,ivFixed)
S3method(standard_error,ivprobit)
S3method(standard_error,ivreg)
S3method(standard_error,lavaan)
S3method(standard_error,lcmm)
S3method(standard_error,list)
S3method(standard_error,lm_robust)
S3method(standard_error,lme)
Expand Down
61 changes: 37 additions & 24 deletions R/ci_generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@


#' @keywords internal
.ci_dof <- function(model,
ci,
dof,
effects,
component,
method = "wald",
se = NULL,
vcov = NULL,
vcov_args = NULL,
verbose = TRUE,
...) {
.ci_dof <- function(
model,
ci,
dof,
effects,
component,
method = "wald",
se = NULL,
vcov = NULL,
vcov_args = NULL,
verbose = TRUE,
...
) {
# need parameters to calculate the CIs
if (inherits(model, "emmGrid")) {
params <- insight::get_parameters(
Expand All @@ -84,7 +86,8 @@
merge_parameters = TRUE
)
} else {
params <- insight::get_parameters(model,
params <- insight::get_parameters(
model,
effects = effects,
component = component,
verbose = FALSE
Expand All @@ -110,7 +113,8 @@
if (is.null(se)) {
if (!is.null(vcov) || isTRUE(list(...)[["robust"]])) {
# robust (HC) standard errors?
stderror <- standard_error(model,
stderror <- standard_error(
model,
component = component,
vcov = vcov,
vcov_args = vcov_args,
Expand All @@ -119,7 +123,8 @@
)
} else {
# normal standard errors, including small-sample approximations
stderror <- switch(method,
stderror <- switch(
method,
kenward = se_kenward(model),
kr = se_kenward(model),
satterthwaite = se_satterthwaite(model),
Expand All @@ -134,9 +139,11 @@

# filter non-matching parameters, resp. sort stderror and parameters,
# so both have the identical order of values
if (nrow(stderror) != nrow(params) ||
!all(stderror$Parameter %in% params$Parameter) ||
!all(order(stderror$Parameter) == order(params$Parameter))) {
if (
nrow(stderror) != nrow(params) ||
!all(stderror$Parameter %in% params$Parameter) ||
!all(order(stderror$Parameter) == order(params$Parameter))
) {
params <- stderror <- merge(stderror, params, sort = FALSE)
}

Expand Down Expand Up @@ -164,19 +171,25 @@

alpha <- (1 + ci) / 2
fac <- suppressWarnings(stats::qt(alpha, df = dof))
out <- cbind(
CI_low = params$Estimate - se * fac,
CI_high = params$Estimate + se * fac
)
out <- cbind(CI_low = params$Estimate - se * fac, CI_high = params$Estimate + se * fac)

out <- as.data.frame(out)
out$CI <- ci
out$Parameter <- params$Parameter

out <- out[c("Parameter", "CI", "CI_low", "CI_high")]
if ("Component" %in% names(params)) out$Component <- params$Component
if ("Effects" %in% names(params) && effects != "fixed") out$Effects <- params$Effects
if ("Response" %in% names(params)) out$Response <- params$Response
if ("Component" %in% names(params)) {
out$Component <- params$Component
}
if ("Effects" %in% names(params) && effects != "fixed") {
out$Effects <- params$Effects
}
if ("Response" %in% names(params)) {
out$Response <- params$Response
}
if ("Group" %in% names(params) && inherits(model, c("lcmm", "externX", "externVar"))) {
out$Group <- params$Group
}

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