Matched Pairs
Example 1
Summary: Calculates a paired t-test using the Matched Pairs platform to compare the 'Awake' and 'Asleep' response variables in a data table, with reference frame 1.
Code:
// paired t-test
// Open data table
dt = Open("data_table.jmp");
// paired t-test
(
Matched Pairs(
y( Awake, Asleep ),
Reference Frame( 1 )
) << report)[AxisBox( 1 )] << Revert Axis;
Code Explanation:
- Open data table;
- Perform paired t-test.
- Set response variables: Awake, Asleep.
- Use reference frame 1.
- Generate report.
- Access AxisBox 1.
- Revert axis settings.
Example 2
Summary: Calculates a paired t-test using the Matched Pairs platform to compare BP AM and BP PM values, with reference frame set to 1.
Code:
// paired t-test
// Open data table
dt = Open("data_table.jmp");
// paired t-test
(
Matched Pairs(
y( BP AM, BP PM ),
Reference Frame( 1 )
) << report)[AxisBox( 1 )] << Revert Axis;
Code Explanation:
- Open data table.
- Perform paired t-test.
- Match pairs of BP AM and BP PM.
- Set reference frame to 1.
- Extract report from analysis.
- Access first axis box.
- Revert axis settings.
Example 3
Summary: Performs a paired t-test using the Matched Pairs function in JMP, analyzing the relationship between two response variables (:LogHist0 and :LogHist1) from an open data table.
Code:
// Matched Pairs
// Open data table
dt = Open("data_table.jmp");
// Matched Pairs
Matched Pairs(
Y( :LogHist0, :LogHist1 )
);
Code Explanation:
- Open data table.
- Define variable
dt. - Use
Matched Pairsfunction. - Specify response variables
:LogHist0and:LogHist1.
Example 4
Summary: Runs a matched pairs analysis to compare the log histograms of two variables, with customized formatting for difference scale boxes and additional rules.
Code:
dt = Open("data_table.jmp");
Matched Pairs(
Y( :LogHist0, :LogHist1 ),
Plot Dif By Row( 1 ),
Reference Frame( 1 ),
Wilcoxon Signed Rank( 1 ),
SendToReport(
Dispatch( {"Difference: LogHist1-LogHist0"}, "1", ScaleBox,
{Format( "Custom", Formula( If( Starts With( Char( value ), "-" ), -Abs( value ), Abs( value ) ) ), 12 )}
),
Dispatch( {"Difference: LogHist1-LogHist0"}, "2", ScaleBox,
{Format( "Custom", Formula( If( Starts With( Char( value ), "-" ), "neg", "non-neg" ) ), 12 )}
),
Dispatch( {"Difference: LogHist1-LogHist0"}, "1", ScaleBox( 2 ), {Format( "Custom", Formula( Modulo( value, 4 ) * 5 ), 12 )} ),
Dispatch( {"Difference: LogHist1-LogHist0"}, "2", ScaleBox( 2 ),
{Format( "Custom", Formula( If( Starts With( Char( value ), "-" ), "neg", "non-neg" ) ), 12 )}
)
)
);
Code Explanation:
- Open data table.
- Perform matched pairs analysis.
- Set Y variables.
- Plot differences by row.
- Use reference frame.
- Apply Wilcoxon signed rank test.
- Format difference scale box.
- Customize positive/negative labels.
- Format second scale box.
- Apply additional formatting rules.
Example 5
Summary: Runs a Matched Pairs analysis to compare the difference between 'BP 8M' and 'BP 8W' variables, while controlling for 'Dose', using Bland Altman percent analysis.
Code:
dt = Open("data_table.jmp");
obj = dt << Matched Pairs(
X( :Dose ),
Y( :BP 8M, :BP 8W ),
Reference Frame( 1 ),
Percent Dif Statistics( 1 ),
Plot Percent Dif by Mean( 1 ),
Plot Percent Dif by Row( 1 ),
Bland Altman Percent Analysis( 1 ),
Bland Altman Analysis( 1 )
);
Code Explanation:
- Open data table;
- Create Matched Pairs analysis.
- Set X variable to "Dose".
- Set Y variables to "BP 8M", "BP 8W".
- Use first reference frame.
- Calculate percent difference statistics.
- Plot percent difference by mean.
- Plot percent difference by row.
- Perform Bland Altman percent analysis.
- Perform Bland Altman analysis.
Example 6
Summary: Runs a Matched Pairs analysis to compare LogHist0 and LogHist1, with plots of difference by mean and row, and Wilcoxon Signed Rank and Sign tests.
Code:
dt under test = Open("data_table.jmp");
obj = Matched Pairs(
Y( :LogHist0, :LogHist1 ),
Plot Dif By Mean( 0 ),
Plot Dif By Row( 1 ),
Reference Frame( 0 ),
Wilcoxon Signed Rank( 1 ),
Sign Test( 1 ),
SendToReport( Dispatch( {}, "Matched Pairs", OutlineBox, {Set Title( "Plot Dif by Row, Wilcoxon Signed Rank, Sign Test" )} ) )
);
Code Explanation:
- Open data table;
- Perform Matched Pairs analysis.
- Set Y variables to LogHist0, LogHist1.
- Plot difference by mean.
- Plot difference by row.
- Use reference frame 0.
- Enable Wilcoxon Signed Rank test.
- Enable Sign test.
- Send report to window.
- Set title for report.
Example 7
Summary: Runs a matched pairs analysis to compare the log-histograms of two variables, utilizing the Matched Pairs platform in JMP.
Code:
dt under test = Open("data_table.jmp");
obj = Matched Pairs( Y( :LogHist0, :LogHist1 ) );
Code Explanation:
- Open data table.
- Perform matched pairs analysis.
Example 8
Summary: Runs a matched pairs analysis to compare the difference between Crude Death Rate and Crude Birth Rate, plotting the result by row using the first reference frame.
Code:
Open("data_table.jmp");
Matched Pairs( Y( :"Crude Death Rate (1000)"n, :"Crude Birth Rate (1000)"n ), Plot Dif By Row( 1 ), Reference Frame( 1 ) );
Code Explanation:
- Open data table.
- Perform matched pairs analysis.
- Select death and birth rates.
- Plot difference by row.
- Use first reference frame.
Example 9
Summary: Runs a matched pairs analysis to compare the relationship between height and weight, sending the report to display with a customized title.
Code:
dt under test = Open("data_table.jmp");
obj = Matched Pairs(
Y( :height, :weight ),
Reference Frame( 1 ),
SendToReport(
Dispatch( {}, "Matched Pairs", OutlineBox,
{Set Title( "Matched Pairs - Testing, look for table layout correct and not discolored" )}
)
)
);
Code Explanation:
- Open data table;
- Create matched pairs analysis.
- Set Y variables: height, weight.
- Use reference frame 1.
- Send report to display.
- Set title for matched pairs outline box.
- Title content: "Matched Pairs - Testing, look for table layout correct and not discolored".
Example 10
Summary: Runs a paired t-test analysis using the Matched Pairs platform, filtering data and generating a report.
Code:
dt = Open("data_table.jmp");
obj = Matched Pairs( Y( :LogHist0, :LogHist1 ), Reference Frame( 1 ), );
obj << Local Data Filter(
Location( {734, 143} ),
Add Filter( columns( :dep1 ), Where( :dep1 == "n" ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
);
dt << Select Where( :drug == "morphine" );
dt << Exclude();
rep = Report( obj );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Matched Pairs( Y( :LogHist0, :LogHist1 ), Reference Frame( 1 ), );
obj << Local Data Filter(
Location( {734, 143} ),
Add Filter( columns( :dep1 ), Where( :dep1 == "n" ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
);
obj << Automatic Recalc( 0 );
dt << Select Where( :drug == "morphine" );
dt << Exclude();
rep = Report( obj );
Code Explanation:
- Open data table;
- Create Matched Pairs analysis.
- Add Local Data Filter at location {734, 143}.
- Filter column :dep1 where value equals "n".
- Set filter mode to Select 0, Show 1, Include 1.
- Select rows where :drug equals "morphine".
- Exclude selected rows.
- Generate report from analysis.
- Close "data_table.jmp" without saving.
- Reopen data_table dataset
Example 11
Summary: Runs a paired t-test analysis using the Matched Pairs platform in JMP, generating a report and extracting numerical results.
Code:
dt = Open("data_table.jmp");
obj = Matched Pairs( Y( :LogHist0, :LogHist1 ), Plot Dif By Row( 1 ), Reference Frame( 1 ), Wilcoxon Signed Rank( 1 ) );
:LogHist0 << Set Property( "Missing Value Codes", 0 );
:LogHist1 << Set Property( "Missing Value Codes", 0 );
:diff << Set Property( "Missing Value Codes", 0 );
:hist0 << Set Values( [1] );
:hist1 << Set Values( [1] );
obj2 = obj << Redo Analysis;
rpt = obj2 << Report;
actN = (rpt[Number Col Box( 1 )] << get( 7 ));
Code Explanation:
- Open data table.
- Perform matched pairs analysis.
- Set missing value codes to 0 for LogHist0.
- Set missing value codes to 0 for LogHist1.
- Set missing value codes to 0 for diff.
- Assign value 1 to hist0.
- Assign value 1 to hist1.
- Redo the analysis.
- Generate report from analysis.
- Extract number from report.
Example 12
Summary: Runs a matched pairs analysis with Bland Altman, Sign Test, and Wilcoxon Signed Rank tests to compare log-histogram values across different sleep states.
Code:
dt = Open("data_table.jmp");
obj = dt << Matched Pairs(
Y( :LogHist0, :LogHist1, :LogHist3, :LogHist5 ),
Separate Pairs( 0 ),
Bland Altman Analysis( 1 ),
Sign Test( 1 ),
Wilcoxon Signed Rank( 1 )
);
rpt = Report( obj );
obj2 = obj << redo analysis;
rpt2 = Report( obj2 );
Code Explanation:
- Open table.
- Define matched pairs analysis.
- Set separate pairs to 0.
- Enable Bland Altman analysis.
- Enable sign test.
- Enable Wilcoxon signed rank.
- Generate initial report.
- Redo analysis.
- Generate second report.
Example 13
Summary: Runs a matched pairs analysis to compare the Wilcoxon signed rank test results for 'LogHist0' and 'LogHist1' variables, given a reference frame of 1.
Code:
dt2 = Open("data_table.jmp");
mp = Matched Pairs( X( :drug ), Y( :LogHist0, :LogHist1 ), Reference Frame( 1 ), Wilcoxon Signed Rank( 1 ) );
rep = Report( mp );
Code Explanation:
- Open data table;
- Perform matched pairs analysis.
- Set X variable as "drug".
- Set Y variables as "LogHist0", "LogHist1".
- Use reference frame 1.
- Enable Wilcoxon signed rank test.
- Generate report object.
Example 14
Summary: Runs a paired t-test analysis using the Matched Pairs platform to compare 'Post' and 'Pre' values, generating a report of the results.
Code:
dt3 = Open("data_table.jmp");
mp = Matched Pairs( Y( :BP 8M, :BP 12M ) );
rep = Report( mp );
Close( dt3, No Save );
dt = New Table( "S0295117",
Add Rows( 25 ),
New Column( "Post", Numeric, Continuous, Set Values( J( 25, 1, 1 ) ) ),
New Column( "Pre", Numeric, Continuous, Set Values( J( 25, 1, 1 ) ) )
);
dt:Pre[7] = .;
dt:Pre[18] = .;
dt:Pre[21] = .;
dt:Pre[25] = .;
mp = Matched Pairs( Y( :Post, :Pre ), Reference Frame( 0 ) );
rep = Report( mp );
Code Explanation:
- Open data table;
- Perform matched pairs analysis.
- Generate report from analysis.
- Close dataset without saving.
- Create new table "S0295117".
- Add 25 rows to table.
- Add "Post" column with numeric values.
- Add "Pre" column with numeric values.
- Set missing values in "Pre" column.
- Perform matched pairs analysis on new data.
Example 15
Summary: Runs a matched pairs analysis to compare BP 8M and BP 12M, generating a report with the results.
Code:
dt3 = Open("data_table.jmp");
mp = Matched Pairs( Y( :BP 8M, :BP 12M ) );
rep = Report( mp );
Code Explanation:
- Open data table;
- Create matched pairs analysis.
- Specify BP 8M as response.
- Specify BP 12M as response.
- Generate matched pairs report.
Example 16
Summary: Creates and configures two matched pairs analyses to compare log-histogram data, utilizing separate pairs and reference frames.
Code:
dt = Open("data_table.jmp");
mp = Matched Pairs( Y( :LogHist0, :LogHist1, :LogHist3, :LogHist5 ), Separate Pairs( 0 ), Reference Frame( 0 ) );
mp << close window;
mp2 = Matched Pairs( Y( :LogHist0, :LogHist1, :LogHist3, :LogHist5 ), Separate Pairs( 1 ), Reference Frame( 0 ) );
Code Explanation:
- Open data table.
- Create matched pairs analysis.
- Set separate pairs to 0.
- Set reference frame to 0.
- Close matched pairs window.
- Create second matched pairs analysis.
- Set separate pairs to 1.
- Set reference frame to 0.
Matched Pairs using Interactive HTML Color
Summary: Runs a series of matched pairs analyses with interactive HTML color changes, utilizing JMP's data table and preferences settings.
Code:
Preferences[1] << Set( Interactive HTML Color( "Dark Background" ) );
Open("data_table.jmp");
Matched Pairs( Y( :"Crude Death Rate (1000)"n, :"Crude Birth Rate (1000)"n ), Reference Frame( 1 ) );
Preferences[1] << Set( Interactive HTML Color( "Gray Background" ) );
Matched Pairs( Y( :"Crude Death Rate (1000)"n, :"Crude Birth Rate (1000)"n ), Reference Frame( 1 ) );
Preferences[1] << Set( Interactive HTML Color( "Light Background" ) );
Matched Pairs( Y( :"Crude Death Rate (1000)"n, :"Crude Birth Rate (1000)"n ), Reference Frame( 1 ) );
Code Explanation:
- Set interactive HTML color.
- Open data table.
- Perform matched pairs analysis.
- Change interactive HTML color.
- Repeat matched pairs analysis.
- Change interactive HTML color.
- Repeat matched pairs analysis.
Matched Pairs using For
Summary: Generates a Bland-Altman analysis for continuous variables in a specified data table, calculating percentage differences and statistical metrics.
Code:
dt = Open("data_table.jmp");
x = dt:BP 8W << get values();
y = dt:BP 8M << get values();
diff_perc = [];
For( i = 1, i <= N Items( x ), i++,
diff_perc = diff_perc || 100 * (x[i] - y[i]) * 2 / (x[i] + y[i])
);
mean_diff_perc = Mean( diff_perc );
se_diff_perc = Std Dev( diff_perc / Sqrt( N Items( x ) ) );
t_stat = mean_diff_perc / se_diff_perc;
b_Perc_Diff_Stat = Matrix( {mean_diff_perc, se_diff_perc, t_stat} );
Lower = mean_diff_perc + Normal Quantile( 0.025 ) * Std Dev( diff_perc );
Upper = mean_diff_perc + Normal Quantile( 0.975 ) * Std Dev( diff_perc );
b_BA_Perc_Anal = Matrix( {mean_diff_perc, Lower, Upper} );
obj = dt << Matched Pairs(
X( :Dose ),
Y( :BP 8M, :BP 8W ),
Reference Frame( 1 ),
Percent Dif Statistics( 1 ),
Plot Percent Dif by Mean( 1 ),
Plot Percent Dif by Row( 1 ),
Bland Altman Percent Analysis( 1 ),
Bland Altman Analysis( 1 )
);
rpt = Report( obj );
Perc_Diff_table = rpt["Difference: BP 8W-BP 8M", Table Box( 2 )] << get as matrix;
Perc_Diff_Stat = Matrix( {Perc_Diff_table[3, 1], Perc_Diff_table[4, 1], Perc_Diff_table[1, 2]} );
BA_perc_table = rpt["Bland-Altman Percent Analysis", Table Box( 1 )] << get as matrix;
BA_Perc_Anal = BA_perc_table[0, 1];
Code Explanation:
- Open data_table data
- Extract BP 8W values.
- Extract BP 8M values.
- Initialize diff_perc list.
- Calculate percentage differences.
- Compute mean difference percentage.
- Calculate standard error of difference.
- Compute t-statistic.
- Store percentage difference statistics.
- Calculate confidence interval limits.