# We drew some curves to demonstrate how a t distribution # differs from a normal distribution. # Here's a grid of values to provide the X-axis of the plot: > x <- seq(-5,5,.01) > head(x) [1] -5.00 -4.99 -4.98 -4.97 -4.96 -4.95 # Here's a standard normal curve. (That's "ell," not # "one" in the "type='l'" subcommand.) > par(pin=c(6,4)) > plot(x, dnorm(x), type='l') > abline(h=0) # Here, we add a t distribution with small degrees # of freedom. Notice the heavier tails: > lines(x, dt(x, df=2), lty=2) # Because of the heavier tails, the critical value of # a test statistic with t(2) as the reference distribution # will be much larger than the 1.96 we saw for a 2-tailed # Z test at alpha=.05: > qt(.975, 2) [1] 4.302653 # As degrees of freedom increase, the curve becomes # more similar to the standard normal curve: > lines(x, dt(x, df=14), lty=3) # And the critical value becomes smaller (but is still # higher than 1.96): > qt(.975, 14) [1] 2.144787 # Here are the estimates of elapsed time we collected # in class last time: > seconds [1] 20 14 25 18 15 23 30 13 40 12 25 32 30 12 > mean(seconds) [1] 22.07143 > sd(seconds) [1] 8.704237 # Because we don't KNOW sigma, we have to estimate the # standard error of the mean using the sample standard deviation: > se <- sd(seconds) / sqrt(length(seconds)) > se [1] 2.326305 # We calculate the one-sample t statistic: > t <- (mean(seconds) - 23) / se > t [1] -0.3991615 # We can evaluate that by comparing it to the critical value; # it's smaller, so the result is non-significant: > length(seconds) [1] 14 > qt(.975, 13) [1] 2.160369 # Here's the probability that a t statistic would be lower than # ours if the true mean is 23 seconds: > pt(t, 13) [1] 0.348127 # But we have to consider also the probability that it's just as # extreme in the other direction, so here's the probability of # being this extreme in absolute value: > 2*pt(-abs(t), 13) [1] 0.6962541 # 0.696 is larger than our alpha level of .05, so we reach the # same conclusion that we did using the critical value: non-significant. # (The conclusion based on comparison of the statistic with its critical # value will ALWAYS be the same as the one based on comparison of the # exact p-value to the alpha level.) # We evaluate the normality of the distribution: > stem(seconds) The decimal point is 1 digit(s) to the right of the | 1 | 223458 2 | 0355 3 | 002 4 | 0 > qqnorm(seconds); qqline(seconds) # The non-standardized effect size is about -.9 seconds: > mean(seconds)-23 [1] -0.9285714 # The standardized effect size is about -.1 standard deviations: > (mean(seconds)-23)/sd(seconds) [1] -0.1066804 # Here's a standardized effect size comparing the Peabody # mean to a theoretical value of 70: > attach(JackStatlab) The following object is masked _by_ .GlobalEnv: X > (mean(CTPEA)-70)/sd(CTPEA) [1] 0.8026107 # Unlike the example with seconds, an unstandardized effect # size would not be especially useful here because the metric # of Peabody is not intrinsically meaningful: > (mean(CTPEA)-70) [1] 10.02