Thursday, September 10, 2009

Analysis of Means (ANOM) in JMP

This is in response to the query sent to me regarding on how to do an Analysis of Means in JMP. For those who are not familiar with this method, you can refer to this SAS link regarding the definition and history of the Analysis of Means, and to this presentation for the technical details. With regards to how to do Analysis of Means in Minitab, refer to this video.

How to do Analysis of Means (ANOM) in JMP

From the 2005 Winter issue of JMPer cable (issue 16) it says that "ANOM is not a standard procedure in JMP. However, scripts generate ANOM decision charts for comparing means with either equal or unequal sample sizes.You can download these scripts at http://www.jmp.com/news/jmpercable. The script for equal sample sizes is named ANOMB.jsl and the script for unequal sample sizes is named ANOMUB.jsl."

The JMP JSL Scripts

Here are the JMP scripts that are downloadable from SAS JMP's website.
JMP's Analysis of Means for Equal Sample Sizes
Clear Globals();
R = Column Dialog(
 Resp = Col List( "Y, Response",
  Data Type( Numeric ),
  Min Col( 1 ),
  Max Col( 1 )
 ),
 Treat = Col List( "X, Treatment",
  Min Col( 1 ),
  Max Col( 1 )
 ),
 V List(
  "Alpha",
  SL = Radio Buttons( "0.1", "0.05", "0.01", "0.001" )
 )
);

If( r["Button"] == -1, Throw( "User cancelled" ) );

TN = Column( R["Treat"] );
RN = Column( R["Resp"] );
SigLevel = R["SL"];

alpha = {0.1, 0.05, 0.01, 0.001};

Summarize(
 a = By( TN ),
 c = Count,
 mean Response = Mean( RN ),
 stdev Response = Std Dev( RN )
);
Ymin = Min( mean Response );
Ymax = Max( mean Response );

k = N Items( a );
K1 = Log( k );
K2 = Log( k-2 );
a1 = a[1];

tc = Sum(c);
MSEnum=summation(i=1, k, (stdev Response[i]^2));
nu = tc - k;
MSE = MSEnum / k;

Insert Into( a, "Total" );
c|/= tc;
mean Response |/= (tmeanY = Col Mean( RN ));
stdev Response |/= Col Std Dev( RN );
 
Include( "Exact Factors for ANOM.JSL" );

Show(SigLevel);
Show(alpha);
PMP = h(SigLevel, k, nu) * Sqrt( MSE ) * Sqrt( (k-1) / tc );

UDL = tmeanY + PMP;
LDL = tmeanY - PMP;

cc = Control Chart(
 Sample Size( TN ),
 KSigma(3),
 Chart Col( RN,
  XBar(
   Needle(1),
   Connect Points(0),
   Show Control Limits(0)
  )
 )
);

ccr = cc << Report;

ccr[TextBox(3)] <<Delete;

ccr[AxisBox(2)] << Max( k+1 );

ccr[FrameBox(1)] << Add Graphics Script(
 Pen Color( 3 );
 H Line( LDL );
 H Line( UDL );
);

ccr[OutlineBox(2)] << Prepend(
 tb = Text Box( "alpha = " || Char( alpha[SigLevel] ) )
);

ccr[OutlineBox(2)] << Prepend(
 tb2 = Text Box( "LDL = " || Char( Round(LDL, 2) )  )
);


ccr[OutlineBox(2)] << Prepend(
 tb3 = Text Box( "UDL = " || Char( Round(UDL, 2) )  )
);

updateChart = Expr(
 PMP = h(SigLevel, k, nu) * Sqrt( MSE ) * Sqrt( (k-1) / tc );
 UDL = tmeanY + PMP;
 LDL = tmeanY - PMP;
 ccr[PictureBox(1)] << Reshow;
 tb << Set Text( "alpha = " || Char( alpha[SigLevel] ) );
 tb2 << Set Text( "LDL = " || Char( Round(LDL, 2) )  );
 tb3 << Set TExt( "UDL = " || Char( Round(UDL, 2) )  );
);

ccr << Append(
 OutlineBox( "Analysis of Means",
  H List Box(
   Button Box( "alpha = 0.1",
    SigLevel = 1;
    updateChart;
   ),
   Button Box( "alpha = 0.05",
    SigLevel = 2;
    updateChart;
   ),
   Button Box( "alpha = 0.01",
    SigLevel = 3;
    updateChart;
   ),
   Button Box( "alpha = 0.001",
    SigLevel = 4;
    updateChart;
   )
  ),
  Outline Box( "Means/Standard Deviations",
   Table Box(
    String Col Box( "Treatment", a ),
    Number Col Box( "Count", c ),
    Number Col Box( "Mean", mean Response ),
    Number Col Box( "Std Dev", stdev Response )
   )
  )
 )
);

JMP's Analysis of Means for Un-Equal Sample Sizes
Clear Globals();

