{"id":26974350,"url":"https://github.com/hofnerb/stabs","last_synced_at":"2025-08-11T21:44:25.324Z","repository":{"id":23888212,"uuid":"27267518","full_name":"hofnerb/stabs","owner":"hofnerb","description":"Stability Selection with Error Control","archived":false,"fork":false,"pushed_at":"2021-01-28T09:57:29.000Z","size":840,"stargazers_count":26,"open_issues_count":11,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T10:40:08.945Z","etag":null,"topics":["cran","machine-learning","r-language","r-package","resampling","stability-selection","variable-importance","variable-selection"],"latest_commit_sha":null,"homepage":"https://cran.r-project.org/package=stabs","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hofnerb.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-28T13:11:42.000Z","updated_at":"2024-08-15T20:41:07.000Z","dependencies_parsed_at":"2022-08-17T22:35:11.156Z","dependency_job_id":null,"html_url":"https://github.com/hofnerb/stabs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hofnerb/stabs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hofnerb%2Fstabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hofnerb%2Fstabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hofnerb%2Fstabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hofnerb%2Fstabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hofnerb","download_url":"https://codeload.github.com/hofnerb/stabs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hofnerb%2Fstabs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269963090,"owners_count":24504298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran","machine-learning","r-language","r-package","resampling","stability-selection","variable-importance","variable-selection"],"created_at":"2025-04-03T10:35:48.560Z","updated_at":"2025-08-11T21:44:25.268Z","avatar_url":"https://github.com/hofnerb.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"stabs\n=====\n\n[![Build Status](https://travis-ci.org/hofnerb/stabs.svg)](https://travis-ci.org/hofnerb/stabs)\n[![Build status](https://ci.appveyor.com/api/projects/status/tlo7dbrevje1f2du?svg=true)](https://ci.appveyor.com/project/hofnerb/stabs)\n[![Coverage Status](https://coveralls.io/repos/hofnerb/stabs/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/hofnerb/stabs?branch=master)\n[![CRAN Status Badge](http://www.r-pkg.org/badges/version/stabs)](https://cran.r-project.org/package=stabs)\n[![](http://cranlogs.r-pkg.org/badges/stabs)](https://cran.r-project.org/package=stabs)\n\n**stabs** implements resampling procedures to assess the stability of selected\nvariables with additional finite sample error control for high-dimensional\nvariable selection procedures such as Lasso or boosting. Both, standard\nstability selection (Meinshausen \u0026 Bühlmann, 2010, [doi:10.1111/j.1467-9868.2010.00740.x](http://dx.doi.org/10.1111/j.1467-9868.2010.00740.x)) and complementarty pairs\nstability selection with improved error bounds (Shah \u0026 Samworth, 2013, [doi:10.1111/j.1467-9868.2011.01034.x](http://dx.doi.org/10.1111/j.1467-9868.2011.01034.x)) are\nimplemented. The package can be combined with arbitrary user specified variable\nselection approaches.\n\nFor an expanded and executable version of this file please see\n```r\nvignette(\"Using_stabs\", package = \"stabs\")\n```\n\n## Installation\n\n- Current version (from CRAN):\n\n```r\ninstall.packages(\"stabs\")\n```\n\n- Latest development version from [GitHub](https://github.com/hofnerb/stabs):\n\n```r\nlibrary(\"devtools\")\ninstall_github(\"hofnerb/stabs\")\n```\n\nTo be able to use the `install_github()` command, one needs to install **devtools** first:\n\n```r\ninstall.packages(\"devtools\")\n```\n\n## Using stabs\n\nA simple example of how to use **stabs** with package **lars**:\n\n```r\nlibrary(\"stabs\")\nlibrary(\"lars\")\n## make data set available\ndata(\"bodyfat\", package = \"TH.data\")\n## set seed\nset.seed(1234)\n\n## lasso\n(stab.lasso \u003c- stabsel(x = bodyfat[, -2], y = bodyfat[,2],\n                       fitfun = lars.lasso, cutoff = 0.75,\n                       PFER = 1))\n\n## stepwise selection\n(stab.stepwise \u003c- stabsel(x = bodyfat[, -2], y = bodyfat[,2],\n                          fitfun = lars.stepwise, cutoff = 0.75,\n                          PFER = 1))\n\n## plot results\npar(mfrow = c(2, 1))\nplot(stab.lasso, main = \"Lasso\")\nplot(stab.stepwise, main = \"Stepwise Selection\")\n```\n\nWe can see that stepwise selection seems to be quite unstable even in this low\ndimensional example!\n\n### User-specified variable selection approaches\n\nTo use **stabs** with user specified functions, one can specify an own `fitfun`.\nThese need to take arguments `x` (the predictors), `y` (the outcome) and `q` the\nnumber of selected variables as defined for stability selection. Additional\narguments to the variable selection method can be handled by `...`. In the\nfunction `stabsel()` these can then be specified as a named list which is given\nto `args.fitfun`.\n\nThe `fitfun` function then needs to return a named list with two elements\n`selected` and `path`:\n* `selected` is a vector that indicates which variable was selected.\n* `path` is a matrix that indicates which variable was selected in which step.\n    Each row represents one variable, the columns represent the steps.\nThe latter is optional and only needed to draw the complete selection paths.\n\nThe following example shows how `lars.lasso` is implemented:\n```r\nlars.lasso \u003c- function(x, y, q, ...) {\n    if (!requireNamespace(\"lars\"))\n        stop(\"Package \", sQuote(\"lars\"), \" needed but not available\")\n\n    if (is.data.frame(x)) {\n        message(\"Note: \", sQuote(\"x\"),\n                \" is coerced to a model matrix without intercept\")\n        x \u003c- model.matrix(~ . - 1, x)\n    }\n\n    ## fit model\n    fit \u003c- lars::lars(x, y, max.steps = q, ...)\n\n    ## which coefficients are non-zero?\n    selected \u003c- unlist(fit$actions)\n\t## check if variables are removed again from the active set\n    ## and remove these from selected\n    if (any(selected \u003c 0)) {\n        idx \u003c- which(selected \u003c 0)\n        idx \u003c- c(idx, which(selected %in% abs(selected[idx])))\n        selected \u003c- selected[-idx]\n    }\n\n    ret \u003c- logical(ncol(x))\n    ret[selected] \u003c- TRUE\n    names(ret) \u003c- colnames(x)\n    ## compute selection paths\n    cf \u003c- fit$beta\n    sequence \u003c- t(cf != 0)\n    ## return both\n    return(list(selected = ret, path = sequence))\n}\n```\n\nTo see more examples simply print, e.g., `lars.stepwise`, `glmnet.lasso`, or\n`glmnet.lasso_maxCoef`. Please contact me if you need help to integrate your\nmethod of choice.\n\n### Using boosting with stability selection\n\nInstead of specifying a fitting function, one can also use `stabsel` directly on\ncomputed boosting models from\n[mboost](https://cran.r-project.org/package=mboost).\n\n```r\nlibrary(\"stabs\")\nlibrary(\"mboost\")\n### low-dimensional example\nmod \u003c- glmboost(DEXfat ~ ., data = bodyfat)\n\n## compute cutoff ahead of running stabsel to see if it is a sensible\n## parameter choice.\n##   p = ncol(bodyfat) - 1 (= Outcome) + 1 ( = Intercept)\nstabsel_parameters(q = 3, PFER = 1, p = ncol(bodyfat) - 1 + 1,\n                   sampling.type = \"MB\")\n## the same:\nstabsel(mod, q = 3, PFER = 1, sampling.type = \"MB\", eval = FALSE)\n\n## now run stability selection\n(sbody \u003c- stabsel(mod, q = 3, PFER = 1, sampling.type = \"MB\"))\nopar \u003c- par(mai = par(\"mai\") * c(1, 1, 1, 2.7))\nplot(sbody, type = \"paths\")\npar(opar)\n\nplot(sbody, type = \"maxsel\", ymargin = 6)\n```\n\n## Citation\n\nTo cite the package in publications please use\n```r\ncitation(\"stabs\")\n```\n\nwhich will currently give you\n\n```r\nTo cite package 'stabs' in publications use:\n\n  Benjamin Hofner and Torsten Hothorn (2021). stabs: Stability\n  Selection with Error Control, R package version R package version\n  0.6-4, https://CRAN.R-project.org/package=stabs.\n\n  Benjamin Hofner, Luigi Boccuto and Markus Goeker (2015). Controlling\n  false discoveries in high-dimensional situations: Boosting with\n  stability selection. BMC Bioinformatics, 16:144.\n  doi:10.1186/s12859-015-0575-3\n  \nTo cite the stability selection for 'gamboostLSS' models use:\n\n  Thomas, J., Mayr, A., Bischl, B., Schmid, M., Smith, A., \n  and Hofner, B. (2017). Gradient boosting for distributional regression -\n  faster tuning and improved variable selection via noncyclical updates. \n  Statistics and Computing. Online First. DOI 10.1007/s11222-017-9754-6  \n\nUse ‘toBibtex(citation(\"stabs\"))’ to extract BibTeX references.\n```\n\nTo obtain BibTeX references use\n\n```r\ntoBibtex(citation(\"stabs\"))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhofnerb%2Fstabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhofnerb%2Fstabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhofnerb%2Fstabs/lists"}