Estimates standard errors for transformations of random variables using Delta method.
Usage
tidydelta(
formula,
normality_eval = TRUE,
formula_vars = mean,
mean_dta = NULL,
cov_dta = NULL,
n = NULL,
conf_lev = 0.95
)
Arguments
- formula
A formula object specifying the variables of interest.
- normality_eval
Logical value to run normality test in case of being possible.
- formula_vars
The function(s) to apply to the variables in the formula.
- mean_dta
Vector containing the means of the variables.
- cov_dta
Covariance matrix of the variables.
- n
Sample size evaluation (in case that we can evaluate the confidence intervals with different hypnotic sample sizes).
- conf_lev
Confidence level for confidence intervals.
Examples
# Equivalent ways to use tidydelta()
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#> ✔ dplyr 1.1.4 ✔ readr 2.1.5
#> ✔ forcats 1.0.0 ✔ stringr 1.5.1
#> ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
#> ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
#> ✔ purrr 1.0.2
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag() masks stats::lag()
#> ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
x <- rnorm(1000, mean = 5, sd = 2)
y <- rnorm(1000, mean = 15, sd = 3)
bd <- tibble(x, y)
tidydelta(~ y / x,
conf_lev = .95
)
#> Error in where_env(vars_select): Object not found in envs.
tidydelta(~ bd$y / bd$x,
conf_lev = .95
)
#> Error in eval(parse(text = x)): object 'bd' not found
bd %>%
summarise(tidydelta(~ y / x,
conf_lev = .95
))
#> Error in summarise(., tidydelta(~y/x, conf_lev = 0.95)): ℹ In argument: `tidydelta(~y/x, conf_lev = 0.95)`.
#> Caused by error in `where_env()`:
#> ! Object not found in envs.