Here's a much more in-depth sample script. Note that this does NOT work!
Names default to here(1);
dt = open( "$SAMPLE_DATA/Body Fat.jmp" );
/////////////////////////// Custom function - Help!
mysim = function( {list, iteration, stddev, step},
// New list placeholder
unique_factors = {};
// Adds only unique factors to new list, uses "*" as identifier
for( i = 1, i <= N items( list ), i++,
if( list[i] << !contains( "*" ) , insert into( unique_factors, list[i] )
)
);
num_sim_factors = N Items( unique_factors );
// Modifies each factor in the simulator to normal distribution with 3 standard deviations
simfactor = {};
for( i = 1, i <= num_sim_factors, i++,
temp_1 = char( unique_factors[i] ) || " << Random( Normal( " || char( col mean( unique_factors[i] ) ) ||
", " || char( stddev * col std dev( unique_factors[i] ) ) || ") ),"
insert into( sim_factor, temp_1 )
);
// Inputs simfactor into simulator
mymodel_sls << Simulator( 1, eval( simfactor ) );
// Creates the arguments for Simulate to table
simtable_pt1 = "N Runs( " || char( iteration ) || "),"
simtable_pt2 = {};
// Creates an argument for each factor
for( i = 1, i <= num_sim_factors, i++,
temp_2 = char( unique_factor[i] ) || " << Sequence Location( " || char ( Col Minimum( unique_factor[i] ) ) || ", "
chart ( Col Maximum( unique_factor[i] ) ) || ", " || char( step ) || " ),";
insert into( simtable_pt2, temp_2 )
);
// Combines strings into a single argument for use for Simulate to Table
simarg = simtable_pt1 || simtable_pt2;
// Simuates data to table for further analysis
mymodel_sls << Get simulator;
mymodel_sls << Simulate to table( simarg );
);
/////////////////////////// Cols to use - user adjustable
predict = {:"Neck circumference (cm)"n, :"Chest circumference (cm)"n,
:"Abdomen circumference (cm)"n, :"Hip circumference (cm)"n,
:"Thigh circumference (cm)"n, :"Knee circumference (cm)"n,
:"Ankle circumference (cm)"n, :"Biceps (extended) circumference (cm)"n,
:"Forearm circumference (cm)"n, :"Wrist circumference (cm)"n};
response = {:"Age (years)"n, :"Weight (lbs)"n, :"Height (inches)"n};
/////////////////////////// User input
num_response = N Items( response );
num_predict = N Items( predict );
// How many simulations to run?
sim_no = 1000;
// How many standard deviations for each predictor in the simulation?
stddev = 3;
// Steps in simulation
steps = 4;
/////////////////////////// Changing col attribute
// In a later step, Simulate, the mean should be 0 due to this
for( i = 1, i <= num_response, i++,
response[i] << Set Property( "Coding", { col minimum( response[i] ), col maximum( response[i] ) } );
);
/////////////////////////// Modeling
/* Fit Model - Stepwise, w/ K-fold validation --> SLS --> Simulate */
for( i = 1, i <= num_response, i++,
// Names models for calling later
mymodel_sw = "FM_SW_" || char( i );
// Iterating through responses - JMP 17
mymodel_sw = Fit Model( Y( response[i] ),
Effects( Factorial to degree( eval( predict ) ), Response Surface( eval( predict ) ) ),
Personality("Stepwise"),
Run( "K-Fold Crossvalidation"n(5) )
);
// Runs modeling
mymodel_sw << Go;
// Finishes predictor selection before proceeding
mymodel_sw << Finish;
// Makes model
mymodel_sls = mymodel_sw << Make Model;
// Runs SLS model
mymodel_sls << Run;
// Finishes modeling before proceeding
mymodel_sls << Finish;
////////////////// NOT WORKING BELOW
// Gets list of predictors <--- This is first step
param_sls1 = mymodel_sls << Get Effect Names;
param_sls2 = mymodel_sls << Get Parameter Names;
show(param_sls1, param_sls2);
// Calls on custom function <--- This is second step
mysim( param_sls1, sim_no, stddev, steps );
// Names Simulate to table dataset by response variable in for loop
Current data table() << Set name( char( response[i] ) || "_report" );
);
Help! There are multiple parts of this not working! Here is what's working - Comment out the custom function and anything below (near the bottom of the script) where is states NOT WORKING BELOW. I can get through the generation of the SLS modeling, but once it comes to modifying the simulate parameters and running the simulate, both of which are customized (see custom function), I'm out of ideas.
Learning every day!