/** * This script helps to compare different screening designs. * Author: Sebastian Hoffmeister (consult@statcon.de) * */ Names Default To Here( 1 ); /** * Functions * * A function for each design to compare. Each function returns * the design itself as a data table, power for the different factors * and the color map to evaluate the degree of aliasing. * */ /** * This functions visualizes the correlation between all facotrs in a doe * and between factors and 2FI * */ custom.colormap.pic = Function( {doe, eval}, Current Data Table( doe ); // Get the factors and responses factors = {}; responses = {}; colnames = doe << Get column Names; // Figure out what are factors based on the column properties For( i = 1, i <= Length( colnames ), i++, If( Contains( Char( Column( colnames[i] ) << Get Properties List ), "Design Role" ) > 0, Insert Into( factors, colnames[i] ), Insert Into( responses, colnames[i] ) ) ); // Number of factors k = Length( factors ); // Get the X-Matrix x = eval << Get X Matrix; // add all 2FIs! x = x[0, 2 :: N Col( x )]; For( i = 1, i <= k, i++, For( j = i + 1, j <= k, j++, x = x || (x[0, i] :* x[0, j]); Insert Into( factors, Char( factors[i] ) || "*" || Char( factors[j] ) ); ) ); // Calculate all correlations cor = Correlation( X ); // Store all results in a data table => Makes it easy to plot comb = {}; // Which ME/2FI with which other ME/2FI r = {}; // Correlation coefficient xaxis = {}; yaxis = {}; size = {}; // Bubble size = abs(r) For( i = 1, i <= N Col( cor ), i++, For( j = i, j <= N Col( cor ), j++, Insert Into( comb, Char( factors[i] ) || "|" || Char( factors[j] ) ); Insert Into( r, cor[i, j] ); Insert Into( xaxis, i ); Insert Into( yaxis, j ); Insert Into( size, Abs( cor[i, j] ) ); ) ); m = New Table( "Correlation Matrix Data", invisible ); m << New Column( "Desc", character, nominal, Set Values( comb ) ); m << New Column( "r", numeric, continuous, Set Values( r ) ); m << New Column( "x", numeric, continuous, Set Values( xaxis ) ); m << New Column( "y", numeric, continuous, Set Values( yaxis ) ); m << New Column( "size", numeric, continuous, Set Values( size ) ); cordata = m << Get as Matrix; // Get Maximum Length of Var-Names to adjust the graph-size max.length = 0; For( i = 1, i <= Length( factors ), i++, If( max.length < Length( factors[i] ), max.length = Length( factors[i] ) ) ); // Bubble Plot graph = New Window( "Color Map of Correlations", Graph Box( framesize( 500, 500 ), // Graph size X Scale( -max.length / 2, Maximum( cordata[0, 2] ) + 1 ), // Adjust Axis for Bubbles + text Y Scale( -max.length / 2, Max( cordata[0, 3] ) + 1 ), // Add reference grid in gray Pen Color( 1 ); // Gray For( i = 1, i <= Length( Factors ), i++, Line Style( 1 ); // Dotted ref lines Line( {0, i}, {Maximum( cordata[0, 2] ), i} ); Line Style( 1 ); Line( {i, 0}, {i, Maximum( cordata[0, 2] )} ); ); // Draw Bubbles For( i = 1, i <= N Row( m ), i++, Fill Color( Heat Color( (cordata[i, 1] + 1) / 2 ) ); Circle( {cordata[i, 2], cordata[i, 3]}, (cordata[i, 4] + 0.3) / 2, "FILL" ); ); // Draw Factor Names For( i = 1, i <= Length( Factors ), i++, Text( Clockwise, {i - 0.1, 0}, factors[i] ); Text( Right Justified, {0, i - 0.1}, factors[i] ); ); ) ); // Delete the Y-and X-Axis from the report graph[Axis Box( 1 )] << Delete; graph[Axis Box( 1 )] << Delete; graph << On Close( Close( m, Nosave ) ); graph; ); // Setup the fullfactorial design setup.full = Function( {x, y}, design = DOE( Full Factorial Design ); design << Load Factors( x ); design << Load Responses( y ); design << Make Design; table = design << Make Table(); design << Close Window; table; ); // Setup a definitive Screening setup.dsd = Function( {x, y}, design = DOE( Definitive Screening Design ); design << Load Factors( x ); design << Load Responses( y ); design << Make Design; table = design << Make Table(); design << Close Window; table; ); // Setup a fractional factorial design (Resolution III, IV or V) setup.fractional = Function( {x, y, res = 5}, design = DOE( Screening Design ); design << Load Factors( x ); design << Load Responses( y ); // Get the right design ID based on resolution and k k = N Col( x ); id = .; If( res == 5, id = Choose( k, "Not for 1 factor", // One factor only does not work "There is no Res V Design for 2 factors.", // Two Factors "There is no Res V Design for 3 factors.", // 3 Factors "There is no Res V Design for 4 factors.", // 4 Factors 4, // 5 Factors 8, // 6 Factors 12, // 7 Factors 11, // 8 Factors 18, // 9 Factors 18, // 10 Factors "Currently this script only supports fractional factorials for up to 12 factors." ), res == 4, id = Choose( k, "Not for 1 factor", // One factor only does not work "No Res IV", // Two Factors "No Res IV", // 3 Factors 1, // 4 Factors "No Res IV Design for 5 Factors", // 5 Factors 4, // 6 Factors 7, // 7 Factors 6, // 8 Factors 12, // 9 Factors 12, // 10 Factors "Currently this script only supports fractional factorials for up to 12 factors." ), res == 3, id = Choose( k, "Not for 1 factor", // One factor only does not work "There is no Res III Design for 2 factors.", // Two Factors 1, // 3 Factors "There is no Res III Design for 4 factors.", // 4 Factors 1, // 5 Factors 1, // 6 Factors 1, // 7 Factors "There is no Res III Design for 8 factors.", // 8 Factors 2, // 9 Factors 1, // 10 Factors "Currently this script only supports fractional factorials for up to 12 factors." ) ); If( Type( id ) == "String", design << Close Window; Return( id ); , design << Make Design( id ); table = design << Make Table(); design << Close Window; Return( table ); ); ); // Setup the design evaluation for a given design eval.design = Function( {d, x, y}, k = N Col( x ); Current Data Table( d ); // Factor & Response Names xs = x << Get Column Names(); ys = Column( y, "Response Name" ) << Get as matrix; eval = DOE( Evaluate Design, X( Eval( xs ) ), Y( Eval( ys ) ) ); eval; ); // Set the right model for the power calculation set.linear.model = Function( {eval, x, a, ac, s}, k = N Col( x ); // Remove all the interactions from the model for power analysis For( i = 1, i <= k, i++, For( j = i, j <= k, j++, eval << Remove Term( {i, 1}, {j, 1} ); eval << Remove Term( {j, 1}, {i, 1} ); ) ); // Set Parameters for Power Analysis eval << Set Significance Level( a ); eval << Change Anticipated Coefficients( ac ); eval << Set RMSE( s ); eval; ); /** * Core functionallity * * Compare all the different screening designs for choosen factors and responses * */ tables = {}; // Get a list of all open tables. We need a data table that is a distance matrix as input For( i = 1, i <= N Table(), i++, Insert Into( tables, Data Table( i ) ) ); dlg = New Window( "Screening Design Comparison", < Deactivate button. Else = > Close design evaluation window If( Type( frac5 ) == "String", openfrac5 << enable( 0 ), e.frac5 << Close Window ); If( Type( frac4 ) == "String", openfrac4 << enable( 0 ), e.frac4 << Close Window ); If( Type( frac3 ) == "String", openfrac3 << enable( 0 ), e.frac3 << Close Window ); dlg["Full Factorial"] << close; dlg["Definitive Screening"] << close; dlg["Fractional Factorial (Res.5)"] << close; dlg["Fractional Factorial (Res.4)"] << close; dlg["Fractional Factorial (Res.3)"] << close; // Cleanup e.ff << Close window; If(do.dsd, e.dsd << Close window; );