+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 16 to 21 of 21

Thread: Adjusting confidence intervals for multiple comparisons

  1. #16
    Test of Gnomality
    Points: 8,295, Level: 61
    Level completed: 49%, Points required for next Level: 155
    hlsmith's Avatar
    Posts
    1,514
    Thanks
    99
    Thanked 255 Times in 248 Posts

    Re: Adjusting confidence intervals for multiple comparisons



    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;

  2. The Following User Says Thank You to hlsmith For This Useful Post:

    lancearmstrong1313 (09-26-2012)

  3. #17
    RotParaTon
    Points: 46,194, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterCommunity AwardMaster Tagger
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,073
    Thanks
    211
    Thanked 1,606 Times in 1,376 Posts

    Re: Adjusting confidence intervals for multiple comparisons

    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

  4. The Following User Says Thank You to Dason For This Useful Post:

    hlsmith (09-26-2012)

  5. #18
    Points: 3,892, Level: 39
    Level completed: 62%, Points required for next Level: 58

    Posts
    302
    Thanks
    16
    Thanked 15 Times in 15 Posts

    Re: Adjusting confidence intervals for multiple comparisons

    Can anyone explain to me why for the Bonferonni CI, the code is doing 1-.025/k instead of 1-.05/k?

  6. #19
    Test of Gnomality
    Points: 8,295, Level: 61
    Level completed: 49%, Points required for next Level: 155
    hlsmith's Avatar
    Posts
    1,514
    Thanks
    99
    Thanked 255 Times in 248 Posts

    Re: Adjusting confidence intervals for multiple comparisons

    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:

    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;
    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).
    Last edited by hlsmith; 10-03-2012 at 08:45 AM. Reason: spelling error

  7. #20
    RotParaTon
    Points: 46,194, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterCommunity AwardMaster Tagger
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,073
    Thanks
    211
    Thanked 1,606 Times in 1,376 Posts

    Re: Adjusting confidence intervals for multiple comparisons

    To make a (1-\alpha)% confidence interval you typically use the (1-\alpha/2) quantile of the distribution of interest. This is why it's 1-alpha/2 instead of 1-alpha.
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  8. #21
    Points: 3,892, Level: 39
    Level completed: 62%, Points required for next Level: 58

    Posts
    302
    Thanks
    16
    Thanked 15 Times in 15 Posts

    Re: Adjusting confidence intervals for multiple comparisons


    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

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats