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
0 answers

Error in t-test: not enough x-observations

I am having issues computing a t-test. First some background info: I am trying to compare the values of males and females, and in order to run the t-test I first had to create single-variables for only the male values and only the female values,…
1
vote
0 answers

statistical test to compare 1st/2nd differences based on output from ggpredict / ggeffect

I want to conduct a simple two sample t-test in R to compare marginal effects that are generated by ggpredict (or ggeffect). Both ggpredict and ggeffect provide nice outputs: (1) table (pred prob / std error / CIs) and (2) plot. However, it does…
1
vote
1 answer

Is there any way to control the output decimal places of the t-test function?

I'm using the built-in t-test function. Code below: t.test( mpg$cyl[mpg$model == "a4"], drill_df$Time_hr[mpg$model == "malibu"], alternative = "l", mu = 0, conf.level = 0.95, )
Bayman
  • 25
  • 4
1
vote
2 answers

Performing multiple two sample t-tests on two lists of data frames

I have two lists with four data frames each. The data frames in the first list ("loc_list_OBS") have only two columns "Year" and "Mean_Precip" while the data frames in the second list ("loc_list_future") have 33 columns "Year" and then mean…
1
vote
1 answer

What would be a more efficient way to create multiple Chisq/t-tests in R? (using Titanic data)

I have some very rudimentary code for generating a chisq test for some of the variables in the titanic dataset. I would like to have a way to differentiate categorical vs numeric/cont variables, so it would only do the chisq test on the categorical…
Adri
  • 121
  • 8
1
vote
0 answers

T Test 2 tail in python

My question is: How t-statistic and p value are calculated in formula stats.ttest_1samp() python ? There is a gap between formula results and my manual calculation which cause to opposite answers. example: A claim, coin isn't fair.…
1
vote
1 answer

What does the rt() function in R generates?

At first, I thought I understood what will the rt() function in R generate - I thought it generates random t-valuesfrom the specified t-distribution. For example, this function tdist <- rt(10000,19) generates, I interpreted, 10,000 t-values from a…
1
vote
1 answer

error in pass string as column name R t test

I am attempting to generalise some repeated measures ANOVA code for a string input of outcome variable and grouping variable as shown below: outcome_var<-"outcome_varnam1" grouping_var <- "grouping_varnam1" Therefore in dplyr i can call the…
A.TJE
  • 13
  • 4
1
vote
1 answer

T-test on the means pandas

I'm woking with the Movielens dataset and I would like to do the t-test on the mean ratings value of the male and female users. import pandas as pd from scipy.stats import ttest_ind users_table_names=…
Pepka
  • 93
  • 1
  • 9
1
vote
1 answer

T test using column variable from 2 different data frames in R

I am attempting to conduct a t test in R to try and determine whether there is a statistically significant difference in salary between US and foreign born workers in the Western US. I have 2 different data frames for the two groups based on…
juliah0494
  • 175
  • 11
1
vote
2 answers

How to combine lapply, t.test, leveneTest, if and else

I want to create a list of t-test results, where the appropriate corrections for unequal variances have been applied, if a levene-test indicated that they were necessary. Here are some example data. #create dataset set.seed(555) data<-…
Saja01
  • 55
  • 6
1
vote
1 answer

Get p-value with two variables and multiple row names

I wandered if you can help me in measuring the p-value from this simple data.frame. My data frame is called (my_data). By viewing it, you can see similar values I have that I am comparing: my_data <- read.csv("densityleftOK.csv", stringsAsFactors =…
Dave91
  • 15
  • 4
1
vote
3 answers

How to perform two-sample, one-tailed t-test in Python

I want to perform a two-sample, one-tailed t-test to compare two means. For the specific problem I am looking, I want the comparison to only be in one direction. I would like the null hypothesis to be that mu_2 > mu_1 and the alternative hypothesis…
Jane Sully
  • 3,137
  • 10
  • 48
  • 87
1
vote
0 answers

Easiest way to plot a T-distribution, mark critical region, and mark T-score in Python

What would be the easiest way to plot a T-distribution, shade the critical region, and perhaps draw a vertical line to mark the T-score in Python? The following will be used as variables: - Mean - Degrees of freedom - Stddev - alpha -…
1
vote
4 answers

How do I show individual points of a boxplot in R?

I have the df1: Name Y_N FIPS score1 score2 1: Alabama 0 1 2633 8 2: Alaska 0 2 382 1 3: Arizona 1 4 2695 41 4: Arkansas 1 5 …
Evan
  • 1,477
  • 1
  • 17
  • 34