tTest | R Documentation |
perform t tests with the possibility of inputting group statistics.
tTest(
x,
y = NULL,
sdx = NULL,
sdy = NULL,
nx = length(na.omit(x)),
ny = length(na.omit(y)),
alternative = c("two.sided", "greater", "less"),
mu = 0,
paired = FALSE,
rxy = NULL,
var.equal = FALSE,
conf.level = 0.95
)
x |
a numeric vector. Can be of length 1 for a group mean. |
y |
a numeric vector. Should be |
sdx |
standard deviation for |
sdy |
standard deviation for |
nx |
sample size for |
ny |
sample size for |
alternative |
a character string specifying the alternative hypothesis,
must be one of " |
mu |
a number indicating the true value of the mean (or difference in means) if you are performing an independent samples t-test). |
paired |
a logical indicating whether you want a paired t-test. |
rxy |
correlation between two paired samples. |
var.equal |
a logical variable indicating whether to treat the two variances as being equal. If
|
conf.level |
level of the confidence interval. |
tTest
performs a t-test (independent samples, paired samples, one sample) just like base-R t.test, but with the extended possibility to enter group statistics instead of raw data.
Mathijs Deen
library(MASS)
set.seed(1)
ds <- mvrnorm(n=50, mu = c(50,55),
Sigma = matrix(c(100,0,0,81),
ncol = 2),
empirical = TRUE) |>
data.frame() |>
setNames(c("x1","x2"))
t.test(ds$x1, ds$x2)
tTest(x = ds$x1,
y = 55,
sdy = 9,
ny = 50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.