Monte Carlo simulation for an analysis (stepwise regression) platformI have an analysis which uses several columns that have random elements in them. I know how to manually update the random numbers that are in the columns and I understand how to conduct a simulation for the output of an analysis. But in this case, I am wanting to run a stepwise regression each time the random numbers in the columns are updated. I want to do this at least 1000 times. I don't know how to automate this process: generate new random numbers in formula columns, rerun the stepwise regression platform run the chosen model and collect the results.
AnalyticsRe: Monte Carlo simulation for an analysis (stepwise regression) platformLet me be more specific in case any of the generous scripters out there can help. I've attached a smaller version of what I am trying to do. I have 10 columns (all starting with Column 2) in the attached file that involve a random normal distribution and the first column Y, that uses 5 columns labeled parameter 1 through 5, and one random normal distribution in the formula. I wish to conduct the following steps:
1. Run the stepwise regression stored in the file. I don't need to make or run the model, I only need to execute the Go button that runs the stepwise procedure after Run from the Fit Model platform.
2. Record how often each of the 10 columns that begin with Column 2 are selected by the stepwise procedure. (I don't know how to script collecting that particular information)
3. Rerun the formula for the 5 parameter columns so that they contain a new set of simulated values. I know this can be done with the Rerun formula command found at the red arrow at the top left of the table (but I don't know how to script that).
4. Repeat Steps 1 and 2. (I believe this can be done via a simple loop)
5. Do this 1000 times and show the distributions for the number of times each of the 10 Column 2 columns were selected in the stepwise procedure.
I believe all this can be scripted but it is far beyond anything I am able to do. If anyone can be of assistance, I'd appreciate that. I am willing to coauthor a paper with someone as I have an outlet in mind for this.
Re: Monte Carlo simulation for an analysis (stepwise regression) platformI have mostly solved my problem - but still have a question. Attached is a small script that executes the stepwise regression as I want. But to generate 1000 samples, I needed to create a "sample" column and use that as a "By" variable in the analysis. This works, but is a cumbersome way to do simulation, since I need to make the file very long - e.g., for 1000 samples of 1000 observations each, I need 1,000,000 rows. Does anyone know a more efficient way to conduct a simulation? As far as I can tell, the "simulate" option that accompanies many JMP platforms can only simulate certain analysis results but not the analysis itself.
Re: Monte Carlo simulation for an analysis (stepwise regression) platformWhat you have laid out in the previous post is a good plan. I would do that, too. I will try to give some recommendations.
- If you are new to scripting in JMP, a starting point is Scripting Guide . Some important pieces, in this specific task, might be:
- Besides that, you need to be familiar with Scripting Index under Help menu. There are 3 groups of scripting objects: Functions, Objects, and Display boxes. There is a combo box on the top left, and you can narrow down to a specific group.
- For this specific task, you may need to check out the Objects group. All platforms, including data table, are listed here. You may want to check out the "Fit Stepwise" item under "Fit Model" object.Click "Fit Stepwise", and look to the right for a "Finish" message among "Item Messages". That might be the key missing piece to you now.
- For this specific task, you also need to learn how to manipulate data tables. Concatenation, in particular, maybe. Go to the Objects list, click "Data Table", and look to the right for "Concatenate" among Item Messages.
Besides the above, here are other helpful tips that I learned from my colleagues.
- Post smaller, specific, questions to the discussion board, whenever possible. It will be more likely to generate help.
- Prefer screenshots to attachments. For JSL codes, you can insert them directly in the post, so readers can see. Look for the button in the toolbar when you edit a post. It will be more likely to generate help, too. E.g. it is unlikely that a reader on a mobile device will open an attachment.

Re: Monte Carlo simulation for an analysis (stepwise regression) platformHi dale_lehman
My idea is get and save the result from 'stepwise' platform in folder. Then 'Multiple File Import' whole result as one file.
At last, row clean by 'P value' and distribut as your want. Detail JSL as below:
Clear Globals();
Clear Log();
Names Default To Here( 1 );
//Define path in and out
Path_in = Pick File( "Select file" );
If( Directory Exists( "$Desktop\Fit_Stepwise" ),
,
Create Directory( "$Desktop\Fit_Stepwise" )
);
Path_out = "$Desktop\Fit_Stepwise\";
//Run Fit model and stepwise after open datatable
dt = Open( Path_in );
For( i = 1, i <= 1000, i++,
ow = dt << Fit Model(
Y( :Y ),
Effects(
:Column 2 001,
:Column 2 002,
:Column 2 003,
:Column 2 004,
:Column 2 005,
:Column 2 006,
:Column 2 007,
:Column 2 008,
:Column 2 009,
:Column 2 010
),
Personality( "Stepwise" ),
Run,
SendToReport( Dispatch( {}, "Step History", OutlineBox, {Close( 1 )} ) )
);
dt_result = Report( ow )[Outline Box( "Stepwise Fit for Y" )][Outline Box( "Current Estimates" )][Table Box( 1 )] << Make Into Data Table;
dt_result << save( Path_out || Char( i ) || ".csv", "csv" );
ow << close window;
dt_result << Close Window;
);
dt << Close Window;
dt_result = Multiple File Import(
<<SET folder="">F\!"" ) > 0.05 ) ) << Delete Rows;
dt_result << Distribution( Stack( 1 ), Nominal Distribution( Column( :Parameter ), Horizontal Layout( 1 ), Vertical( 0 ) ) );</SET>