Imported from https://github.com/matt-sutton/bigsgPLS