One-sample t-test

Compare the mean of a quantitative variable in one sample with a fixed reference value – the scale midpoint, a known population mean, a norm, a "no preference" value. The output: sample statistics, the test table as in SPSS (t, df, p, the difference from the test value and a confidence interval), Cohen's d and r², a chart of the mean against the test value, and a report sentence in English.

Calculator

Loading the data

Drag an Excel file or an SPSS file (.sav) here, or click to choose
In the site's standard template: row = participant, column = variable, first row = headers. CSV is also accepted.
Any numeric column can be tested; if you computed a scale score on the Cronbach's alpha page – upload here the file you downloaded from there, and test the score against the scale midpoint.
Just want to try it out? Download a sample data file (120 participants: age, attitude scale score 1-5 and more, with a legend): English example
or

Paste columns directly from the sheet (including the header row) – select them in Excel, copy, and paste here:

A
B
C
D
E
F
You can also just paste – the data will be loaded and displayed automatically.

Variables and test value

Guide

When to use?

When there is one sample, one mean, and one question: does this mean differ from a particular value. Gravetter and Wallnau (2017, chapter 9) present two situations. The first – a known population before treatment: the population mean before treatment is known (e.g., 30), a sample received treatment, and the question is whether the mean after treatment is still 30 (pp. 274-275, Figure 9.3). The second, and more common in the social sciences – a value derived from logic, without any prior knowledge of the population: rating questions on a 1-7 scale, where 4 is "neutral", and the research question is whether the respondents have any attitude at all – H0: μ = 4 (pp. 275-276; the humor study of McGee and Shevlin, 2009, at the opening of the chapter: a description with a sense of humor received M = 4.53, significantly higher than 4); or infants who looked at two faces for 20 seconds – if there is no preference, the mean for the attractive face is 10 seconds, H0: μ = 10 (Example 9.2). "All that is needed to compute t is a null hypothesis and a sample from the unknown population" (p. 275).

