# Different results for simulated and closed form distribution of T-statistic under the alternative hypothesis

While running some simulations to get a better grasp of the concept of statistical power I stumbled upon an unexpected result. I was trying to simulate the sampling distribution of test statistic $$T$$ associated with Pearson correlation coefficient $$R$$, assuming a sample size of $$n = 200$$ and a population correlation $$\rho = .5$$. I expected that this distribution would look like a non-central $$T$$-distribution with noncentrality parameter $$\lambda = \sqrt{\frac{n \rho^2}{1-\rho^2}} = \sqrt{\frac{200*0.5^2}{1-0.5^2}}=8.164966$$ (which is the distribution used in G*Power to calculate statistical power under these circumstances; see page 41 of the manual). However, the distribution I got from my simulation did not at all resemble the plot of the noncentral $$pdf$$. This is the plot:

The R code I used is:

set.seed(1234)

n <- 200
rho <- 0.5
noncentrality <- sqrt(((rho**2)*n)/(1-(rho**2)))

tdistsim <- c()
for (i in 1:10000) {
Variable1 <- rnorm(n,0,1)
Variable2 <- rho*Variable1+rnorm(n,0,1)
tdistsim[i] <- cor.test(Variable1,Variable2,method="pearson")$statistic } pdft <- dt(seq(0,15,15/10000),df=n-2,ncp=noncentrality) plot(seq(0,15,15/10000),pdft,type="l",col="blue",lwd=3,xlab=c("T"),ylab=c("Density")) lines(density(tdistsim),col="red",lwd=3) legend(0,0.32, c("Noncentral pdf","Simulation"), lwd="3", col=c("blue","red") )  So, obviously, my question is: how is this possible? Aren't these distributions supposed to be (nearly/asymptotically) identical? And if so, where's my error? EDIT. I think I found the error in my simulation. The standard deviation of the residuals was set to 1 instead of $$RMSE = \sqrt{1-\rho^2}$$. That is, the line Variable2 <- rho*Variable1+rnorm(n,0,1)  should read Variable2 <- rho*Variable1+rnorm(n,0,sqrt(1-rho**2))  The plot now looks like this: • Where exactly in the G*Power manual can we find the cited formula? – COOLSerdash Sep 23 '19 at 10:01 • Page 41. Sorry, will add this to the opening post as well. – Barlon Mrando Sep 23 '19 at 10:05 • Re the edit: Do you have a question left to ask? – whuber Sep 24 '19 at 11:38 • I don't think so - not unless someone spots another error somewhere. Thanks! – Barlon Mrando Sep 24 '19 at 14:54 • What this doesn't resolve is the question about the sampling distribution of the$t\$ statistic when you have an arbitrary residual standard deviation, as in your first simulation where you set it to 1. – COOLSerdash Sep 29 '19 at 14:06