File Exchange

image thumbnail

MatSurv

version 1.1.01 (1.56 MB) by Anders
Survival analysis in MATLAB

12 Downloads

Updated 13 Feb 2020

GitHub view license on GitHub

MatSurv is a simple survival analysis function for MATLAB (version 2016b and later) that creates a KM-plot with risk table. Survival statistics, such as log rank p-value and Hazard Ration (HR) is also calculated. The log rank test has been tested to give the same results as SAS and R. The style of the KM-plot is easily changed with input parameters. No additional toolboxes are needed. MatSurv was inspired by the survminer R-package (https://github.com/kassambara/survminer).
More examples can be found at: https://github.com/aebergl/MatSurv

Cite As

Creed, Jordan, et al. “MatSurv: Survival Analysis and Visualization in MATLAB.” Journal of Open Source Software, vol. 5, no. 46, The Open Journal, Feb. 2020, p. 1830, doi:10.21105/joss.01830.

View more styles

Comments and Ratings (14)

Anders

@Jordan
Please use the Cite As above for now. Working on a real publication.

This is great! If I'm going to use this package if a peer reviewed journal article how should I cite it?

Anders

@Hila
Thanks for your comment.
I don't use the chi2cdf function since it a part of the Statistics and Machine Learning Toolbox but gammainc has the same option. Will update the code

Also, better to use:
p = chi2cdf(chi2, nu, 'upper')

xinyi zhu

It worked perfectly on R2017a, the painting is wonderful!
Thank you very much!

xinyi zhu

Thank you for your reply.
I will try it on R2017a. Thanks a lot.

Anders

Hi again.
it seems like that it runs perfect on 9.1.0.441655 (R2016b) and later versions but I get some strange Y-axis with 9.0.0.341360 (R2016a) but it does not crash.
Will see if I can make it more back-wards compatible but I can't promise anything.

xinyi zhu

my version is 2015

Anders

Hello,
I just tried the following and it works for me
load laml_RC_data.mat
[p,fh,stats]=MatSurv(laml_RC_TimeVar, laml_RC_EventVar, laml_RC_GroupVar,...
'GroupsToUse', {'Good','Intermediate','Poor'},'Xstep',24);

What version of MATLAB are you running?

xinyi zhu

There was a problem in this package.
when I ran the ('laml_RC_data.mat') example, matlab showed an error in using axes and there was a mistake in line 272.
I hope you to fix this problem, thank you.

Updates

1.1.01

Fixed description text

1.1

Added JOSS paper and DOI information

1.0.4.3

Additional error checking including minimum number of samples per group and if there is more than one group with zero events. Also added support for multilevel GroupsToUse input in order to merge groups

1.0.4.2

Added an option so the risk table can be placed in the KM-plot (RT_KMplot)

1.0.4.1

Fixed bug in print option

1.0.4

Fixed the HR calculations when there are multiple groups

1.0.3

Small update of functionality

1.0.2

Updated Cite As

1.0.1

Updated stats structure and included Mantel-Haenszel Hazard Ratio

1.0.0.0

Fixed bug where it crashed if there was only 1 group member.

1.0.0.0

Updated CutPoint option to include Tertile

1.0.0.0

Fixed a bug where median survival time was not calculated with the NoPlot option

1.0.0.0

Changed median cut to x < median by default and added an option to change it to x > median. Only affect the results if there is an odd number of samples.

1.0.0.0

Updated MATLAB version requirement

1.0.0.0

Updated GitHub example figures to match current default settings

1.0.0.0

Updated LineColor options, median survival time is now calculated and option to print results to the screen

1.0.0.0

Updated the description

MATLAB Release Compatibility
Created with R2017a
Compatible with R2016b to R2019b
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: KMplot, Logrank