cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
rtool
Level I

Matched Pair analysis: tabulate the t statistics; multiple Y responses

Hello JMP Community,

 

For context and in case this helps with Google indexing, this is a use case from a proteomic experiment, and the individual "measurements" in the attached example file represents individual peptide measurement.   

 

The Matched Pair analysis already gives me the answer I need (Matched Pairs Analysis (jmp.com)) 

  • Group by "GroupBy"
  • Matching two conditions at a time (e.g. Drug00 vs. Drug01, Drug00 vs. Drug02, Drug00 vs. Drug03)

 

However, since I really just need the two-tailed t test p-value, I currently have to:

  • Go through Analyze >> Specialized Modeling >> Matched Pairs
  • Select two Y columns at a time (e.g. Drug00 and Drug01)
  • by the column GroupBy
  • Wait for output with plots and all the t statistics
  • Make Combined Data Table
  • Sort by Column 4
  • Scroll down to "Prob > |t|"
  • Select all rows with "Prob > |t|" in Column 4
  • Invert select, then delete selected rows

Question 1:

Is there a way to go through JSL or otherwise, to simply tabulate either all the statistical outputs (e.g. Mean Difference, Std Error, Upper/Lower 95%, Prob > |t|), or better yet, just Prob > |t| ?  I don't know how to get started, since unlike the Graph Builder, I can't figure out how to "Save Script".

 

Question 2:

Getting "Question 1" resolved would go a long way for me already, but is there a way to do multiple Matched Pair analysis (i.e. Drug00 vs Drug01, Drug00 vs. Drug02, Drug00 vs. Drug03)?

Analyze >> Screening >> Response Screening seems to be what I'm looking for.  Launch the Response Screening Platform (jmp.com)

  • Drug01, Drug02, and Drug03 as Y, Response
  • Drug00 as X
  • Grouping by GroupBy
  • Checked:  PValues Table on Launch and Paired X and Y

However, it's not clear to me what the PValue column in the output represents.

In addition, the PValue from the Response Screening workflow doesn't correspond to and seem to be smaller than any of the one- or two-tailed p-values I get through the Matched Pair Analysis work flow; the Prob > |t| values from the Matched Pair Analysis workflow seems more reasonable.

 

Thanks for your advice.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

See if this helps you along

txnelson_0-1659662131429.png

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( continuous );

// Start final data table
dtFinal = New Table( "Final", New Column( "Comparison", character ) );

For( i = 2, i <= N Items( colNames ), i++,
	platform = Data Table( "Matched_Pair_by_Group" ) <<
	Matched Pairs(
		invisible,
		SendToByGroup( {:GroupBy == "ProteinA"} ),
		Y( colNames[1], colNames[i] ),
		By( :GroupBy )
	);
	Wait( 0 );

    // Make combined data table
	dtCombined = Report( platform[1] )[Table Box( 1 )] << Make Combined Data Table;
 
    // Close report window
	Report( platform[1] ) << Close Window;

    // Keep only the Prob > |t| rows
	dtCombined << select where( :column 4 != "Prob > |t|" );
	dtCombined << delete rows;
	
	// Add the comparison column
	dtCombined << New Column( "Comparison",
		character,
		set each value( colNames[1] || " vs. " || colNames[i] )
	);

    // Add the data table to the Final data table
	dtFinal << concatenate( dtCombined, Append to first table( 1 ) );

    // Delete the Combined table
	Close( dtCombined, nosave );
);
Jim

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

See if this helps you along

txnelson_0-1659662131429.png

Names Default To Here( 1 );
dt = Current Data Table();

colNames = dt << get column names( continuous );

// Start final data table
dtFinal = New Table( "Final", New Column( "Comparison", character ) );

