One Sample T-Test With Howell Data, IQ of Students in Vermont data howell; infile 'C:\Users\Vati\Documents\StatData\howell.dat'; input addsc sex repeat iq engl engg gpa socprob dropout; IQ_diff = iq - 100; run; *Want to test null hypothesis that mean IQ is 100; proc means mean stddev n skewness kurtosis t prt CLM; var iq IQ_diff; run; One Sample T-Test With Howell Data, IQ of Students in Vermont The MEANS Procedure Variable Mean Std Dev N Skewness Kurtosis t Value Pr > t Lower 95% Upper 95% iq 100.2613636 12.9849553 88 0.3943203-0.34709 72.43 97.5101145 103.0126128 IQ_diff 0.2613636 12.9849553 88 0.3943203-0.34709 0.19 0.8507-2.4898855 3.0126128 Data CI1; t = 0.19 ; n = 88 ; df = n-1; d = t/sqrt(n); ncp_lower = TNONCT(t,df,.975); ncp_upper = TNONCT(t,df,.025); d_lower = ncp_lower/sqrt(n); d_upper = ncp_upper/sqrt(n); output; run; proc print; var d d_lower d_upper; run; Obs d d_lower d_upper 1 0.020254-0.18876 0.22915 Vermont students mean IQ (M = 100.26, SD = 12.98) did not differ significantly from 100, t(87) = 0.19, p =.85, d =.02. A 95% CI for the difference in means runs from 97.51 in 103.01 in IQ units and from -.19 to.23 in standard deviation units. --------------------------------------------------------------------------------------------------
Experiment 2 of Karl's Dissertation Correlated t-tests, Visits to Mus Tunnel vs Rat Tunnel, Three Nursing Groups data Mus; infile 'C:\Users\Vati\Documents\StatData\tunnel2.dat'; input nurs $ 1-2 L1 3-5 L2 6-8 t1 9-11 t2 12-14 v_mus 15- v_rat 17-18; *t_mus=sqrt(1.575 * t1 +.5); *t_rat=sqrt(1.575 * t2 +.5); *L_mus=LOG10(1.575 * L1 + 1); *L_rat=LOG10(1.575 * L2 + 1); v_diff=v_mus - v_rat; *t_diff=t_mus - t_rat; *L_diff=L_mus - L_rat; proc sort; by nurs; proc means mean stddev n skewness kurtosis t prt CLM; var V_mus V_rat V_diff; by nurs; run; Experiment 2 of Karl's Dissertation Correlated t-tests, Visits to Mus Tunnel vs Rat Tunnel, Three Nursing Groups The MEANS Procedure nurs=mm Variable Mean Std Dev N Skewness Kurtosis t Value Pr > t Lower 95% Upper 95% v_mus 22.4375000 12.84933-0.33856-0.8764539 7.00 15.6080728 29.2669272 v_rat 7.5625000 5.8874867 0.1115399-1.5610184 5.14 0.0001 4.4252798 10.6997202 v_diff 14.8750000 10.5506714 0.0587866-1.4495685 5.64 9.2529441 20.4970559 The MM mice made significantly more visits to the Mus-scented tunnel (M = 22.44, s = 12.82) than to the Rattus-scented tunnel (M = 7.56, s = 5.89), t(15) = 5.64, p <.001, d = 1.49. I did not report the unstandardized confidence intervals here, as I felt they would not add much to understanding the results. nurs=mr Variable Mean Std Dev N Skewness Kurtosis t Value Pr > t Lower 95% Upper 95% v_mus 22.3125000 10.2092687-0.4074942-0.0747930 8.74.8723647 27.7526353 v_rat 7.5625000 5.7383941 0.9244088 1.1906350 5.27 4.5047256 10.6202744 v_diff 14.7500000 7.5674743-0.0213611-1.1933542 7.80 10.7175776 18.7824224
The MR mice made significantly more visits to the Mus-scented tunnel (M = 22.31, s = 10.21) than to the Rattus-scented tunnel (M = 7.56, s = 5.73), t(15) = 7.80, p <.001, d = 1.78. nurs=rr Variable Mean Std Dev N Skewness Kurtosis t Value Pr > t Lower 95% Upper 95% v_mus 23.4375000 8.5085741 0.3691328-0.1333649 11.02 18.9036009 27.9713991 v_rat 24.7500000 8.0952661 0.6327068 0.8319591 12.23 20.4363372 29.0636628 v_diff -1.3125000 8.40411 0.1199781 0.3553554-0.62 0.54-5.7907373 3.57373 For the RR mice, the number of visits to the Mus-scented tunnel (M = 23.44, s = 8.51) did not differ significantly from the number of visits to the Rattus-scented tunnel (M = 24.75, s = 8.10), t(15) = 0.62, p =.54, d =.. Notice that house mice reared with house mice or with deer mice avoided the rat-scented tunnels, but those reared with rats did not. Avoiding the scent of rat makes a lot of sense when you consider that rats eat mice. proc corr nosimple; var V_Mus; with V_rat; by nurs; run; We need these correlations to run Algina s code for computing d with confidence intervals. The CORR Procedure nurs=mm 1 With Variables: v_rat 1 Variables: v_mus Pearson Correlation Coefficients, N = Prob > r under H0: Rho=0 v_mus v_rat 0.58052 0.0184
nurs=mr 1 With Variables: v_rat 1 Variables: v_mus Pearson Correlation Coefficients, N = Prob > r under H0: Rho=0 v_mus v_rat 0.68185 0.0036 nurs=rr 1 With Variables: v_rat 1 Variables: v_mus Pearson Correlation Coefficients, N = Prob > r under H0: Rho=0 v_mus v_rat 0.48854 0.0548 -------------------------------------------------------------------------------------------------- Data CI2; m1=22.4375 ; m2= 7.5625 ; s1=12.84933 ; s2= 5.8874867 ; r= 0.58052 ; n= ; prob=.95 ; v1=s1**2;
v2=s2**2; s12=s1*s2*r; se=sqrt((v1+v2-2*s12)/n); pvar=(v1+v2)/2; nchat=(m1-m2)/se; es=(m1-m2)/(sqrt(pvar)); df=n-1; ncu=tnonct(nchat,df,(1-prob)/2); ncl=tnonct(nchat,df,1-(1-prob)/2); ul=se*ncu/(sqrt(pvar)); ll=se*ncl/(sqrt(pvar)); output; proc print; title1 'll is the lower limit and ul is the upper limit'; title2 'of a confidence interval for the effect size'; title3 'MM group only' ; var es ll ul ; run; ll is the lower limit and ul is the upper limit of a confidence interval for the effect size MM group only Obs es ll ul 1 1.49151 0.73888 2.21981 House mice who had been reared with house mice visited the tunnels scented with house mouse significantly more often (M = 22.44, SD = 12.81) than tunnels scented with rat (M = 7.56, SD = 5.89), t(15) = 5.64, p <.001, d = 1.49, 95% CI [.74, 2.22]. Independent Samples T-Tests on Mouse-Rat Tunnel Difference Scores Foster Mom is a Mouse or is a Rat data Mus2; set Mus; if nurs NE 'RR' then Mom = 'Mouse'; else if nurs = 'RR' then Mom = 'Rat'; proc ttest; class Mom; var v_diff; run; *proc mixed; *class Mom; *model v_diff = Mom / ddfm = satterth; *repeated / group=mom; *lsmeans Mom / pdiff CL; *run;
title2 'Foster Mom is a Mouse, Pups Exposed to Rat Scent (MR) or Not (MM)'; run; Independent Samples T-Tests on Mouse-Rat Tunnel Difference Scores Foster Mom is a Mouse or is a Rat The TTEST Procedure Variable: v_diff The dependent variable here is a measure of preference for visiting the Mus-scented tunnel rather than the Rattus-scented tunnel. Mom N Mean Std Dev Std Err Minimum Maximum Mouse 32 14.8125 9.0320 1.5966 0 31.0000 Rat -1.3125 8.4041 2.1010-17.0000 17.0000 Diff (1-2).1250 8.8321 2.7043 Mom Method Mean 95% CL Mean Std Dev 95% CL Std Dev Mouse 14.8125 11.5561 18.0689 9.0320 7.2410 12.0078 Rat -1.3125-5.7907 3.57 8.4041 6.2082 13.0070 Diff (1-2) Pooled.1250 10.68 21.5684 8.8321 7.3393 11.0930 Diff (1-2) Satterthwaite.1250 10.7507 21.4993 Method Variances DF t Value Pr > t Pooled Equal 46 5.96 Satterthwaite Unequal 32.141 6.11 Equality of Variances Method Num DF Den DF F Value Pr > F Folded F 31 15 1.15 0.7906
-------------------------------------------------------------------------------------------------- data CI3; t= 5.96 ; df = 46 ; n1 = 32 ; n2 = ; ***********************************************************************************; d = t/sqrt(n1*n2/(n1+n2)); ncp_lower = TNONCT(t,df,.975); ncp_upper = TNONCT(t,df,.025); d_lower = ncp_lower*sqrt((n1+n2)/(n1*n2)); d_upper = ncp_upper*sqrt((n1+n2)/(n1*n2)); output; run; proc print; var d d_lower d_upper; run; Obs d d_lower d_upper 1 1.82487 1.114 2.52360 Mice that had been fostered onto a mouse mother had a significantly stronger preference for visiting mouse-scented rather than rat-scented tunnels (M = 14.81, SD = 9.03) than did mice who had been fostered onto a rat mother (M = -1.31, SD = 8.40), t(32.1) = 6.11, p <.001, d = 1.82, 95% CI [1.11, 2.52]. The graphics provided by SAS in the htm output can be very helpful with respect to evaluating the normality assumption. For each group we get a histogram overlaid with 1.) a smoothed curve representing the distribution of the observed scores, and 2.) a normal curve with the same mean and standard deviation of the observed scores.
data Mus3; set Mus; if nurs NE 'RR'; proc ttest; class nurs; var v_diff; run; Independent Samples T-Tests on Mouse-Rat Tunnel Difference Scores Foster Mom is a Mouse, Pups Exposed to Rat Scent (MR) or Not (MM) Variable: v_diff nurs N Mean Std Dev Std Err Minimum Maximum MM 14.8750 10.5507 2.6377 0 31.0000 MR 14.7500 7.5675 1.8919 3.0000 26.0000 Diff (1-2) 0.1250 9.1810 3.2460 nurs Method Mean 95% CL Mean Std Dev 95% CL Std Dev MM 14.8750 9.2529 20.4971 10.5507 7.7938.3292 MR 14.7500 10.7176 18.7824 7.5675 5.5901 11.7121 Diff (1-2) Pooled 0.1250-6.5042 6.7542 9.1810 7.3367 12.2721 Diff (1-2) Satterthwaite 0.1250-6.5329 6.7829 Method Variances DF t Value Pr > t Pooled Equal 30 0.04 0.9695 Satterthwaite Unequal 27.204 0.04 0.9696 Method Equality of Variances Num DF Den DF F Value Pr > F Folded F 15 15 1.94 0.2096 The sample sizes are equal and the ratio of the larger variance to the smaller variance less than 4, so I employ the pooled variances t test.
Preference for the Mus-scented tunnel for the MM mice (M = 14.88, s = 10.55, n = ) did not differ significantly from that for the MR mice (M = 14.75, s = 7.57, n = ), t(30) = 0.04, p =.97, d =.01, 95% CI [-.68,.71]. -------------------------------------------------------------------------------------------------- Independent t on WTLOSS Data data wtloss; input program $ loss @@ ; cards; A 25 A 21 A 18 A 20 A 22 A 30 B 15 B 17 B 9 B 12 B 11 B 19 B 14 B 18 B B 10 B 5 B 13 proc ttest; class program; var loss; run; program N Mean Std Dev Std Err Minimum Maximum A 6 22.6667 4.2740 1.7448 18.0000 30.0000 B 12 13.2500 4.0927 1.1815 5.0000 19.0000 Diff (1-2) 9.47 4.1502 2.0751 program Method Mean 95% CL Mean Std Dev 95% CL Std Dev A 22.6667 18.1814 27.1519 4.2740 2.6678 10.4824 B 13.2500 10.6496 15.8504 4.0927 2.8992 6.9489 Diff (1-2) Pooled 9.47 5.0177 13.8157 4.1502 3.0909 6.33 Diff (1-2) Satterthwaite 9.47 4.7023 14.1310 Method Variances DF t Value Pr > t Pooled Equal 4.54 0.0003 Satterthwaite Unequal 9.7083 4.47 0.0013 Equality of Variances Method Num DF Den DF F Value Pr > F Folded F 5 11 1.09 0.8357
data CI4; t= 4.54 ; df = ; n1 = 6 ; n2 = 12 ; ***********************************************************************************; d = t/sqrt(n1*n2/(n1+n2)); ncp_lower = TNONCT(t,df,.975); ncp_upper = TNONCT(t,df,.025); d_lower = ncp_lower*sqrt((n1+n2)/(n1*n2)); d_upper = ncp_upper*sqrt((n1+n2)/(n1*n2)); output; run; proc print; var d d_lower d_upper; run; Obs d d_lower d_upper 1 2.27 0.99588 3.50073 Participants who completed the Marine Corps weight loss program (M = 22.67, s = 4.27, n = 6) lost significantly more weight than those who completed the Boy Scouts weight loss program (M = 13.25, s = 4.09, n = 12), t(9.7) = 4.47, p =.001, d = 2.27, 95% CI [1.00, 3.50]. When considering these results, one must question how the selective attrition might have affected the means. Perhaps weight loss was greater in Program A simply because Program A was more effective in chasing off those who were not losing weight. options pageno=min nodate formdlim='-'; proc format; value bk 0='Kerry' 1='Bush'; run; title 'Income, IQ, and Presidential Voting'; run; data Voting; infile 'C:\D\StatData\Bush-Kerry2004.txt'; input IQ state $ income vote candidate $; format vote bk. ; proc corr; var vote iq income; run; proc ttest; class vote; var iq income; run; Data CI; t= 2.61 ; df = 49 ; n1 = 20 ; n2 =31 ; d = t/sqrt(n1*n2/(n1+n2));
ncp_lower = TNONCT(t,df,.975); ncp_upper = TNONCT(t,df,.025); d_lower = ncp_lower*sqrt((n1+n2)/(n1*n2)); d_upper = ncp_upper*sqrt((n1+n2)/(n1*n2)); output; run; proc print; var d d_lower d_upper; run; -------------------------------------------------------------------------------------------------- Obs d d_lower d_upper 1 2.27 0.99588 3.50073 Income, IQ, and Presidential Voting options pageno=min nodate formdlim='-'; proc format; value bk 0='Kerry' 1='Bush'; run; title 'Income, IQ, and Presidential Voting'; run; data Voting; infile 'F:\StatData\Bush-Kerry2004.txt'; input IQ state $ income vote candidate $; format vote bk. ; proc corr; var vote iq income; run; proc ttest; class vote; var iq income; run; The CORR Procedure 3 Variables: vote IQ income Simple Statistics Variable N Mean Std Dev Sum Minimum Maximum vote 51 0.60784 0.49309 31.00000 0 1.00000 IQ 51 99.92157 2.39034 5096 94.00000 104.00000 income 51 30.81918 4.92449 1572 23.44800 48.34200 For the vote variable, 0 coded the state voting for Kerry, 1 coded the state voting for Bush.
Pearson Correlation Coefficients, N = 51 Prob > r under H0: Rho=0 vote IQ income vote 1.00000-0.34902 0.0121-0.63470 IQ -0.34902 0.0121 1.00000 0.26385 0.0614 income -0.63470 0.26385 0.0614 1.00000 There are two significant correlations in the matrix above. Voting for Bush is negatively correlated with average IQ and average income in the state. We can test the null hypothesis that the correlation between voting preference and IQ is zero this way: t r n 2 1 r 2.34902 49 1.34902 2 2.61. The obtained value of t will be identical to that for the pooled t test. The TTEST Procedure Variable: IQ vote N Mean Std Dev Std Err Minimum Maximum Kerry 20 101.0 1.9861 0.4441 95.0000 104.0 Bush 31 99.2581 2.4217 0.4349 94.0000 102.0 Diff (1-2) 1.6919 2.2628 0.6490
vote Method Mean 95% CL Mean Std Dev 95% CL Std Dev Kerry 101.0 100.0 101.9 1.9861 1.5104 2.9009 Bush 99.2581 98.3698 100.1 2.4217 1.9352 3.2370 Diff (1-2) Pooled 1.6919 0.3878 2.9961 2.2628 1.8902 2.8197 Diff (1-2) Satterthwaite 1.6919 0.4407 2.9431 Method Variances DF t Value Pr > t Pooled Equal 49 2.61 0.0121 Satterthwaite Unequal 46.079 2.72 0.0091 Method Equality of Variances Num DF Den DF F Value Pr > F Folded F 30 19 1.49 0.3688 The estimated mean IQ of residents of states which voted for Kerry (M = 101.0, s = 1.99, n = 20) was significantly higher than that of states which voted for Bush (M = 99.3, s = 2.42, n = 32), t(46.1) = 2.71, p =.009, d =.75, 95% CI [., 1.33]. One could use the point biserial r as the effect size estimator here, or its square (which can be interpreted as a proportion of variance in IQ explained by the model). The value of that r here is -0.35. Variable: income vote N Mean Std Dev Std Err Minimum Maximum Kerry 20 34.6722 5.0018 1.1184 28.8310 48.3420 Bush 31 28.3334 2.8794 0.5172 23.4480 34.2380 Diff (1-2) 6.3388 3.8441 1.1025
vote Method Mean 95% CL Mean Std Dev 95% CL Std Dev Kerry 34.6722 32.3312 37.0131 5.0018 3.8038 7.3055 Bush 28.3334 27.2772 29.3896 2.8794 2.3009 3.8488 Diff (1-2) Pooled 6.3388 4.1232 8.5543 3.8441 3.2111 4.7902 Diff (1-2) Satterthwaite 6.3388 3.8114 8.8662 Method Variances DF t Value Pr > t Pooled Equal 49 5.75 Satterthwaite Unequal 27.205 5.14 Method Equality of Variances Num DF Den DF F Value Pr > F Folded F 19 30 3.02 0.0067 Average income in states voting for Kerry (M = $34,672, s = $5,002), n = 20) was significantly greater than that in states voting for Bush (M = $28,333, s = $2,879, n = 31), t(27.2) = 5.14, p <.001, d = 1.65, 95% CI [.99, 2.29].