This function is primarily designed for speed in simulation. Missing values
are silently excluded.
The one-sample test is used for both the true one-sample scenario and for the
paired differences from a dependent two-sample scenario. Below we use paired
difference language as that is the most common case. The hypotheses for the
paired t-test are
$$
\begin{aligned}
H_{null} &: \mu_{diff} = \mu_{null} \\
H_{alt} &: \begin{cases}
\mu_{diff} \neq \mu_{null} & \text{two-sided}\\
\mu_{diff} > \mu_{null} & \text{greater than}\\
\mu_{diff} < \mu_{null} & \text{less than}
\end{cases}
\end{aligned}
$$
where \(\mu_{diff} = AM(X_2 - X_1)\) is the arithmetic mean of the paired
differences (sample 2 - sample 1) and \(\mu_{null}\) is a constant for the
assumed population mean difference (usually \(\mu_{null} = 0\)).
The test statistic is
$$
T = \frac{\bar{x}_{diff} - \mu_{null}}{\sqrt{\frac{s^2}{n}}}
$$
where \(\bar{x}_{diff}\) is the sample mean of the differences, \(\mu_{null}\)
is the population mean difference assumed under the null hypothesis, \(n\)
is the sample size of the differences, and \(s^2\) is the sample variance.
The critical value of the test statistic has degrees of freedom
$$
df = n-1
$$
and the p-value is calculated as
$$
\begin{aligned}
p &= \begin{cases}
2 \text{min} \{P(T \geq t_{n-1} \mid H_{null}), P(T \leq t_{n-1} \mid H_{null})\} & \text{two-sided}\\
P(T \geq t_{n-1} \mid H_{null}) & \text{greater than}\\
P(T \leq t_{n-1} \mid H_{null}) & \text{less than}
\end{cases}
\end{aligned}
$$
Let \(GM(\cdot)\) be the geometric mean and \(AM(\cdot)\) be the
arithmetic mean. For dependent lognormal samples \(X_1\) and \(X_2\) it
follows that \(\ln X_1\) and \(\ln X_2\) are dependent normally
distributed variables. Setting \(\mu_{diff} = AM(\ln X_2 - \ln X_1)\)
we have
$$
e^{\mu_{diff}} = GM\left( \frac{X_2}{X_1} \right)
$$
This forms the basis for making inference about the geometric mean ratio of
the original lognormal data using the mean difference of the log transformed
normal data.