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 4 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 a large set of countries
- Host: GitHub
- URL: https://github.com/moritzpschwarz/osem
- Owner: moritzpschwarz
- License: agpl-3.0
- Created: 2025-06-25T13:45:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-03-03T20:52:16.000Z (23 days ago)
- Last Synced: 2026-03-17T11:19:28.131Z (10 days ago)
- Language: R
- Homepage: http://www.moritzschwarz.org/osem/
- Size: 13 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 26
- Releases: 1
-
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",
input = "inst/extdata/InputData.xlsx",
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
- Release event: 1
- Delete event: 19
- Member event: 1
- Pull request event: 29
- Issues event: 37
- Watch event: 3
- Issue comment event: 22
- Push event: 191
- Pull request review event: 26
- Pull request review comment event: 30
- Create event: 23
Last Year
- Release event: 1
- Delete event: 9
- Member event: 1
- Pull request event: 15
- Issues event: 25
- Watch event: 3
- Issue comment event: 15
- Push event: 70
- Pull request review comment event: 29
- Pull request review event: 25
- Create event: 13
Committers metadata
Last synced: 3 days ago
Total Commits: 152
Total Committers: 2
Avg Commits per committer: 76.0
Development Distribution Score (DDS): 0.474
Commits in past year: 152
Committers in past year: 2
Avg Commits per committer in past year: 76.0
Development Distribution Score (DDS) in past year: 0.474
| Name | Commits | |
|---|---|---|
| Jonas Kurle | 5****e | 80 |
| Moritz Schwarz | m****z@o****m | 72 |
Issue and Pull Request metadata
Last synced: 3 days ago
Total issues: 56
Total pull requests: 75
Average time to close issues: 7 months
Average time to close pull requests: 28 days
Total issue authors: 2
Total pull request authors: 5
Average comments per issue: 0.27
Average comments per pull request: 0.77
Merged pull request: 56
Bot issues: 0
Bot pull requests: 1
Past year issues: 14
Past year pull requests: 17
Past year average time to close issues: N/A
Past year average time to close pull requests: 22 days
Past year issue authors: 2
Past year pull request authors: 3
Past year average comments per issue: 0.14
Past year average comments per pull request: 0.35
Past year merged pull request: 9
Past year bot issues: 0
Past year bot pull requests: 1
Top Issue Authors
- moritzpschwarz (49)
- jkurle (7)
Top Pull Request Authors
- moritzpschwarz (65)
- Geoffrey-Harper (5)
- jkurle (2)
- paulhoea (2)
- codecov-ai[bot] (1)
Top Issue Labels
- enhancement (17)
- bug (4)
- double check (2)
- documentation (2)
Top Pull Request Labels
- enhancement (4)
Dependencies
- actions/checkout v4 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
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v4 composite
- actions/upload-artifact v4 composite
- codecov/codecov-action v4 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
- zoo * imports
- DT * suggests
- broom * suggests
- forecast * suggests
- ggraph * suggests
- igraph * suggests
- imf.data * suggests
- knitr * suggests
- modelsummary * suggests
- plotly * suggests
- purrr * suggests
- readr * suggests
- readxl * suggests
- rmarkdown * suggests
- shiny * suggests
- statcanR * suggests
- testthat >= 3.0.0 suggests
- tidygraph * suggests
- writexl * suggests
Score: 4.060443010546419