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
2
votes
1 answer

R: T-statistics with subsets

I would like to have a table as ouptut where I have the t-statistics between the difference in means of certain variables and based on two specific subsets of my data. I have the following data: structure(list(Name = c("A", "A", "A", "A", "B", "B",…
remo
  • 365
  • 1
  • 10
2
votes
1 answer

R- How to conduct two-sample t-test with two different survey designs

I want to perform a two-sample (welch's) t-test on the equality of two means, one of which is obtained using simple random sampling (srsmean), and the other which is calculated using survey weighting with the survey package (mean_weighted). I also…
Nate
  • 61
  • 6
2
votes
2 answers

Writing a function for pairwise t-tests

I'm currently attempting to write a function in R that will allow me to calculate all possible pairwise t-tests in a data frame (I'm aware that functions exist that can achieve this, but I would also like to learn how to write the function…
2
votes
2 answers

One-sample T-test Over Multiple Columns with Multiple mu Values in R

I have several datasets, each for a particular time point, and each containing several measures. For each of them, I want to conduct a one-sample t-test on each measure, so across all the columns. Each measure has a different mu value that I want to…
muriosity
  • 23
  • 4
2
votes
1 answer

Testing difference between two means in r survey package

I have a problem when trying to test difference between two means in a survey with a t test. Basically I have a repeated health survey from different years and I want to test if the difference in means between them is meaningful. Using package…
Phate
  • 87
  • 5
2
votes
1 answer

How to loop through a pandas dataframe to run an independent ttest for each of the variables?

I have a dataset that consists of around 33 variables. The dataset contains patient information and the outcome of interest is binary in nature. Below is a snippet of the data. The dataset is stored as a pandas dataframe df.head() ID Age GAD …
ummendial
  • 83
  • 9
2
votes
1 answer

Error in R t_test , not enough "x" observations

I am trying to conduct group-wise t-test , but the code i am using returnign an error. It has worked alright for me previously and on other data frame but for this data frame its giving this error Error in t.test.default(x = 0.0268, y = 0.0223,…
Shah
  • 31
  • 5
2
votes
1 answer

stats.ttest_ind() vs. "manual" computation of Student's independent t-test: different results

I am comparing stats.ttest_ind() vs "manual" computation of the same test, and get different results. import numpy as np import pandas as pd import scipy.stats as stats import math stats.ttest_ind() method: #generate data np.random.seed(123) df =…
johnjohn
  • 716
  • 2
  • 9
  • 17
2
votes
1 answer

How to compute the confidence interval of the Difference in Differences method using Python?

I'm trying to analyze the total active minutes per user before and after an experiment. Here I've included the associated user data before and after the experiment - variant_number = 0 indicates control group while 1 means treatment group.…
2
votes
0 answers

Dask ttest between2 rows for all columns in dataframe

I wrote the following function to calculate statistical tests between two categories across all pandas columns in parallel - I was able to extract the categories using dask, but I need to compute and use pandas to get the ttest (or other statistical…
Jano
  • 21
  • 2
2
votes
2 answers

R: t.test in a facet_grid (ggplot)

This is a very specific question, but I already have and use this detailed and well working code, so I hope to find the minor change it takes to adjust it and make it work for the next level of complexity. What I…
user_20201212
  • 47
  • 1
  • 5
2
votes
0 answers

t-test as a randomisation test

Can I do a randomization test using a simple t-test? In particular, I have data and already checked the difference in group means of dependant variables by using t-test, but I also would like to check if control variables (e.g., age, gender, etc) in…
helplzz
  • 29
  • 1
2
votes
2 answers

How to run a multiple t-tests or ANOVA that controls for multiple variables in R?

I have df1: Rate Dogs MHI_2018 Points Level AGE65_MORE P_Elderly 1 0.10791173 0.00000000 59338 236.4064 C 8653 15.56267 2 0.06880040 0.00000000 57588 229.4343 C 44571 20.44335 3 …
Evan
  • 1,477
  • 1
  • 17
  • 34
2
votes
1 answer

Pairwise T-test: Error in complete.cases(x, y) : not all arguments have the same length?

I am trying to run a pairwise T-test: Dataundershootwithoutmeansminusstopdistance %>% (Undershootextent ~ Condition, paired = TRUE, p.adjust.method = "bonferroni") I am getting this result: Error in complete.cases(x, y) : not all arguments have…
Caledonian26
  • 727
  • 1
  • 10
  • 27
2
votes
2 answers

T-Test in Python for multiple group comparisons

I would like to conduct a simple t-test in python, but I would like to compare all possible groups to each other. Let's say I have the following data: import pandas as pd data = {'Category':…
user2635656
  • 127
  • 3
  • 8
1 2
3
32 33