When you use Distribution() with a list of columns, the report window contains the output from many 'independent' distribution analysis. Each one of those analysis is a separate object. Interacting with those objects can be different than interacting with the report layer in the report window When you do
dist << Normal Quantile Plot(1);
that message is broadcast to all of the distribution objects that are being displayed in the report window. But when you do
distr=Report(dist);
distr["Parameter Estimates"] << Delete;
what JMP does is to go to the first instance of the report layer object that can be referenced using the "Parameter Estimates" string, which in this case is the Outline Box under the Fitted Normal results. To do what you want to do, you would need iterate through each part of the report, get the result for the Shapiro-Wilk test from the report layer, and then decide to delete parts of the output report.
I think in your case it would be easier to iterate the distribution analysis for each column one at a time, appending the results to a new report window. Here is some example code that shows how to do that
// Select variables to analyze
Names Default To Here( 1 );
dt = Current Data Table();
dialog = New Window( "Select Columns",
<<Modal,
Panel Box( "Column Selection",
Lineup Box( N Col( 1 ),
Text Box( "Select columns for distribution" ),
y_col_list = Col List Box( All )
)
),
H List Box(
Button Box( "OK", y_col = y_col_list << Get Selected ),
Button Box( "Cancel" )
)
);
If( dialog["Button"] == -1,
Throw( "User cancelled" )
);
// Create new empty report window
nw = New Window( "Distribution Analysis", hb = H List Box() );
// iterate through each column
For( ii = 1, ii <= N Items( y_col ), ii++,
// Create distribution, display in report window by appending
// to the H List Box
hb << Append(
dist = dt << Distribution( Columns( y_col[ii] ), Histograms Only )
);
// get reference to the report layer for the individual distribution analysis
distr = Report( dist );
// turn on Normal Quantile Plot and add the Normal distribution
// fit with the goodness of fit test
dist << Normal Quantile Plot( 1 );
dist << Fit Distribution( Normal( Goodness of Fit( 1 ) ) );
// instead of deleting the parameter estimates, just close the
// outline box that contains them
distr["Parameter Estimates"]<<Close;
// get the p-value for the shapiro wilks test from the report layer
// CAUTION: the Goodness of Fit test output depends on
// the number of observations and other conditions, so this may not be
// robust to all scenarios
/* the report element that contains the p-value is in the second
Number Col Box in the first Table Box underneath the
"Goodness-of-Fit Test" outline box. Using << get on that report
object returns a list, and use the [1] index to get the first element
of that list*/
swpval = (distr["Goodness-of-Fit Test"][Table Box( 1 )][Number Col Box( 2 )] <<
get)[1];
// check to see if GOF test p value is <0.05 and if so add custom summary stats
If( swpval < 0.05,
dist << Summary Statistics( 1 );
dist << Customize Summary Statistics( Skewness( 1 ), Kurtosis( 1 ) );
);
);