R = Column Dialog(
 Resp = Col List( "Y, Response",
  Data Type( Numeric ),
  Min Col( 1 ),
  Max Col( 1 )
 ),
 Treat = Col List( "X, Treatment",
  Min Col( 1 ),
  Max Col( 1 )
 ),
 V List(
  "Alpha",
  SL = Radio Buttons( "0.1", "0.05", "0.01", "0.001" )
 )
);

If( r["Button"] == -1, Throw( "User cancelled" ) );

TN = Column( R["Treat"] );
RN = Column( R["Resp"] );
SigLevel = R["SL"];

alpha = {0.1, 0.05, 0.01, 0.001};

Summarize(
 a = By( TN ),
 c = Count,
 mean Response = Mean( RN ),
 stdev Response = Std Dev( RN )
);
Ymin = Min( mean Response );
Ymax = Max( mean Response );

k = N Items( a );
K1 = Log( k );
K2 = Log( k-2 );
a1 = a[1];

tc = Sum(c);
MSEnum = Summation( i=1, k, ((c[i]-1)*stdev Response[i]^2) );
nu = tc - k;
MSE = MSEnum / nu;

Insert Into( a, "Total" );
c |/= tc;
mean Response |/= (tmeanY = Col Mean( RN ));
stdev Response |/= Col Std Dev( RN );
 
Include( "Exact Factors for ANOMUB.JSL" );

Show( SigLevel );
Show( alpha );

PMP = {};

UDL = {};
LDL = {};

For( i=1, i<k+1, i++, Insert Into( PMP, m(SigLevel, k, nu) * Sqrt(MSE)*Sqrt((tc - c[i])/(tc*c[i]))));
For( i=1, i<k+1, i++, Insert Into( UDL, tmeanY + PMP[i]));
For( i=1, i<k+1, i++, Insert Into( LDL, tmeanY - PMP[i]));

cc = Control Chart(
 Sample Size( TN ),
 KSigma(3),
 Chart Col( RN,
  XBar(
   Needle(1),
   Connect Points(0),
   Show Control Limits(0)
  )
 )
);

ccr = cc << Report;

ccr[TextBox(3)] << Delete;

ccr[AxisBox(2)] << Max( k+1 );

For( i=1, i<k+1, i++,
 Eval(
  Substitute(
   Expr(
    ccr[FrameBox(1)] << Add Graphics Script(
     Pen Color( 3 );
     H Line( sss, eee, LDL[iii] );
     H Line( sss, eee, UDL[iii] );
    );
   ),
   Expr( sss ),
   i - 0.5,
   Expr( eee ),
   i + 0.5,
   Expr( iii ),
   i
  )
 );
);

ccr[OutlineBox(2)] << Prepend(
 tb = Text Box( "alpha = " || Char( alpha[SigLevel] ) )
);

ccr[OutlineBox(2)] << Prepend(
 tb2 = Text Box( "LDL = " || Char( Round(LDL, 2) )  )
);


ccr[OutlineBox(2)] << Prepend(
 tb3 = Text Box( "UDL = " || Char( Round(UDL, 2) )  )
);

updateChart = Expr(
 For(i=1, i<k+1, i++, PMP[i]=m(SigLevel, k, nu)* Sqrt(MSE)*Sqrt((tc - c[i])/(tc*c[i])));
 For(i=1, i<k+1, i++, UDL[i]= tmeanY + PMP[i]);
 For(i=1, i<k+1, i++, LDL[i] = tmeanY - PMP[i]);

 ccr[PictureBox(1)] <!<! Reshow;
 tb << Set Text( "alpha = " || Char( alpha[SigLevel] ) );
 tb2 << Set Text( "LDL = " || Char( Round(LDL, 2) )  );
 tb3 << Set TExt( "UDL = " || Char( Round(UDL, 2) )  );
);

ccr << Append(
 OutlineBox( "Analysis of Means",
  H List Box(
   Button Box( "alpha = 0.1",
    SigLevel = 1;
    updateChart;
   ),
   Button Box( "alpha = 0.05",
    SigLevel = 2;
    updateChart;
   ),
   Button Box( "alpha = 0.01",
    SigLevel = 3;
    updateChart;
   ),
   Button Box( "alpha = 0.001",
    SigLevel = 4;
    updateChart;
   )
  ),
  Outline Box( "Means/Standard Deviations",
   Table Box(
    String Col Box( "Treatment", a ),
    Number Col Box( "Count", c ),
    Number Col Box( "Mean", mean Response ),
    Number Col Box( "Std Dev", stdev Response )
   )
  )
 )
);

2 comments:

  1. I did determine that the h values used in the Exact Factors for ANOMUB.jsl script for alpha=0.001 were taken from the balanced ANOM table of critical values. I corrected my copy with the values from the unbalanced ANOM table and extend out the number of means to 12.
    Received email from Karen Copeland confirming the error in the lookup table.

    ReplyDelete

 
Custom Search