Open Source Empirical Macro Model
Study Climate Policies and the wider Macro-economy that can easily be applied to all EU countries.
https://github.com/moritzpschwarz/osem
Category: Climate Change
Sub Category: Integrated Assessment and Climate Policy
Last synced: about 21 hours ago
JSON representation
Repository metadata
A novel Open-Source Empircial Macro (OSEM) Model to study Climate Policies and the wider Macro-economy that can easily be applied to all EU countries
- Host: GitHub
- URL: https://github.com/moritzpschwarz/osem
- Owner: moritzpschwarz
- License: agpl-3.0
- Created: 2021-12-28T15:32:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-30T18:28:15.000Z (8 days ago)
- Last Synced: 2025-06-03T14:02:49.780Z (4 days ago)
- Language: R
- Homepage: http://moritzschwarz.org/osem/
- Size: 68.1 MB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 21
- Releases: 0
-
Metadata Files:
- Readme: README.Rmd
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
README.Rmd
--- output: github_document always_allow_html: true --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", fig.width = 7, fig.height = 5, dev = "png", dpi = 600 ) ``` # osem - Open Source Empirical Macro Model [](https://github.com/moritzpschwarz/osem/actions/workflows/R-CMD-check.yaml) [](https://app.codecov.io/gh/moritzpschwarz/osem?branch=main) The goal of the {osem} Package is to implement and operationalise the Open Source Empirical Macro (OSEM) Model, developed by Moritz Schwarz, Jonas Kurle, Felix Pretis, and Andrew Martinez. This is an adaptation of the [Norwegian Aggregate Model](https://normetrics.no/nam/), developed by Gunnar Bardsen and Ragnar Nymoen. ## Installation You can install the development version of {osem} from [GitHub](https://github.com/) with: ``` r # install.packages("devtools") devtools::install_github("moritzpschwarz/osem") ``` ## Basic Workflow This is an example which shows you how to run the model: First we load the package: ```{r, include=FALSE} library(tidyverse) ``` ```{r loading} library(osem) ``` ### Specify the model The we calibrate the model specification and save this in a tibble. Here the column names and the structure of the specification table must follow the basic structure below. ```{r set-up} spec <- dplyr::tibble( type = c( "n", "n", "n", "n", "d", "n", "n", "n", "n" ), dependent = c( "Import", "FinConsExpHH", "GCapitalForm", "Emissions", "GDP", "GValueAddGov", # as in NAM, technical relationship "GValueAddManuf", # more complicated in NAM, see 2.3.3 and 6.3.1 "GValueAddConstr" , "GValueAddWholesaletrade" ), independent = c( "FinConsExpHH + GCapitalForm", "", "FinConsExpGov + FinConsExpHH", "GDP + Export + GValueAddIndus", "GValueAddGov + GValueAddAgri + GValueAddIndus + GValueAddConstr + GValueAddWholesaletrade + GValueAddInfocom + GValueAddFinance + GValueAddRealest + GValueAddResearch + GValueAddArts", "FinConsExpGov", # as in NAM, technical relationship "Export + LabCostManuf", # NAM uses 'export market indicator' not exports - unclear what this is, NAM uses unit labour cost in NOR manufacturing relative to the foreign price level - here is just total labour cost "LabCostConstr + BuildingPermits", # in NAM some form of YFP2J = 0.3JBOL + 0.2JF P N + 0.3JO + 0.3JOIL. Unclear what this is. Using Building Permits instead "Export + LabCostService" )) ``` To summarise this, we can print out the specification table: ```{r, include=FALSE} library(kableExtra, verbose = FALSE) ``` ```{r, results='asis', echo=FALSE} kable(spec) %>% kable_styling() %>% kable_paper() ``` In order to run this model, we also need a dictionary that translates our model variables to EUROSTAT codes so that the download process can be automated. You can either pass a new dictionary to the model function, or you can use the built in dictionary `osem::dict` (here the first few rows): ```{r, results='asis', echo=FALSE} osem::dict %>% head() %>% kable() %>% kable_styling() %>% kable_paper() ``` ### Running the model Now we are ready to run the model with the `run_model()` function: ```{r} model_result <- run_model( specification = spec, save_to_disk = "inst/extdata/InputData.xlsx", primary_source = "download", trend = TRUE, saturation.tpval = 0.01, plot = FALSE ) ``` ```{r} model_result ``` The first time that we run this, all data will be downloaded and saved in the folder `data/use/InputData.xlsx`. The next time that we run the same model, we can save some time and just load the data from our earlier run: ```{r, eval=FALSE} model_result <- run_model( specification = spec, primary_source = "local", inputdata_directory = "inst/extdata", trend = TRUE, saturation.tpval = 0.01 ) ``` ### Forecasting the model Now that we have run the model, we can forecast the model (here using an AR process for the exogenous values and for 10 time periods): ```{r} model_forecast <- forecast_model(model_result, n.ahead = 10, exog_fill_method = "AR", plot = FALSE) ``` Once we are done, we can plot the forecast: ```{r} plot(model_forecast, order.as.run = TRUE) ```
Owner metadata
- Name: Moritz Schwarz
- Login: moritzpschwarz
- Email:
- Kind: user
- Description: Climate Econometrics and Institute for New Economic Thinking at the Oxford Martin School
- Website: moritzschwarz.org
- Location: Oxford
- Twitter: moritzpschwarz
- Company: University of Oxford
- Icon url: https://avatars.githubusercontent.com/u/30114680?u=6b959e1bd1a3649747c0bc1666c93616cbc59c86&v=4
- Repositories: 21
- Last ynced at: 2024-05-12T09:40:56.855Z
- Profile URL: https://github.com/moritzpschwarz
GitHub Events
Total
- Issues event: 20
- Watch event: 1
- Delete event: 14
- Issue comment event: 12
- Push event: 134
- Pull request review event: 9
- Pull request review comment event: 7
- Pull request event: 19
- Create event: 12
Last Year
- Issues event: 20
- Watch event: 1
- Delete event: 14
- Issue comment event: 12
- Push event: 134
- Pull request review event: 9
- Pull request review comment event: 7
- Pull request event: 19
- Create event: 12
Issue and Pull Request metadata
Last synced: 2 days ago
Total issues: 93
Total pull requests: 110
Average time to close issues: 5 months
Average time to close pull requests: 25 days
Total issue authors: 2
Total pull request authors: 4
Average comments per issue: 0.61
Average comments per pull request: 0.89
Merged pull request: 96
Bot issues: 0
Bot pull requests: 0
Past year issues: 48
Past year pull requests: 60
Past year average time to close issues: 3 months
Past year average time to close pull requests: 18 days
Past year issue authors: 2
Past year pull request authors: 2
Past year average comments per issue: 0.33
Past year average comments per pull request: 0.7
Past year merged pull request: 49
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- moritzpschwarz (86)
- jkurle (7)
Top Pull Request Authors
- moritzpschwarz (98)
- Geoffrey-Harper (8)
- paulhoea (3)
- jkurle (1)
Top Issue Labels
- enhancement (32)
- bug (15)
- double check (8)
- testing (3)
- documentation (3)
- error message (2)
Top Pull Request Labels
- enhancement (6)
Dependencies
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- r-lib/actions/setup-tinytex v2 composite
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- R >= 3.5 depends
- countrycode * imports
- dplyr * imports
- eurostat * imports
- fastDummies * imports
- gets >= 0.37 imports
- ggplot2 * imports
- lubridate * imports
- magrittr * imports
- rlang * imports
- scales * imports
- stringr * imports
- tidyr * imports
- utils * imports
- DT * suggests
- ggraph * suggests
- igraph * suggests
- knitr * suggests
- plotly * suggests
- purrr * suggests
- readr * suggests
- readxl * suggests
- rmarkdown * suggests
- shiny * suggests
- testthat >= 3.0.0 suggests
- tidygraph * suggests
- writexl * suggests
- actions/checkout v4 composite
- actions/upload-artifact v4 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
Score: -Infinity