cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
doraemengs
Level III

Risk Table of KM plot on JMP?

According to https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/m-p/55338/high... , Could you please provide the method for generating a risk table underneath the KM plot? I tried to follow the script from the comment but it was closed to be solved. 

dt = Current Data Table ();
minT = 0;
maxT = 25;
stepT = 1;

Summarize( lv = by( :group) );
obj = Survival(
	Y( :time ),
	Censor( :"reject"n ),
	Grouping( :group ),
	Failure Plot( 0 ),
	SendToReport(
		Dispatch(
			{"Survival Plot"},
			"1",
			ScaleBox,
			{Min( 0 ), Max( 25 ), Inc( 1 ), Minor Ticks( 1 )}
		),
		Dispatch(
			{"Survival Plot"},
			"time",
			TextEditBox,
			{Set Text( "Times(years)" )}
		)
	)
) << report;
obj[List Box( 2 )] << append( Table Box( String Col Box( "No at Risk | Year", lv ) ) );
Tab1 = (obj[lv[1]][Table Box( 1 )] << get);
Tab2 = (obj[lv[2]][Table Box( 1 )] << get);
For( T = minT, T <= maxT, T += stepT,
	lp = Max( Loc( Matrix( Tab1 [years] ) <= T ) );
	AR1 = Tab1["At Risk"][lp];
	lp = Max( Loc( Matrix( Tab2 [years]) <= T ) );
	AR2 = Tab2["At Risk"][lp];
	obj[List Box( 2 )][Table Box( 1 )] << append( Number Col Box( Char( T ), {AR1, AR2} ) );
);

the out put showed as the attachment picture. Could you please to correct the script?

 

Thank you

11 REPLIES 11

Re: Risk Table of KM plot on JMP?

following up on the "inflated" at risk number.  Using your script (thanks!) on the VP Lung cancer dataset, I get 1 additional at risk numbers for 400 for the standard group and 200, 400, 600, 800 for test test group.  

jkarcusbiojmpco_0-1752869954880.png

looking at the data table, values with exact timepoint (200 for standard - first pink row) shows correct at risk number, however for when there is not an exact match, such as 400, 600 and 800) current script is brining in the number before the specified time point. it would be great if scripting can fix these cases.  

jkarcusbiojmpco_1-1752870291733.png

jkarcusbiojmpco_2-1752870542512.png

 

jthi
Super User

Re: Risk Table of KM plot on JMP?

What it should display if not the earlier value?

-Jarmo

Recommended Articles