For( i = 2, i <= N Items( colNames ), i++,
	platform = Data Table( "Matched_Pair_by_Group" ) <<
	Matched Pairs(
		invisible,
		SendToByGroup( {:GroupBy == "ProteinA"} ),
		Y( colNames[1], colNames[i] ),
		By( :GroupBy )
	);
	Wait( 0 );

    // Make combined data table
	dtCombined = Report( platform[1] )[Table Box( 1 )] << Make Combined Data Table;
 
    // Close report window
	Report( platform[1] ) << Close Window;

    // Keep only the Prob > |t| rows
	dtCombined << select where( :column 4 != "Prob > |t|" );
	dtCombined << delete rows;
	
	// Add the comparison column
	dtCombined << New Column( "Comparison",
		character,
		set each value( colNames[1] || " vs. " || colNames[i] )
	);

    // Add the data table to the Final data table
	dtFinal << concatenate( dtCombined, Append to first table( 1 ) );

    // Delete the Combined table
	Close( dtCombined, nosave );
);
Jim
rtool
Level I

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

Tested your script on 133K rows and 10 conditions, and got both Questions resolved.

 

I did have to edit ProteinA, and will take time to learn what that actually does later.

SendToByGroup( {:GroupBy == "ProteinA"} ),

 

Thanks, @txnelson !

txnelson
Super User

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

The ProteinA line is an error.  Just delete the whole line.

Jim
MRB3855
Super User

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

If I am correctly understanding your question, the more complete analysis is a mixed model. You will have three columns in your data set. GroupBy (character, nominal), Drug (character, nominal), and  the peptide measurement (numeric, continuous).  Using the Fit Model platform, Y is your peptide measurement, then put Drug and GroupBy in as Model Effects.  Then, using the "Attributes" pull down triangle, set GroupBy as "Random Effect" (and leave "Unbounded Variance Components" checked, with "Emphasis" set to "Effect Screening").  With the usual assumptions of homoskedasticity etc, this is a generalized version of the Matched Pairs Analysis that extends to two or more groups (drugs in your case). In fact, you can verify this by applying this mixed model with only two of the drugs. The results will be identical to the Matched Pairs results for those two drugs. The benefits of using this mixed model are many. Among them are: More power for each comparison, and all the capability of the fit model platform is at your disposal (multiple comparisons, variance components, etc).

 

Mark        

rtool
Level I

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

Thanks for the suggestion, @MRB3855 .

I'll confess I am not familiar with mixed model or Fit Model.

1) Yes, we can assume homoskedasticity, if you're mean that we expect the same variability regardless of the magnitude of the values under the columns Drug00/Drug01/Drug02/Drug03 (e.g. no need to log transform)

2) I have changed the attribute for "Measurement" to numeric, continuous, but I don't understand the results (attached).

  • Perhaps I wasn't clear: when conducting the Specialized Modeling >> Matched Pairs, we populate the "By" box with the column "GroupBy"  (not "X Grouping").

 

On a related note, could you guide me on which of the Model Types corresponds to the "Matched Pairs" analysis, if that's what you're referring to?  Thanks.

Overview of the Fit Model Platform (jmp.com)

MRB3855
Super User

Re: Matched Pair analysis: tabulate the t statistics; multiple Y responses

Thanks for the detail.  OK...to use the Mixed model as I've described, you must stack the data first. In the end there will be four columns: GroupBy (character, nominal), Measurement (character, nominal), Drug (character, nominal), and the peptide measurement (numeric, continuous). Using the Fit Model platform, Y is your peptide measurement, then put Drug and Measurement in as Model Effects. The put GroupBy as your "By" variable.  Then, using the "Attributes" pull down triangle, set Measurement  as "Random Effect" (and leave "Unbounded Variance Components" checked, with "Emphasis" set to "Effect Screening"). This is a mixed model; it's called mixed because it contains fixed effects (drug) and random effects (Measurement).  It is "simply" a two-way ANOVA model...a mixed two-way ANOVA model.

FWIW, here are some details: https://www.lexjansen.com/pharmasug/2004/Posters/PO05.pdf

Mark