osem

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

https://github.com/moritzpschwarz/osem

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.1%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

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

Basic Info
Statistics
  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • Open Issues: 26
  • Releases: 1
Created about 1 year ago · Last pushed 12 months ago
Metadata Files
Readme Contributing License

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


[![R-CMD-check](https://github.com/moritzpschwarz/osem/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/moritzpschwarz/osem/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/moritzpschwarz/osem/branch/main/graph/badge.svg)](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

  • Name: Moritz Schwarz
  • Login: moritzpschwarz
  • Kind: user
  • Location: Oxford
  • Company: University of Oxford

Climate Econometrics and Institute for New Economic Thinking at the Oxford Martin School

GitHub Events

Total
  • Create event: 20
  • Release event: 1
  • Issues event: 37
  • Watch event: 3
  • Delete event: 19
  • Member event: 1
  • Issue comment event: 22
  • Push event: 169
  • Pull request review event: 20
  • Pull request review comment event: 21
  • Pull request event: 29
Last Year
  • Create event: 20
  • Release event: 1
  • Issues event: 37
  • Watch event: 3
  • Delete event: 19
  • Member event: 1
  • Issue comment event: 22
  • Push event: 169
  • Pull request review event: 20
  • Pull request review comment event: 21
  • Pull request event: 29

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 16
  • Total Committers: 1
  • Avg Commits per committer: 16.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 16
  • Committers: 1
  • Avg Commits per committer: 16.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Moritz Schwarz m****z@o****m 16

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 64
  • Total pull requests: 59
  • Average time to close issues: 6 months
  • Average time to close pull requests: 27 days
  • Total issue authors: 2
  • Total pull request authors: 5
  • Average comments per issue: 0.34
  • Average comments per pull request: 0.88
  • Merged pull requests: 46
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 36
  • Pull requests: 35
  • Average time to close issues: 3 months
  • Average time to close pull requests: 20 days
  • Issue authors: 2
  • Pull request authors: 4
  • Average comments per issue: 0.11
  • Average comments per pull request: 0.54
  • Merged pull requests: 23
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • moritzpschwarz (50)
  • jkurle (7)
Pull Request Authors
  • moritzpschwarz (64)
  • Geoffrey-Harper (5)
  • paulhoea (2)
  • jkurle (1)
  • codecov-ai[bot] (1)
Top Labels
Issue Labels
enhancement (18) bug (4) double check (2) documentation (2)
Pull Request Labels
enhancement (3)

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • 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
.github/workflows/pkgdown.yaml actions
  • 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
.github/workflows/test-coverage.yaml actions
  • 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
DESCRIPTION cran
  • 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