Questions tagged [t-test]

Related to statistical hypothesis testing. Most software packages used for statistical analysis (including R) provide functions for performing the t-test. Use this tag for questions related to the t-test.

The t-test is also known as the "Student's t-test" after the pseudonym of its inventor. It is used for comparing the means of two samples, or the mean of one sample (or even parameter estimates) with a specified value. See the Wikipedia article for more details. Refer to the R documentation for details on the t.test function arguments and return values.

494 questions
1
vote
1 answer

How to compare the amount of cases in two same-sized groups?

This is most likely a very simple question but I'll ask it nevertheless since I haven't found an answer. How can I compare the amount of "cases" (for example flu) in two groups i.e. find out if the difference between the amounts of cases in the…
Pinus
  • 17
  • 4
1
vote
1 answer

Why does Excel t-test return #DIV/0! error?

I'm testing the t.test functionality of Excel and when I specify two-sided, paired with two lists of 1,2,3,4,5,6,7 and 2,3,4,5,6,7,8, paired t-test, the p-value returns #DIV/0! I have made sure the cell is formatted as number. As soon as I change…
Stack_Protégé
  • 302
  • 1
  • 15
1
vote
2 answers

2-sample independent t-test where each of two columns is in different data frame

I need to run a 2-sample independent t-test, comparing Column1 to Column2. But Column1 is in DataframeA, and Column2 is in DataframeB. How should I do this? Just in case relevant (feel free to ignore): I am a true beginner. My experience with R so…
rrrookie
  • 11
  • 1
1
vote
2 answers

Is there a neater way to carry out several one-sample T-tests in R

I'm trying to see if the class 'means' of four separate groups (pKa recorded at pH 6.1, 6.7, 7.3 and 8.1) are significantly different to the individual data points I obtained for each group (pKa recorded at pH 6.1, 6.7, 7.3 and 8.1) Here is a sample…
1
vote
1 answer

Is there an R function to extract a single group mean?

I know tapply can be used to separate groups and calculate means individually. I was wondering if there is a function to isolate one of these means for separate analysis. I am comparing my collected data to the class means using a One sample t-test.…
1
vote
1 answer

Replacing loop to do T-test in R

I have a dataframe with the following structure: set.seed(1) dat<- data.frame(gender=sample(rep(c("Man","Woman"),3000)), age=sample(rep(c("Young","Old"),3000)), question=rep(c("Q1", "Q2", "Q3"),2000), …
cholo.trem
  • 314
  • 2
  • 9
1
vote
2 answers

T-test with column number instead of column name

I am trying to perform a series of T-tests using RStatix's t_test(), where the dependent variable is the same in every test and the grouping variable changes. I am doing these tests inside a loop, so I would like to select the grouping variable with…
cholo.trem
  • 314
  • 2
  • 9
1
vote
1 answer

T-test() does not add adjusted p-values

I have a survey that was conducted in 3 different classes (math, phys, bio) at the beginning and at the end of the semester (pre and post). In the survey, there were 3 groups of questions (A, B, C) and a Likert-type scale. I converted all the…
yuliaUU
  • 1,581
  • 2
  • 12
  • 33
1
vote
1 answer

stat_compare_means paired = TRUE seem to pair the wrong values

I want to plot a boxplot figure using ggpaired from ggpubr to compare the two conditions of the following dataframe. So you can see that the csv consists of 3 data pairs (-FLS, UT) coming from 3 experiments (E2020-36, E2021-04, E2021-06).…
MaxRH
  • 11
  • 2
1
vote
0 answers

In a facet_grid call how can I remove one aesthetic from the margin = T (all the values of the other panels together?)

So, I am calculating a statistic between two values, one random and the other one "real" scores. As it is sort of paired, I plot the distributions of the differences for different conditions and states with facet_grid but I am also interested in the…
Garini
  • 1,088
  • 16
  • 29
1
vote
2 answers

What does R assume regarding order in paired t-test?

In the non-formula signature of the t.test function t.test(x, y, paired=T), I'm assuming that the data are assumed paired as ordered in the two inputs (x and y in the documentation). However, in the formula signature t.test(values ~ groups, df,…
abalter
  • 9,663
  • 17
  • 90
  • 145
1
vote
2 answers

Apply function taking matching columns in 2 data frames, looping over columns

I have the following two data frames df1 <- as.data.frame(matrix(runif(50), nrow = 10, byrow = TRUE)) colnames(df1) <- c("x1", "x2", "x3", "x4", "x5") df2 <- as.data.frame(matrix(runif(100), nrow = 20, byrow = TRUE)) colnames(df2) <- c("x1", "x2",…
wy6622
  • 13
  • 3
1
vote
1 answer

Compute t-test in R via reading csv data and visualize it in Boxplot

I am trying to import some data from a csv file and visualize it in a Boxplot to display it again online using a plateform. I am using R as developing language for computing a t-test function then displaying the results in plot. I am getting this…
Anouar
  • 191
  • 4
  • 14
1
vote
1 answer

Two sample t-test in multiple groups with multiple variables / metrics using tidyverse and broom package

Using the following data df <- data.frame(category = sample(1:3, replace = TRUE, 50), testgroup = sample(c('A', 'B'), replace = TRUE, 50), var_1 = rnorm(50), var_2 = rnorm(50), var_3 =…
Rami Al-Fahham
  • 617
  • 1
  • 6
  • 10
1
vote
1 answer

How to perform multiple t.tests with R package srvyr?

As a follow up on a recent SO question (see here) I am wondering how to perform multiple t.tests in R with weighted data (package srvyr). I cant make it run and would be happy if anyone could help me here. I added a random sample in the code…
Boombardeiro
  • 105
  • 8