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; The MEANS Procedure Variable Mean Std Dev N Skewness Kurtosis t Value Pr > |t| ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ iq 100.2613636 12.9849553 88 0.3943203 -0.1634709 72.43 <.0001 IQ_diff 0.2613636 12.9849553 88 0.3943203 -0.1634709 0.19 0.8507 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Lower 95% Upper 95% Variable CL for Mean CL for Mean ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ iq 97.5101145 103.0126128 IQ_diff -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; One Sample T-Test With Howell Data, IQ of Students in Vermont Obs d d_lower d_upper 1 0.020254 -0.18876 0.22915 2 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-16 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; var V_mus V_rat V_diff; by nurs; run; -------------------------------------------- nurs=MM --------------------------------------------The MEANS Procedure Variable Mean Std Dev N Skewness Kurtosis t Value Pr > |t| ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ v_mus 22.4375000 12.8164933 16 -0.3163856 -0.8764539 7.00 <.0001 v_rat 7.5625000 5.8874867 16 0.1115399 -1.5610184 5.14 0.0001 v_diff 14.8750000 10.5506714 16 0.0587866 -1.4495685 5.64 <.0001 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ -------------------------------------------- nurs=MR --------------------------------------------Variable Mean Std Dev N Skewness Kurtosis t Value Pr > |t| ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ v_mus 22.3125000 10.2092687 16 -0.4074942 -0.0747930 8.74 <.0001 v_rat 7.5625000 5.7383941 16 0.9244088 1.1906350 5.27 <.0001 v_diff 14.7500000 7.5674743 16 -0.0213611 -1.1933542 7.80 <.0001 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ -------------------------------------------- nurs=RR --------------------------------------------Variable Mean Std Dev N Skewness Kurtosis t Value Pr > |t| ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ v_mus 23.4375000 8.5085741 16 0.3691328 -0.1333649 11.02 <.0001 v_rat 24.7500000 8.0952661 16 0.6327068 0.8319591 12.23 <.0001 v_diff -1.3125000 8.4041161 16 0.1199781 0.3553554 -0.62 0.5416 ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 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. -------------------------------------------------------------------------------------------------Experiment 2 of Karl's Dissertation Correlated t-tests, Visits to Mus Tunnel vs Rat Tunnel, Three Nursing Groups 4 -------------------------------------------- nurs=MM --------------------------------------------The CORR Procedure 1 With Variables: 1 Variables: v_rat v_mus Pearson Correlation Coefficients, N = 16 Prob > |r| under H0: Rho=0 v_mus v_rat 0.58052 0.0184 -------------------------------------------------------------------------------------------------Experiment 2 of Karl's Dissertation Correlated t-tests, Visits to Mus Tunnel vs Rat Tunnel, Three Nursing Groups 5 -------------------------------------------- nurs=MR --------------------------------------------The CORR Procedure 1 With Variables: 1 Variables: v_rat v_mus Pearson Correlation Coefficients, N = 16 Prob > |r| under H0: Rho=0 v_mus v_rat 0.68185 0.0036 -------------------------------------------------------------------------------------------------Experiment 2 of Karl's Dissertation Correlated t-tests, Visits to Mus Tunnel vs Rat Tunnel, Three Nursing Groups 6 -------------------------------------------- nurs=RR --------------------------------------------The CORR Procedure 1 With Variables: 1 Variables: v_rat v_mus Pearson Correlation Coefficients, N = 16 Prob > |r| under H0: Rho=0 v_mus v_rat 0.48854 0.0548 -------------------------------------------------------------------------------------------------- Data CI2; m1=22.4375 ; m2= 7.5625 ; s1=12.8164933 ; s2= 5.8874867 ; r= 0.58052 ; n=16 ; 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 7 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; The TTEST Procedure Variable: Mom Mouse Rat Diff (1-2) Mom Mouse Rat Diff (1-2) Diff (1-2) v_diff N Mean Std Dev Std Err Minimum Maximum 32 16 14.8125 -1.3125 16.1250 9.0320 8.4041 8.8321 1.5966 2.1010 2.7043 0 -17.0000 31.0000 17.0000 Std Dev 95% CL Std Dev Method Mean 95% CL Mean 14.8125 -1.3125 16.1250 16.1250 Pooled Satterthwaite 11.5561 -5.7907 10.6816 10.7507 Method Variances Pooled Satterthwaite Equal Unequal 18.0689 3.1657 21.5684 21.4993 9.0320 8.4041 8.8321 DF t Value Pr > |t| 46 32.141 5.96 6.11 <.0001 <.0001 7.2410 6.2082 7.3393 12.0078 13.0070 11.0930 Equality of Variances Method Folded F Num DF Den DF F Value Pr > F 31 15 1.15 0.7906 -------------------------------------------------------------------------------------------------- data CI3; t= 5.96 ; df = 46 ; n1 = 32 ; n2 = 16 ; ***********************************************************************************; 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.11164 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. Independent Samples T-Tests on Mouse-Rat Tunnel Difference Scores Foster Mom is a Mouse, Pups Exposed to Rat Scent (MR) or Not (MM) data Mus3; set Mus; if nurs NE 'RR'; proc ttest; class nurs; var v_diff; run; The TTEST Procedure Variable: nurs MM MR Diff (1-2) nurs N Mean Std Dev Std Err Minimum Maximum 16 16 14.8750 14.7500 0.1250 10.5507 7.5675 9.1810 2.6377 1.8919 3.2460 0 3.0000 31.0000 26.0000 Method MM MR Diff (1-2) Diff (1-2) v_diff Mean Pooled Satterthwaite 95% CL Mean 14.8750 14.7500 0.1250 0.1250 9.2529 10.7176 -6.5042 -6.5329 Method Variances Pooled Satterthwaite Equal Unequal 20.4971 18.7824 6.7542 6.7829 Std Dev 95% CL Std Dev 10.5507 7.5675 9.1810 7.7938 5.5901 7.3367 DF t Value Pr > |t| 30 27.204 0.04 0.04 0.9695 0.9696 16.3292 11.7121 12.2721 Equality of Variances Method Num DF Den DF F Value Pr > F 15 15 1.94 0.2096 Folded F 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. -------------------------------------------------------------------------------------------------- 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 16 B 10 B 5 B 13 proc ttest; class program; var loss; run; The TTEST Procedure Variable: program A B Diff (1-2) program A B Diff (1-2) Diff (1-2) loss N Mean Std Dev Std Err Minimum Maximum 6 12 22.6667 13.2500 9.4167 4.2740 4.0927 4.1502 1.7448 1.1815 2.0751 18.0000 5.0000 30.0000 19.0000 Method Mean Pooled Satterthwaite 95% CL Mean 22.6667 13.2500 9.4167 9.4167 Method Variances Pooled Satterthwaite Equal Unequal 18.1814 10.6496 5.0177 4.7023 Std Dev 27.1519 15.8504 13.8157 14.1310 4.2740 4.0927 4.1502 DF t Value Pr > |t| 16 9.7083 4.54 4.47 0.0003 0.0013 Equality of Variances Method Folded F Num DF Den DF F Value Pr > F 5 11 1.09 0.8357 95% CL Std Dev 2.6678 2.8992 3.0909 10.4824 6.9489 6.3163 -------------------------------------------------------------------------------------------------- data CI4; t= 4.54 ; df = 16 ; 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; Independent t on WTLOSS Data Obs d d_lower d_upper 1 2.27 0.99588 3.50073 12 Those who completed weight-loss Program A lost significantly more weight (M = 22.67 lb., SD = 4.27, n = 6) than did those who completed weight-loss Program B (M = 13.25 lb., SDs = 4.09, n = 12), t(9.7) = 4.47, p = .001. 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 The CORR Procedure 3 Variables: vote IQ Simple Statistics income Variable vote IQ income N Mean Std Dev Sum Minimum Maximum 51 51 51 0.60784 99.92157 30.81918 0.49309 2.39034 4.92449 31.00000 5096 1572 0 94.00000 23.44800 1.00000 104.00000 48.34200 Pearson Correlation Coefficients, N = 51 Prob > |r| under H0: Rho=0 vote IQ income 1.00000 -0.34902 0.0121 -0.63470 <.0001 IQ -0.34902 0.0121 1.00000 0.26385 0.0614 income -0.63470 <.0001 0.26385 0.0614 1.00000 vote -------------------------------------------------------------------------------------------------Income, IQ, and Presidential Voting 2 The TTEST Procedure Variable: vote Kerry Bush Diff (1-2) vote Kerry Bush Diff (1-2) Diff (1-2) IQ N Mean Std Dev Std Err Minimum Maximum 20 31 101.0 99.2581 1.6919 1.9861 2.4217 2.2628 0.4441 0.4349 0.6490 95.0000 94.0000 104.0 102.0 Method Pooled Satterthwaite Mean 101.0 99.2581 1.6919 1.6919 Method Variances Pooled Satterthwaite Equal Unequal 95% CL Mean 100.0 98.3698 0.3878 0.4407 Std Dev 101.9 100.1 2.9961 2.9431 1.9861 2.4217 2.2628 DF t Value Pr > |t| 49 46.079 2.61 2.72 0.0121 0.0091 95% CL Std Dev 1.5104 1.9352 1.8902 2.9009 3.2370 2.8197 Equality of Variances Method Num DF Den DF F Value Pr > F 30 19 1.49 0.3688 Folded F Obs g d_lower d_upper 1 0.74857 0.16375 1.32623 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 [.16, 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: vote Kerry Bush Diff (1-2) vote Kerry Bush Diff (1-2) Diff (1-2) income N Mean Std Dev Std Err Minimum Maximum 20 31 34.6722 28.3334 6.3388 5.0018 2.8794 3.8441 1.1184 0.5172 1.1025 28.8310 23.4480 48.3420 34.2380 Method Mean 34.6722 28.3334 6.3388 6.3388 Pooled Satterthwaite Method Variances Pooled Satterthwaite Equal Unequal 95% CL Mean 32.3312 27.2772 4.1232 3.8114 Std Dev 37.0131 29.3896 8.5543 8.8662 5.0018 2.8794 3.8441 DF t Value Pr > |t| 49 27.205 5.75 5.14 <.0001 <.0001 95% CL Std Dev 3.8038 2.3009 3.2111 7.3055 3.8488 4.7902 -------------------------------------------------------------------------------------------------Income, IQ, and Presidential Voting 3 The TTEST Procedure Variable: income Equality of Variances Method Folded F Num DF Den DF F Value Pr > F 19 30 3.02 0.0067