mean_test2: Two sided or one sided test of hypothesis of mu1 and mu2 of two normal samples
Description
Compute the two sided or one sided test of hypothesis of mu1 and mu2 of two normal samples when the population variances are known, unknown equal, or unknown unequal.
Usage
mean_test2(x, y, sigma = c(-1, -1), var.equal = FALSE, side = 0)
Value
A data.frame with variables:
mean
The difference of sample means xb-yb.
df
The degree of freedom.
statistic
The statistic, when all(sigma>=0), statistic = Z; otherwise, statistic = T.
p_value
The P value.
Arguments
x
A numeric vector.
y
A numeric vector.
sigma
A numeric vector of length 2, which contains the standard deviations of two populations. When the standard deviations are known, input it, then the function computes the interval endpoints using normal population; when the standard deviations are unknown, ignore it, now we need to consider whether the two populations have equal variances. See var.equal below.
var.equal
A logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.
side
A parameter used to control two sided or one sided test of hypothesis. When inputting side = 0 (default), the function computes two sided test of hypothesis, and H1: mu1 != mu2; when inputting side = -1 (or a number < 0), the function computes one sided test of hypothesis, and H1: mu1 < mu2; when inputting side = 1 (or a number > 0), the function computes one sided test of hypothesis, and H1: mu1 > mu2.
x=rnorm(10, mean = 1, sd = 0.2); x
y=rnorm(20, mean = 2, sd = 0.3); y
mean_test2(x, y, sigma = c(0.2, 0.3), side = 1)
mean_test2(x, y, var.equal = TRUE, side = 1)
mean_test2(x, y, side = 1)