Title: | Estimation of Standard Errors using Delta Method |
Version: | 0.1.0 |
Description: | Delta Method implementation to estimate standard errors with known asymptotic properties within the 'tidyverse' workflow. The Delta Method is a statistical tool that approximates an estimator’s behaviour using a Taylor Expansion. For a comprehensive explanation, please refer to Chapter 3 of van der Vaart (1998, ISBN: 9780511802256). |
License: | MIT + file LICENSE |
Imports: | dplyr, numDeriv, purrr, rlang, tibble, cli |
Suggests: | testthat (≥ 3.0.0), tidyverse |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Config/testthat/edition: | 3 |
URL: | https://github.com/JavierMtzRdz/tidydelta |
BugReports: | https://github.com/JavierMtzRdz/tidydelta/issues |
NeedsCompilation: | no |
Packaged: | 2024-07-16 13:58:31 UTC; javiermtz |
Author: | Javier Martinez-Rodriguez [aut, cre, cph] |
Maintainer: | Javier Martinez-Rodriguez <javier.matz.rdz@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-07-18 23:20:02 UTC |
Extract variables and their names from the formula
Description
Extract variables and their names from the formula
Usage
cases_ext(formula, mean_dta = NULL, cov_dta = NULL)
Arguments
formula |
A formula object specifying the variables of interest. |
mean_dta |
Vector containing the means of the variables. |
cov_dta |
Covariance matrix of the variables. |
Value
list containing objects with variables and formula
Extract variables from a formula
Description
Extracts variables from a formula string.
Usage
ext_bd_var(formula)
Arguments
formula |
A formula object or a character string representing a formula. |
Value
A named character vector of extracted variables.
Convert a formula to an expression
Description
Converts a formula to an expression for further evaluation.
Usage
for_to_exp(formula)
Arguments
formula |
A formula object or a character string representing a formula. |
Value
The evaluated expression.
Delta Method implementation
Description
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. |
Value
A tibble with columns for means, standard errors, and optionally, confidence intervals.
Examples
# Equivalent ways to use tidydelta()
library(tidyverse)
x <- rnorm(1000, mean = 5, sd = 2)
y <- rnorm(1000, mean = 15, sd = 3)
bd <- tibble(x, y)
tidydelta(~ y / x,
conf_lev = .95
)
tidydelta(~ bd$y / bd$x,
conf_lev = .95
)
bd %>%
summarise(tidydelta(~ y / x,
conf_lev = .95
))
Recursive search of environment
Description
Recursive search of environment containing object.
Usage
where_env(name, env = rlang::caller_env())
Arguments
name |
Object searched |
env |
Initial environment to search |
Value
A named character vector of extracted variables.