Applies the Delta method to the ratio of two random variables, \(f(X,Y)=X/Y\), to estimate the expected value, variance, standard error, and confidence interval.
References
id:sz_dr (2018). Calculating the mean and variance of the ratio of random variables using the Delta method [in Japanese]. If you are human, think more now. https://www.szdrblog.info/entry/2018/11/18/154952
Methods
Method new()
Initialize a new DeltaMethodForRatio object.
Usage
DeltaMethodForRatio$new(numerator, denominator, bias_correction = FALSE)
Arguments
numerator, denominator
numeric vectors sampled from the distributions of the random variables in the numerator and denominator of the ratio.
bias_correction
logical value indicating whether correction to the mean of the metric is performed using the second-order term of the Taylor expansion. The default is
FALSE
.
Method get_confidence_interval()
Get the confidence interval.
Usage
DeltaMethodForRatio$get_confidence_interval(
alternative = c("two.sided", "less", "greater"),
conf_level = 0.95
)
Method get_info()
Get statistical information.
Usage
DeltaMethodForRatio$get_info(
alternative = c("two.sided", "less", "greater"),
conf_level = 0.95
)
Method compute_expected_value()
Class method to compute the expected value of the ratio using the Delta method.
Usage
DeltaMethodForRatio$compute_expected_value(
mean1,
mean2,
var2,
cov = 0,
bias_correction = FALSE
)
Arguments
mean1
numeric value of the mean numerator of the ratio.
mean2
numeric value of the mean denominator of the ratio.
var2
numeric value of the variance of the denominator of the ratio.
cov
numeric value of the covariance between the numerator and denominator of the ratio. The default is 0.
bias_correction
logical value indicating whether correction to the mean of the metric is performed using the second-order term of the Taylor expansion. The default is
FALSE
.
Method compute_variance()
Class method to compute the variance of the ratio using the Delta method.
Arguments
mean1
numeric value of the mean numerator of the ratio.
mean2
numeric value of the mean denominator of the ratio.
var1
numeric value of the variance of the numerator of the ratio.
var2
numeric value of the variance of the denominator of the ratio.
cov
numeric value of the covariance between the numerator and denominator of the ratio. The default is 0.
Method compute_confidence_interval()
Class method to compute the confidence interval of the ratio using the Delta method.
Usage
DeltaMethodForRatio$compute_confidence_interval(
mean,
standard_error,
alternative = c("two.sided", "less", "greater"),
conf_level = 0.95
)
Arguments
mean
numeric value of the estimated mean of the ratio.
standard_error
numeric value of the estimated standard error of the mean of the ratio.
alternative
character string specifying the alternative hypothesis, must be one of
"two.sided"
(default),"greater"
, or"less"
. You can specify just the initial letter.conf_level
numeric value specifying the confidence level of the interval. The default is 0.95.