This test is the foundation of the t family: the two other tests on the site – for independent samples (two separate groups) and for paired samples (the same participants twice) – compare two means with each other; here one mean is compared with a constant. A multi-item scale score (the page Cronbach's alpha and scale score) is treated as an interval variable per the site convention (Variables and levels of measurement), so it can be tested against the scale midpoint; a single Likert item – not (frequencies and median, on the frequencies page).

The logic: the difference divided by the standard error

The idea of Gravetter and Wallnau (2017, section 9.1): a sample mean approximates the population mean, and the standard error tells how large a difference between them is reasonable to expect. In a z-score, the difference M − μ is divided by the true standard error, which requires the population standard deviation – which is almost never known; "the whole reason for the test is to learn about an unknown population" (p. 269). The solution: estimate the standard error from the sample, sM = s/√n (Formula 9.1), and get t – the same structure as z, with an estimate in the denominator: t = (M − μ)/sM (Formula 9.2). The numerator measures the actual difference between the data and the hypothesis; the denominator – how large a difference is reasonable to expect by chance; when the numerator is much larger than the denominator, t is large (positive or negative) and the data are not consistent with the hypothesis (p. 275).

Because the denominator is also estimated and varies from sample to sample, t varies more than z: the t distribution is flatter and more spread out than the normal, especially when the degrees of freedom – df = n − 1 (Formula 9.3) – are small, and approaches it as n increases (section 9.1, Figure 9.1): at df = 1 the two-tailed critical value for .05 is 12.706, at df = 8 – 2.306, and at infinity – 1.96 (Table 9.1). The page does not use the table: it computes the exact p from the t distribution, as a "computer printout" does (p. 287), and reports it as a number and not as p < .05.

How to read the output?

Table 1 – sample statistics. The N of valid values, the mean, the standard deviation (sample, n − 1) and the standard error of the mean. This is the SPSS One-Sample Statistics table. First check that N makes sense – many missing values or a text value in the column reduce it, and the page reports this on loading.

Table 2 – the test. The SPSS One-Sample Test table: the test value, t, df, two-tailed p, the difference M − μ0 (Mean Difference) and the 95% confidence interval for the difference. The sign of t and of the difference tells in which direction the sample deviates from the test value: positive – the mean is higher than it. p smaller than .05 – the mean differs significantly from the test value; otherwise – no significant difference was found (Gravetter & Wallnau, 2017, p. 277: "the statistical decision"). The confidence interval. The table prints the interval for the difference, as SPSS does; the table note and the chart show the same interval for the mean – μ = M ± t·sM (Formula 9.6; Example 9.5) – which is simply the interval for the difference plus the test value. When the interval for the difference includes zero (that is, the interval for the mean includes the test value), the test is not significant, and vice versa. The interval is narrower the larger the sample and the lower the confidence level (p. 286); and therefore, Gravetter and Wallnau warn, it is a description of the effect but not a substitute for d or r² (p. 286).

Effect size

"A very small treatment effect can be 'statistically significant', especially when the sample is very large", so a measure of effect size is reported alongside the test (Gravetter & Wallnau, 2017, p. 279). There are two in the output, and both are almost independent of sample size (p. 284):

Cohen's d (estimated). The difference between the sample mean and the test value in units of the sample standard deviation: d = (M − μ)/s (Formula 9.4). In the infants example: (13 − 10)/3 = 1.00 – the effect equals one standard deviation (Example 9.3, Figure 9.5). Gravetter and Wallnau note that when sample values are substituted for parameters, many researchers prefer to call it "estimated d" (p. 280); this is also the Cohen's d in the SPSS 27 and later output for one sample. Cohen's conventions (1988, pp. 25-27): 0.2 small, 0.5 medium, 0.8 large – with his warning that the thresholds are for orientation, and the effect is judged in the context of the field.

r² – percentage of variance explained. How much of the variance in the scores is "explained" by the shift from the test value: in the example, the variance around 10 is SS = 153, and after removing the effect (3 points from each score) – 72; the difference, 81 out of 153, is 52.94% (Table 9.2). The formula from the test itself: r² = t²/(t² + df) (Formula 9.5) – in the context of t this is sometimes also called ω². Cohen's thresholds for r² (Table 9.3): .01 small, .09 medium, .25 large – note that these are the r thresholds squared (.1/.3/.5), and they are different from the thresholds the independent-samples t-test page gives for η² from Pallant (.01/.06/.14); this page follows its own source, Gravetter and Wallnau. A large standard deviation reduces both t and both effect measures; sample size reduces only p (pp. 278, 284).

Assumptions and warnings

The two assumptions (Gravetter & Wallnau, 2017, pp. 277-278): the observations are independent of each other – one event does not affect the probability of another (a participant measured twice, pairs, classes – violate this); and the population is normally distributed – an assumption needed for the mathematics, but "violating it has little practical effect, especially when the sample is relatively large"; in a very small sample it is important, and "if there is reason to suspect that the distribution is not normal – use a large sample, to be safe". Field (2024) explains why: what is required is a normal sampling distribution of the mean, and the central limit theorem guarantees it when the sample is large enough (sections 6.2.7 and 6.8.3) – the accepted value is 30, but in a distribution with heavy tails 100 or even more may be needed (Box 6.4); in a small sample look at the histogram (Frequencies and descriptive statistics) and at outliers (Outliers and assumptions), and in a large sample do not decide by a normality test (Box 6.7). The "Interpreting the result" box mentions this when n is smaller than 30.

The test value is a decision, not a finding. It is set before the analysis from logic or external knowledge – the scale midpoint, a published mean, a norm – and reported with its rationale. Choosing it after seeing the mean, or trying several values until something comes out significant, destroys the meaning of p (see Research ethics, section 7).

One-tailed test. Gravetter and Wallnau (section 9.4) show how to run a directional test – the critical value is taken from one tail, and "one-tailed" is reported explicitly – and note that the two-tailed test is more common, and the directional one is appropriate when there is prior justification. The page computes a two-tailed p only; whoever plans a one-tailed test in advance, with the difference in the predicted direction, divides p by two – and reports this.

Missing values. For each tested variable, the participants with a valid value on it are included – analysis-by-analysis deletion (/MISSING=ANALYSIS), the SPSS default; N can change from one variable to another. Multiple tests. Several variables in one click are several tests, each with a 5% risk of a Type I error; report all of them, and consider a correction (the correlations page: Holm / FDR).

What the page does not compute. A confidence interval for d (SPSS 27 and later prints it), bootstrap, a one-tailed test as output, the one-sample sign test and Wilcoxon test (the nonparametric alternatives), and the Bayes factor.

And how do you do it in SPSS?

The sources the site relies on (Field, 2024; Pallant, 2020) do not describe this procedure – they go straight to tests for two groups – so the description here is the site's, validated against PSPP (a free implementation of SPSS): Analyze › Compare Means › One-Sample T Test… – the variable (or several) into the Test Variable(s) box, the test value in the Test Value field (the default is 0 – almost never what you want); Options… – the confidence interval level and the handling of missing values; in version 27 and later – the Estimate effect sizes box. The syntax the page generates:

T-TEST
  /TESTVAL=3
  /MISSING=ANALYSIS
  /VARIABLES=attitude_score
  /ES DISPLAY(TRUE)
  /CRITERIA=CI(.95).

Reading the output. One-Sample Statistics = Table 1 (N, Mean, Std. Deviation, Std. Error Mean); One-Sample Test = Table 2 – in the heading Test Value = 3, and then t, df, Sig. (2-tailed) (in 27 and later also One-Sided p – ignore it), Mean Difference and 95% Confidence Interval of the Difference – an interval for the difference, not for the mean; One-Sample Effect Sizes – the Cohen's d row, Point Estimate (SPSS also prints Hedges' correction, which is not on the page). One test value for all the variables in the command; when different values were chosen on the page for different variables, the syntax contains a T-TEST command for each value.

