Col Shuffle
Col Shuffle using For
Example 1
Summary: Creates a list
testVarby iterating through variables inxlist, inserting specific values and shuffling columns based on conditions.
Code:
xlist = {"age", "height", "weight", "sex"};
testVar = [];
For( i = 1, i <= N Items( xlist ), i++,
If( i == 3,
dt = Open("data_table.jmp");
Row() = 1;
);
Match( xlist[i],
xlist[1], Insert Into( testVar, Eval List( {i, Row()} ) ),
xlist[2], Insert Into( testVar, Eval List( {i, Row()} ) ),
xlist[3],
Insert Into( testVar, Eval List( {i, Row()} ) );
testVar2 = Col Shuffle();,
xlist[4], Insert Into( testVar, Eval List( {i, Row()} ) ),
Insert Into( testVar, Eval List( {i, Row(), "error"} ) )
);
);
Code Explanation:
- Initialize
xlistwith variables. - Initialize empty list
testVar. - Loop through
xlistitems. - Check if index
iequals 3. - Open data table;
- Set row to 1.
- Match current
xlistitem. - For "age", insert index and row into
testVar. - For "height", insert index and row into
testVar. - For "weight", insert index and row into
testVar, shuffle column.
Example 2
Summary: Runs data manipulation and filtering for specified variables in a JMP data table, utilizing a For loop to iterate over the list of variables.
Code:
xlist = {"age", "height", "weight", "sex"};
testVar = [];
For( i = 1, i <= N Items( xlist ), i++,
If( i == 3,
dt = Open("data_table.jmp");
Row() = 1;
);
MatchMZ( xlist[i],
xlist[1], Insert Into( testVar, Eval List( {i, Row()} ) ),
xlist[2], Insert Into( testVar, Eval List( {i, Row()} ) ),
xlist[3],
Insert Into( testVar, Eval List( {i, Row()} ) );
testVar2 = Col Shuffle();,
xlist[4], Insert Into( testVar, Eval List( {i, Row()} ) ),
Insert Into( testVar, Eval List( {i, Row(), "error"} ) )
);
);
Code Explanation:
- Define variable
xlist. - Initialize empty list
testVar. - Start loop over
xlist. - Check if index
iis 3. - Open data table;
- Set row pointer to 1.
- Match current item in
xlist. - For "age" or "height", insert index and row into
testVar. - For "weight", insert index and row into
testVar. - Shuffle column data into
testVar2.
Example 3
Summary: Matches and inserts data from a specified table into an empty list, utilizing a For loop to iterate through the xlist items.
Code:
xlist = {"age", "height", "weight", "sex"};
testVar = [];
For( i = 1, i <= N Items( xlist ), i++,
If( i == 3,
dt = Open("data_table.jmp");
Row() = 1;
);
MatchV3( xlist[i],
xlist[1], Insert Into( testVar, Eval List( {i, Row()} ) ),
xlist[2], Insert Into( testVar, Eval List( {i, Row()} ) ),
xlist[3],
Insert Into( testVar, Eval List( {i, Row()} ) );
testVar2 = Col Shuffle();,
xlist[4], Insert Into( testVar, Eval List( {i, Row()} ) ),
Insert Into( testVar, Eval List( {i, Row(), "error"} ) )
);
);
Code Explanation:
- Initialize variable
xlist. - Initialize empty list
testVar. - Loop through
xlistitems. - Check if index
iequals 3. - Open data table;
- Set row to 1.
- Match current
xlistitem. - For
age, insert index and row intotestVar. - For
height, insert index and row intotestVar. - For
weight, insert index and row intotestVar; shuffle column.
Col Shuffle using New Column
Summary: Fits a parametric survival model with multiple effects and generates a profiler plot, utilizing data table manipulation and script execution in JMP.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Censor Shuffle", Formula( Col Stored Value( :Censor, Col Shuffle() ) ) );
dt << New Column( "Hours Shuffle", Formula( Col Stored Value( :Hours, Col Shuffle() ) ) );
Column( dt, "Censor Shuffle" ) << Suppress Eval;
Column( dt, "Hours Shuffle" ) << Suppress Eval;
FPS = dt << Run Script( "Fit Parametric Survival" );
rpt = Report( FPS );
ChiSqval = rpt["Whole Model Test"][1][3];
new_log = Collapse Whitespace( Log Capture( ChiSqval << Simulate( toSim, Out( :Hours ), In( :Hours Shuffle ) ) ) );
oracle_log = "Unable to perform simulation. The Column to Switch In (Hours Shuffle) must not have evaluation suppressed.";
FPS << close window;
Code Explanation:
- Open data table.
- Create new column for shuffled censor data.
- Create new column for shuffled hours data.
- Suppress evaluation on shuffled censor column.
- Suppress evaluation on shuffled hours column.
- Run parametric survival fit script.
- Retrieve report from fit script.
- Extract chi-square value from report.
- Capture log output from chi-square simulation.
- Compare captured log to expected error message.