SuperLearnerMacro

Usage details

The sas script containing the SuperLearner macro actually contains 4 main macros: %SuperLearner, %_SuperLearner, %CVSuperLearner macro, and %_CVSuperLearner

0. Installing the macro

Option 1 - run the following two lines in SAS (requires internet connection each SAS session in which super learner is used):
FILENAME slgh URL "https://cirl-unc.github.io/SuperLearnerMacro/super_learner_macro.sas";
%INCLUDE slgh;
Option 2 - install from release version (requires initial internet connection):
  1. Navigate to the release page of the super learner macro here
  2. Download the zip/tar.gz file to your computer and open/unzip the file - you should see a folder called SuperLearnerMacro-XXXX, where XXXX is the release number
  3. Run the following two lines in SAS (replacing appropriate path names):

FILENAME slgh "C:/path/to/SuperLearnerMacro-XXXX/super_learner_macro.sas";
%INCLUDE slgh;

Some examples of using the %SuperLearner macro are available here

1. Using %SuperLearner macro

Stacking is based on what Wolpert refers to as a set of ‘level-0’ models and a ‘level-1’ model, indexed by parameters equation and equation in some study sample S. Where

Level-0: equation

Level-1: equation

The parameterization of the macro is based loosely on this notation. Each level-0 model is referred to as a ‘learner’ in the super learner library. A call to super learner is structured as follows:

%SuperLearner(
 Y=,
 X=,
 library=, 
 indata=, 
 preddata=, 
 outdata=sl_out,
 dist=GAUSSIAN,
 method=NNLS,
 id=,
 by=,
 intvars=,
 binary_predictors=,
 ordinal_predictors=,
 nominal_predictors=,
 continuous_predictors=,
 weight=, 
 trtstrat=false, 
 folds=10 
);

Macro parameters include the following:

2. %_SuperLearner macro

This is a version of the %SuperLearner macro for advanced users that may be somewhat faster due to reduced error checking, and offers finer level controls. If the %SuperLearner macro completes successfully, it will give some example code that can be run with %_SuperLearner. Of note, there is no checking or correction of parameter syntax, so the case-sensitive parameter arguments may cause an error in %_SuperLearner, but not %SuperLearner.

One main difference is that %_SuperLearner will make no guesses about variable types for X, so use of the [coding]_predictors parameters is required for correct specification. See the source code for documentation of additional options.

3. %CVSuperLearner macro

This macro is used to estimate the cross-validated expected loss of super learner itself. It does not produce predictions! This gives an idea about whether super learner is the appropriate learner to use in a given scenario, and allows some choice between parameters of the the super learner model, such as the method (e.g. NNLS vs. CCLS).

Options repeated from %SuperLearner (see definitions given above)

Y, X, binary_predictors, ordinal_predictors, nominal_predictors, continuous_predictors, weight, indata, dist, library, method

4. %_CVSuperLearner macro

This is a version of the %CVSuperLearner macro for advanced users that may be somewhat faster due to reduced error checking, and offers finer level controls. See the source code for further tuning options.

Getting errors?

See the Troubleshooting help

Further reading

About this macro
  1. A. P. Keil. Super Learning in the SAS system. ArXiv e-prints, May 2018. https://arxiv.org/abs/1805.08058
About stacking
  1. D. H. Wolpert. Stacked generalization. Neural networks, 5(2):241–259, 1992.

  2. L. Breiman. Stacked regressions. Machine learning, 24(1):49–64, 1996.

About super learner
  1. M. J. van der Laan, E. C. Polley, and A. E. Hubbard. Super learner. Report, Division of Biostatistics, University of California, Berkeley, 2007.

  2. E. C. Polley and M. J. van der Laan. Super learner in prediction. Report, Division of Biostatistics, University of California, Berkeley, 2010.

Acknowledgements

This work was only possible with valuable advice and beta testing from the following people: Stephen R Cole, Jessie K Edwards, Katie M O'Brien, Eric Polley, Marie Stoner, Jennifer Winston and many others

Super learner macro home page