{"id":28702846,"url":"https://github.com/epiforecasts/lopensemble","last_synced_at":"2026-02-01T16:34:18.783Z","repository":{"id":116026644,"uuid":"257593706","full_name":"epiforecasts/lopensemble","owner":"epiforecasts","description":"Model stacking for predictive ensembles","archived":false,"fork":false,"pushed_at":"2026-01-30T15:47:08.000Z","size":29289,"stargazers_count":6,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-31T07:48:05.277Z","etag":null,"topics":["crps","ensembles","forecasting","stacking"],"latest_commit_sha":null,"homepage":"http://epiforecasts.io/lopensemble/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epiforecasts.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-21T12:48:38.000Z","updated_at":"2026-01-30T14:59:48.000Z","dependencies_parsed_at":"2025-06-06T20:27:29.022Z","dependency_job_id":"5d8a64d8-42d1-46ec-b364-0f248b0cf6de","html_url":"https://github.com/epiforecasts/lopensemble","commit_stats":{"total_commits":89,"total_committers":4,"mean_commits":22.25,"dds":0.3707865168539326,"last_synced_commit":"51227bf564f49314fd84a259d09a0e40402e1b3b"},"previous_names":["epiforecasts/lopensemble","epiforecasts/stackr"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/epiforecasts/lopensemble","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Flopensemble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Flopensemble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Flopensemble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Flopensemble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epiforecasts","download_url":"https://codeload.github.com/epiforecasts/lopensemble/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiforecasts%2Flopensemble/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28982869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T16:29:42.054Z","status":"ssl_error","status_checked_at":"2026-02-01T16:29:41.428Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["crps","ensembles","forecasting","stacking"],"created_at":"2025-06-14T13:05:31.714Z","updated_at":"2026-02-01T16:34:18.772Z","avatar_url":"https://github.com/epiforecasts.png","language":"HTML","readme":"---\ntitle: \"lopensemble package\"\noutput: github_document\n---\n\n\u003c!-- badges: start --\u003e\n![GitHub R package version](https://img.shields.io/github/r-package/v/epiforecasts/lopensemble)\n[![R-CMD-check](https://github.com/epiforecasts/lopensemble/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/epiforecasts/lopensemble/actions/workflows/R-CMD-check.yaml)\n[![codecov](https://codecov.io/github/epiforecasts/lopensemble/branch/main/graph/badge.svg?token=rYeyG3kFIa)](https://app.codecov.io/github/epiforecasts/lopensemble)\n![GitHub contributors](https://img.shields.io/github/contributors/epiforecasts/lopensemble)\n [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\u003c!-- badges: end --\u003e\n\n# Overview\nThe `lopensemble` (lop-ensemble) package provides an easy way to combine predictions\nfrom individual time series or panel data models to an \nensemble. `lopensemble` stacks models according to the Continuous Ranked Probability \nScore (CRPS) over k-step ahead predictions. It is therefore especially\nsuited for time-series and panel data. This is sometimes called a linear opinion pool (LOP), which is is reflected in the package name. \n\nPredictions need to be predictive distributions represented by predictive samples.\nUsually, these will be sets of posterior predictive simulation draws generated by an MCMC algorithm.\n\n# Installation\n\n\nThe stable version of the package can be installed using\n```{r eval=FALSE}\ninstall.packages(\"lopensemble\", repos = \"https://epiforecasts.r-universe.dev/\")\n```\n\nThe development version can be installed using `pak`\n```{r eval=FALSE}\npak::pak(\"epiforecasts/lopensemble\")\n```\n\n# CRPS Stacking \nGiven some training data with true observed values as well as predictive samples\ngenerated from different models, `lopensemble` finds the optimal (in the sense of \nminimizing expected cross-validation predictive error) weights to form an\nensemble of these models. Using these weights, `lopensemble` can then provide\nsamples from the optimal model mixture by drawing from the predictive samples\nof those models in the correct proportion. This gives a mixture model\nsolely based on predictive samples and is in this regard superior to other\nensembling techniques like Bayesian Model Averaging. More information \ncan be found in the package vignette. \n\nWeights are generated using the `crps_weights` function. With these weights \nand predictive samples, the `mixture_from_samples` function can be used to obtain \npredictive samples from the optimal mixture model.\n\n# Usage\n## Load example data and split into train and test data\n``` {r eval = FALSE}\nsplitdate \u003c- as.Date(\"2020-03-28\")\ntraindata \u003c- example_data[date \u003c= splitdate]\ntestdata \u003c- example_data[date \u003e splitdate]\n```\n\n\n## Get weights and create mixture \n``` {r eval = FALSE}\nweights \u003c- crps_weights(traindata)\ntest_mixture \u003c- mixture_from_samples(testdata, weights = weights)\n```\n\n## Score predictions\n``` {r eval = FALSE}\nlibrary(\"scoringutils\")\n\n# combine data.frame with mixture with predictions from other models\nscore_df \u003c- rbindlist(list(testdata, test_mixture), fill = TRUE)\n\n# score all predictions using from github.com/epiforecasts/scoringutils\nscore_df[, crps := crps(unique(observed), t(predicted)),\n  by = .(geography, model, date)\n]\n\n# summarise scores\nscore_df[, mean(crps), by = model][, setnames(.SD, \"V1\", \"CRPS\")]\n```\n\n# References\n- Using Stacking to Average Bayesian Predictive Distributions, Yuling Yao, Aki Vehtari, Daniel Simpson, and Andrew Gelman, 2018, Bayesian Analysis 13, Number 3, pp. 917–1003 DOI 10.1214/17-BA1091\n- Strictly Proper Scoring Rules, Prediction, and Estimation, \nTilmann Gneiting and Adrian E. Raftery, 2007, Journal of the American\nStatistical Association, Volume 102, 2007 - Issue 477 DOI 10.1198/016214506000001437\n- Comparing Bayes Model Averaging and Stacking When Model Approximation Error Cannot be Ignored, \nBertrand Clarke, 2003, Journal of Machine Learning Research 4\n- Bayesian Model Weighting: The Many Faces of Model Averaging, \nMarvin Höge, Anneli Guthke and Wolfgang Nowak, 2020, Water, DOI 10.3390/w12020309\n- Bayesian Stacking and Pseudo-BMA weights using the loo package, \nAki Vehtari and Jonah Gabry, 2019, https://mc-stan.org/loo/articles/loo2-weights.html\n\n\nContributors\n---\n\n\n\n\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\nAll contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [allcontributors](https://allcontributors.org) specification. Contributions of any kind are welcome!\n\n### Code\n\n\n\u003ca href=\"https://github.com/epiforecasts/lopensemble/commits?author=nikosbosse\"\u003enikosbosse\u003c/a\u003e, \n\u003ca href=\"https://github.com/epiforecasts/lopensemble/commits?author=sbfnk\"\u003esbfnk\u003c/a\u003e, \n\u003ca href=\"https://github.com/epiforecasts/lopensemble/commits?author=seabbs\"\u003eseabbs\u003c/a\u003e\n\n\n\n### Issue Authors\n\n\n\u003ca href=\"https://github.com/epiforecasts/lopensemble/issues?q=is%3Aissue+author%3Anickreich\"\u003enickreich\u003c/a\u003e\n\n\n\n### Issue Contributors\n\n\n\u003ca href=\"https://github.com/epiforecasts/lopensemble/issues?q=is%3Aissue+commenter%3Ajonathonmellor\"\u003ejonathonmellor\u003c/a\u003e\n\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiforecasts%2Flopensemble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepiforecasts%2Flopensemble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiforecasts%2Flopensemble/lists"}