betaDelta: Example Using the DeltaGeneric Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-delta-generic.Rmd
example-delta-generic.Rmd
In this example, we use the delta method to calculate the odds ratio, the associated standard errors, and confidence intervals within a logistic regression model.
object <- glm(
formula = vs ~ wt + disp,
family = "binomial",
data = mtcars
)
def <- list("exp(wt)", "exp(disp)")
DeltaGeneric(
object = object,
def = def,
alpha = 0.05
)
#> Call:
#> DeltaGeneric(object = object, def = def, alpha = 0.05)
#> est se z p 2.5% 97.5%
#> exp(wt) 5.0853 7.5805 0.6708 0.5023 -9.7723 19.9429
#> exp(disp) 0.9662 0.0148 65.0838 0.0000 0.9371 0.9952
Methods
delta <- DeltaGeneric(
object = object,
def = def,
alpha = 0.05
)
summary
Summary of the results of DeltaGeneric()
.
summary(delta)
#> Call:
#> DeltaGeneric(object = object, def = def, alpha = 0.05)
#> est se z p 2.5% 97.5%
#> exp(wt) 5.0853 7.5805 0.6708 0.5023 -9.7723 19.9429
#> exp(disp) 0.9662 0.0148 65.0838 0.0000 0.9371 0.9952
vcov
Calculate the sampling covariance matrix.
vcov(delta)
#> exp(wt) exp(disp)
#> exp(wt) 57.46443026 -0.0977480169
#> exp(disp) -0.09774802 0.0002203662
confint
Generate confidence intervals.
confint(delta, level = 0.95)
#> 2.5 % 97.5 %
#> exp(wt) -9.7722691 19.9428612
#> exp(disp) 0.9370572 0.9952475
References
Pesigan, I. J. A., Sun, R. W., & Cheung, S. F. (2023). betaDelta and betaSandwich: Confidence intervals for
standardized regression coefficients in R. Multivariate
Behavioral Research, 58(6), 1183–1186. https://doi.org/10.1080/00273171.2023.2201277