# One Sample T-Test - Data Transformation

I apologize in advance is this question seems very elementary. It has been a long time since I have dabbled in significance tests and I can't seem to find an answer to this anywhere else.

I have a dataset (n=52) of samples that I would like to test against a known value (e.g., 5). Because, I am testing my population mean against a known mean, this would be a one-sample t-test. Please correct me if I'm wrong. My data is positively skewed (majority of samples are low, with some high outliers) and I understand that a normal distribution is necessary to support the use of a parametric test.

I suppose I have two questions:

1. When I log transform my data, the histogram, Q-Q plot, kurtosis, skew, etc. all strongly suggest the data is normal enough for a t-test. From here, do I also log transform the known mean I am testing against (e.g., log10(5))?
2. Is something like this typically done for a one-sample t-test or should I try a non-parametric test?
• If I'm not mistaken the estimator of a funtion of the parameter (log in this case) is the function of the estimator not the function of the data. If T is an estimator of mu, f(T) is an estimator of f(mu). So, the log of the data do not estimate the log of the mean.
– Luke
Commented Dec 7, 2021 at 8:03
• @BruceET Part 2 is not a yes or no question! (or, rather is the conjunction of two yes or no questions :). Does "no" apply to the part about "typically done for one-sample t tests" or to the part about "try a non-parametric test"? Commented Dec 7, 2021 at 18:29
• @Alexis. The main difficulty (as the question now stands) is with the null value $\log_{10}5.$ But (depending on the meaning of "something like this"), I object to Part 2 altogether. The natural log of a lognormal will be normal and a correctly formulated t test would be fine. Commented Dec 7, 2021 at 20:31

Preliminaries. You might want to start by reviewing the standard definition of the lognormal distribution and fundamental facts about its mean and variance, either in a textbook or on the relevant Wikipedia page.

Three points are of particular importance for your question.

(1) If you take the natural log $$(\log_e=\ln,$$ not $$\log_{10})$$ of lognormal data, then you get data from the corresponding normal distribution.

(2) If the mean and SD of the normal population are $$\mu$$ and $$\sigma,$$ respectively, then the mean of the lognormal population will be $$\exp(\mu+\sigma^2/2).$$

(3) Because the relationship between the mean and variance of normal and corresponding lognormal distributions is not trivial, it is customary (but sometimes possibly confusing) to use the normal parameters for the corresponding lognormal distribution.

Demo with huge lognormal sample in R for $$\mu=5, \sigma=1,$$ for which sample mean nearly matches population mean:

set.seed(1234)
mean(rlnorm(10^7, 5, 1))
[1] 244.775
exp(5 + .5)
[1] 244.6919


Fictitious data for illustration. Consider fictitious normal data y and corresponding lognormal data x as follows:

set.seed(2021)
y = rnorm(52, 5, 1)   # normal
x = exp(y)            # lognormal

# Normal
summary(y);  length(y);  sd(y)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
2.744   4.023   4.990   4.962   5.902   7.120
[1] 52        # sample size
[1] 1.156031  # sample SD
shapiro.test(y)$p.val [1] 0.177547 # not signif different from normal # Lognormal summary(x); length(x); sd(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 15.55 55.95 146.93 257.55 365.94 1236.45 [1] 52 [1] 278.6784 shapiro.test(x)$p.val
[1] 3.559653e-07      # normality strongly rejected


The normal sample y (left panel) has a normal probability plot that is roughly linear, except possibly for a few points in the tails. The red reference line goes through the theoretical and sample upper and lower quartiles. Lognormal sample y (right panel) is clearly not normal.

R code for figure:

par(mfrow=c(1,2))
qqnorm(y, main="Normal QQ Plot: Normal")
qqline(y, col="red")
qqnorm(x, main="Normal QQ Plot: Lognormal")
qqline(x, col="red")
par(mfrow=c(1,1))


one-sample t test on normal data. You could do a one sample t test on the normal data y, as you suggest. Because these are fictitious data sampled with mean $$\mu_y = 5,$$ the null hypothesis $$H_0: \mu_y = 5$$ is not rejected in favor of the alternative $$H_a: \mu_y \ne 5.$$

t.test(y, mu=5)

One Sample t-test

data:  y
t = -0.2354, df = 51, p-value = 0.8148
alternative hypothesis: true mean is not equal to 5
95 percent confidence interval:
4.640422 5.284104
sample estimates:
mean of x              # output uses symbol 'x'
4.962263
sample estimates:
mean of x
257.5527


However, $$\mu_x = E(X) = 244.6919,$$ the lognormal mean, has natural log about $$5.2,$$ which is not $$E(Y),$$ so $$H_0: \mu_y = 5.2$$ is strongly rejected in favor of $$H_a: \mu_y \ne 5.2$$ with P-value far below 5%.

t.test(y, mu=5.5)$p.val [1] 0.001507389  • Thanks to @Luke for attempted edit. Just got out of "minor surgery" so making even more typos than usual. Hope I have found all the typos now. Commented Dec 7, 2021 at 8:18 • thank you for the detailed response. I'm not sure that I entirely follow as this is a bit out of my scope. I'm still a bit unsure how to proceed but I'll keep looking into it. – CSJ Commented Dec 7, 2021 at 16:05 • Can you say what is the first part of the answer you don't 'entirely follow'? One key point is that you can't take the$\ln\$ of lognormal mean to get corresp. normal mean. (That works for medians, but not for means.) Commented Dec 7, 2021 at 16:10
• I can back up a little with my question and see if that helps as well. I have seen a few examples and videos on transforming data prior to running a two-sample T-test, and the data transformation must be applied to both datasets (otherwise you would be testing if the mean of variance 1 is equal to the transformed mean of variance 2).
– CSJ
Commented Dec 7, 2021 at 16:23
• Because I would like to run a one-sample T-test, however, and my data (untransformed) is not normally distributed, I am unsure how to proceed. Transforming the data does improve the normality so I am wondering if I apply the same logic as the two-sample T-test, which would be to transform both my data AND transform the known value I would like to test against. Or do I leave the known value I am testing against untransformed? Does this help?
– CSJ
Commented Dec 7, 2021 at 16:26