And how do you do it in R?

In base R, t.test(x, mu = …) gives t, df, p and a confidence interval for the mean (and not for the difference as in SPSS – subtract μ0 to compare); d and r² are computed by hand. The script was run as is on the sample data file and gave the table values (in the comments). The site rule for R: a UTF-8 file, every comment line starts with an English word, and a UTF-8 locale for Hebrew names.

# One-sample t-test – Professor Stat. This file is saved in UTF-8; every comment line starts with an English word
library(readxl)   # reading Excel

# Loading: the standard template – row = participant, column = variable; the sheet "data"
d <- read_excel("C:/Rdata/DATA_ttest1_example_eng.xlsx", sheet = "data")
y <- d[["attitude_score"]]; y <- y[!is.na(y)]

# Sample statistics – Table 1
c(n = length(y), M = mean(y), SD = sd(y), SE = sd(y) / sqrt(length(y)))   # n 120, M 3.270, SD 0.745, SE 0.068

# The test against the test value 3 (midpoint of a 1-5 scale) – Table 2; the R confidence interval is for the mean
tt <- t.test(y, mu = 3)
tt                                   # t = 3.96, df = 119, p = .00013, confidence interval for the mean [3.135, 3.404]
tt$conf.int - 3                      # Confidence interval for the difference, as in SPSS: [0.135, 0.404]

# Effect size: Cohen's d = (M − μ)/s, and r² = t²/(t² + df)
(mean(y) - 3) / sd(y)                                                     # d = 0.362
unname(tt$statistic^2 / (tt$statistic^2 + tt$parameter))                # r² = .117

Reporting the results

Report the description and then the test: the mean and standard deviation, the test value and what it represents, t with the degrees of freedom in parentheses, an exact p, the effect size – and the confidence interval right after the test (Gravetter & Wallnau, 2017, p. 287; American Psychological Association [APA], 2020, Section 6.43). The example of Gravetter and Wallnau: "The infants looked at the attractive face M = 13 out of 20 seconds on average, SD = 3.00. The time was significantly higher than expected in the absence of a preference, t(8) = 3.00, p = .017, r² = 0.5294", and with a confidence interval: t(8) = 3.00, p < .05, 80% CI [11.603, 14.397]. When the exact p is available – report it (p = .017, not p < .05); and "p = 0.000" in a printout is not zero but rounding – write p < .001 (p. 287). For a one-tailed test, write "one-tailed" explicitly (p. 289).

Formatting rules (APA, 2020, Section 6.36): t and the difference with a zero before the decimal point; p and r² without (they cannot exceed 1); d with a zero. The report sentences in the output are built this way, in English, with the 95% confidence interval for the mean.

Common mistakes

Leaving the test value at 0. The SPSS default tests whether the mean differs from zero – almost always "significant" and almost always meaningless. The test value is the hypothesis (Gravetter & Wallnau, 2017, pp. 275-276).

Choosing the test value after seeing the mean. The hypothesis comes before the data; otherwise p says nothing.

Reading the SPSS confidence interval as an interval for the mean. It is an interval for the difference from the test value; for the mean – add the test value (or read the table note on the page).

Interpreting "not significant" as "the mean equals the test value". A confidence interval that includes the test value says that the true difference may be negative, zero or positive – not that it is zero. Report d and the interval.

A one-sample test on a single Likert item. Per the site convention, a single item is an ordinal variable – frequencies and median; the mean of a multi-item scale score – yes.

Confusing the r² and η² yardsticks. .09 is a medium r² in Gravetter and Wallnau (Table 9.3); .06 is a medium η² in Pallant – two yardsticks, the same idea, different numbers.

Dividing p by two after seeing the direction. A one-tailed test is planned in advance, justified, and reported as such (Gravetter & Wallnau, 2017, Section 9.4).

References

American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). https://doi.org/10.1037/0000165-000

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.

Field, A. (2024). Discovering statistics using IBM SPSS statistics (6th ed.). SAGE.

Gravetter, F. J., & Wallnau, L. B. (2017). Statistics for the behavioral sciences (10th ed.). Cengage Learning.

McGee and Shevlin (2009) and Slater and colleagues (1998) – as cited in Gravetter and Wallnau (2017). Per the site rule, the reference list includes only sources read in the original; Gravetter and Wallnau (2017), Cohen (1988) and APA (2020) – by page and section of the printed edition; Field (2024) in a reflowable digital copy – by section. The SPSS procedure – the site's description, validated against PSPP (not quoted from a source).