lancearmstrong1313 (09-26-2012)
Everything put together:
Code:data test; input mean sd n; cards; 10 2.5 40 15 2.0 37 08 2.3 45 17 3.4 35 11 2.9 41 ; run; proc sql; create table test as select *, monotonic() as class from test; quit; proc sql noprint; select count(distinct(class)) into :n from test; quit; proc sql noprint; select fact(count(distinct(class)))/((fact(2))*(fact(count(distinct(class)) - 2))) into :nC2 from test; quit; proc plan; factors test_number=&nC2. ordered class= 2 of &n. comb ; ods output plan=combinations; run; quit; proc sql; create table temp1 as select c.test_number, c.class1, t.mean as mean1, t.sd as sd1, t.n as n1 from combinations c left join test t on c.class1 = t.class ; quit; proc sql; create table temp2 as select c.test_number, c.class2, t.mean as mean2, t.sd as sd2, t.n as n2 from combinations c left join test t on c.class2 = t.class ; quit; proc sql; create table joined as select t1.*, t2.* from temp1 t1, temp2 t2 where t1.test_number = t2.test_number order by t1.test_number ; quit; data combineTest2; set joined; f=finv(0.95,&p,n1+n2-&p-1); t=tinv(1-0.025/&p,n1+n2-2); sp=((n1-1)*sd1+(n2-1)*sd2)/(n1+n2-2); losim=mean1-mean2-sqrt(&p*(n1+n2-2)*f*(1/n1+1/n2)*sp/(n1+n2-&p-1)); upsim=mean1-mean2+sqrt(&p*(n1+n2-2)*f*(1/n1+1/n2)*sp/(n1+n2-&p-1)); lobon=mean1-mean2-t*sqrt((1/n1+1/n2)*sp); upbon=mean1-mean2+t*sqrt((1/n1+1/n2)*sp); run; proc print; run;
lancearmstrong1313 (09-26-2012)
I wrapped your code in [code] [/code] tags for you so it displays better.
"His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich
hlsmith (09-26-2012)
Can anyone explain to me why for the Bonferonni CI, the code is doing 1-.025/k instead of 1-.05/k?
To me it seems to be because otherwise it would be 90% CI.
95%-5% = 90%
See this link for another example:
http://www.statisticslectures.com/to...ndentsamplest/
However, my basic question is why when I conduct the t-test:
are the CIs: -6.0332, -3.9668 and the Bonferroni are -5.9293, -4.07073. I would have imagined that they should have widened on both ends, so the -5.9293 would actually be smaller than -6.0332. I am probably missing something simple (such as how they both are being caluculated).Code:data test; input Category _TYPE_ _FREQ_ _STAT_$ YourVar; datalines; 1 0 6 N 40 1 0 6 MEAN 10 1 0 6 STD 2.5 2 0 6 N 37 2 0 6 MEAN 15 2 0 6 STD 2.0 ; run; proc ttest data=test; class category; var YourVar; run;
Last edited by hlsmith; 10-03-2012 at 08:45 AM. Reason: spelling error
"His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich
Oh yeah duh, because it's technicailly (.05)/(2*k) so the code is just canceling out the .05/2 part. I'm used to seeing it with the .05 in the numerator and 2 in the denominator that I didn't notice the code just canceled the .05/2 part - I'm dumb
|
|