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
10
votes
2 answers

Perform multiple paired t-tests based on groups/categories

I am stuck at performing t.tests for multiple categories in Rstudio. I want to have the results of the t.test of each product type, comparing the online and offline prices. I have over 800 product types so that's why don't want to do it manually for…
User100009
  • 103
  • 1
  • 1
  • 5
9
votes
1 answer

Why are there wrong and/or inconsistent degrees of freedom from R's t-test function?

I have a simple question. I've seen this behaviour in R for both t-tests and correlations. I do a simple paired t-test (in this case, two vectors of length 100). So the df of the paired t-test should be 99. However this is not what appears in the…
elisa
  • 965
  • 9
  • 27
7
votes
2 answers

How to interpret the upper/lower bound of a datapoint with confidence intervals?

Given a list of values: >>> from scipy import stats >>> import numpy as np >>> x = list(range(100)) Using student t-test, I can find the confidence interval of the distribution at the mean with an alpha of 0.1 (i.e. at 90% confidence) with: def…
alvas
  • 115,346
  • 109
  • 446
  • 738
5
votes
2 answers

R t.test group by

I have stumbled across a bit of an annoying problem. I am trying to perform multiple independent sample t-tests at once, grouped by a value. To put it into an example: In 5 cities we have measured job satisfaction between males and females. For…
koolmees
  • 2,725
  • 9
  • 23
5
votes
1 answer

Different results with weighted t test between R and Python

I'm running a weighted t test in Python and am seeing different results. It appears that the issue is the degree of freedom calculation. Would like to understand why I'm seeing different outputs. Here is some sample code. In R: library(weights) x…
matsuo_basho
  • 2,833
  • 8
  • 26
  • 47
5
votes
1 answer

How to calculate (statistical) power function vs. sample size in python?

How can this be done in python? Calculate sample size for a given power and alpha? Calculate power for a given sample size and alpha? Note: I am totally confused :( with the functions that python gives for (statistical) power function…
Samer Aamar
  • 1,298
  • 1
  • 15
  • 23
5
votes
1 answer

How to perform Welch's t-test on slopes from two regressions with R?

I run regressions over two groups with the same independent variables. Then, I would like to test whether the slopes from the two regressions are significantly different. I have read that when the sample size and the variance are not equal between…
David Marguerit
  • 197
  • 2
  • 14
4
votes
1 answer

Group by and run multiple t tests in R

I have the following dataset (dput here): # A tibble: 3,713 x 17 ID Age Group RHR HRV Sleep.Onset Wake.Onset Hours.in.Bed Hours.of.Sleep Sleep.Disturbances Latency.min Cycles REM.Sleep.hours Deep.Sleep.hours
CanyonView
  • 401
  • 3
  • 15
4
votes
2 answers

R: t tests on rows of 2 dataframes

I have two dataframes and I would like to do independent 2-group t-tests on the rows (i.e. t.test(y1, y2) where y1 is a row in dataframe1 and y2 is matching row in dataframe2) whats best way of accomplishing this? EDIT: I just found the format:…
bdeonovic
  • 4,130
  • 7
  • 40
  • 70
3
votes
0 answers

R Bayesian difference in means test using BEST and brms packages

The R packages "BEST" and "brms" can both calculate a Bayesian difference in means test. I'm trying to compare the results from both packages. My questions are: (1) what do the link functions do in the brms package? Do they preprocess the data…
user1491868
  • 596
  • 4
  • 15
  • 42
3
votes
1 answer

Apply t test over all columns of data frame seperated by variable

I have data frame like this X1 X2 X3 X4 X5 class 1 1 7 3 9 5 n 2 2 8 4 10 6 n 3 3 9 5 1 7 n 4 4 10 6 2 8 p 5 5 1 7 3 9 p 6 6 2 8 4 10 p I like to run t test over all columns, separated on groups…
3
votes
1 answer

Perform t-tests by groups

I am trying to do t test comparing control and treatment groups in a long table. Part of table looks like this, the ones with T are the one with treatment while the ones without T are the controls and each group has…
Meifong
  • 69
  • 7
3
votes
1 answer

How to perform two-sample unequal sized t-test for two np.array in python?

I have two numpy arrays with different sizes that I would like to run a t-test on directly in python to see the p-value.
Stack_Protégé
  • 302
  • 1
  • 15
3
votes
1 answer

How to add effect sizes to ggplot bar graphs of t-tests? (e.g., Cohen's d or Hedges' g)

I have a dataset like the following. Group <- c("A", "B", "A", "A", "A", "B", "A", "A", "B", "B","A", "A", "B", "B") Score <- c(26, 22, 15, 5, 19, 3, 4, 5, 23, 3, 5, 2, 20, 4) Order <- c("First", "First", "First", "Second", "First", "Second",…
Nick Byrd
  • 163
  • 1
  • 14
3
votes
2 answers

Two sample t-test for every individual row in Python

I am trying to do a two sample t test to check if there is significant difference in mean between two datasets. I have two datasets and each dataset has 5 trials and each Trial has 3 features. Every Trial has different unique label but the 3…
anaz8
  • 105
  • 2
  • 15
1
2 3
32 33