confint.lm_betaselect: Confidence Interval for 'lm_betaselect' or 'glm_betaselect'...

View source: R/lm_betaselect_methods.R

confint.lm_betaselectR Documentation

Confidence Interval for 'lm_betaselect' or 'glm_betaselect' Objects

Description

Return the confidence interval of the regression coefficients in the output of lm_betaselect() or glm_betaselect().

Usage

## S3 method for class 'lm_betaselect'
confint(
  object,
  parm,
  level = 0.95,
  method = c("boot", "bootstrap", "ls"),
  type = c("beta", "standardized", "raw", "unstandardized"),
  warn = TRUE,
  boot_type = c("perc", "bc"),
  ...
)

## S3 method for class 'glm_betaselect'
confint(
  object,
  parm,
  level = 0.95,
  trace = FALSE,
  test = c("LRT", "Rao"),
  method = c("boot", "bootstrap", "default", "ls"),
  type = c("beta", "standardized", "raw", "unstandardized"),
  warn = TRUE,
  boot_type = c("perc", "bc"),
  transform_b = NULL,
  ...
)

Arguments

object

The output of lm_betaselect() or glm_betaselect().

parm

The terms for which the confidence intervals are returned. If missing, the confidence intervals of all terms will be returned.

level

The level of confidence, default is .95, returning the 95% confidence interval.

method

The method used to compute the confidence intervals/ If bootstrapping was requested when calling lm_betaselect() and this argument is set to "bootstrap" or "boot", the bootstrap confidence intervals are returned. If bootstrapping was not requested or if this argument is set to "ls", then the usual lm confidence intervals are returned, with a warning raised unless type is "raw" or ⁠"unstandardized".⁠ Default is "boot".

type

String. If "unstandardized" or "raw", the confidence intervals of the coefficients before standardization are returned. If "beta" or "standardized", then the confidence intervals of the coefficients after selected variables standardized are returned. Default is "beta".

warn

Logical. Whether a warning will be raised is OLS (or WLS) confidence intervals are requested for the model with some variables standardized (i.e., type is "beta" or "standardized"). Default is TRUE.

boot_type

The type of bootstrap confidence intervals. Currently, it supports "perc", percentile bootstrap confidence intervals, and "bc", bias-corrected bootstrap confidence interval.

...

Optional arguments. Ignored.

trace

Logical. Whether profiling will be traced. See stats::confint.glm() for details. ignored if method is "boot" or "bootstrap".

test

The test used for profiling. See stats::confint.glm for details. ignored if method is "boot" or "bootstrap".

transform_b

The function to be used to transform the confidence limits. For example, if set to exp, the confidence limits will be exponentiated. Users need to decide whether the transformed limits are meaningful. Default is NULL.

Details

The type of confidence intervals depends on the object. If bootstrapping was requested, by default it returns the percentile bootstrap confidence intervals. Otherwise, it returns the default confidence intervals.

Support for other type of confidence intervals may be added in the future.

Value

A p by 2 matrix of the confidence intervals, p being the number of coefficients.

Author(s)

Shu Fai Cheung https://orcid.org/0000-0002-9871-9448

See Also

lm_betaselect()

Examples


data(data_test_mod_cat)

# bootstrap should be set to 2000 or 5000 in real studies
lm_beta_x <- lm_betaselect(dv ~ iv*mod + cov1 + cat1,
                           data = data_test_mod_cat,
                           to_standardize = "iv",
                           do_boot = TRUE,
                           bootstrap = 100,
                           iseed = 1234)
confint(lm_beta_x)
confint(lm_beta_x, method = "ls")
confint(lm_beta_x, type = "raw")


data_test_mod_cat$p <- scale(data_test_mod_cat$dv)[, 1]
data_test_mod_cat$p <- ifelse(data_test_mod_cat$p > 0,
                              yes = 1,
                              no = 0)
# bootstrap should be set to 2000 or 5000 in real studies
logistic_beta_x <- glm_betaselect(p ~ iv*mod + cov1 + cat1,
                                  data = data_test_mod_cat,
                                  family = binomial,
                                  to_standardize = "iv",
                                  do_boot = TRUE,
                                  bootstrap = 100,
                                  iseed = 1234)

confint(logistic_beta_x, method = "default")
confint(logistic_beta_x, type = "raw")


betaselectr documentation built on April 3, 2025, 8:51 p.m.