Introduction

This vignette demonstrates how to reproduce the AMS-II.E calculations using cdmAmsIIe. The methodology covers building energy efficiency and fuel switching projects that improve thermal and electrical performance. The core steps include estimating baseline emissions, calculating project emissions, accounting for leakage, and deriving net emission reductions.

Applicability Checks

library(cdmAmsIIe)

baseline <- tibble::tibble(
  baseline_total_energy_mwh = c(220, 195),
  baseline_thermal_energy_gj = c(320, 180),
  baseline_thermal_emission_factor_tco2_per_gj = c(0.07, 0.072),
  service_level_indicator = c(4.2, 3.9)
)
project <- tibble::tibble(
  project_total_energy_mwh = c(150, 138),
  project_thermal_energy_gj = c(280, 120),
  project_thermal_emission_factor_tco2_per_gj = c(0.045, 0.05),
  service_level_indicator = c(4.2, 3.9)
)
monitoring <- tibble::tibble(
  building_id = c("Office_A", "Office_B"),
  project_total_energy_mwh = c(12.5, 11.2),
  service_level_indicator = c(0.35, 0.32),
  operating_hours = c(220, 215)
)

check_applicability_energy_efficiency(
  baseline,
  project,
  energy_col = "baseline_total_energy_mwh",
  project_energy_col = "project_total_energy_mwh",
  service_col = "service_level_indicator"
)
## [1] TRUE
## [1] TRUE
## [1] TRUE
assess_ams_iie_applicability(baseline, project, monitoring)
## # A tibble: 1 × 4
##   energy_efficiency fuel_switching monitoring_ready overall_applicable
##   <lgl>             <lgl>          <lgl>            <lgl>             
## 1 TRUE              TRUE           TRUE             TRUE

Simulated Dataset

set.seed(123)
example_data <- simulate_ams_iie_dataset(n_buildings = 4, n_periods = 6, start_year = 2024, start_month = 7)
quiet_kable(
  head(example_data),
  format = "html",
  digits = 3
)
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
building_id monitoring_period year month day monitoring_date monitoring_label baseline_electricity_mwh baseline_thermal_energy_gj baseline_electricity_emission_factor_tco2_per_mwh baseline_thermal_emission_factor_tco2_per_gj baseline_total_energy_mwh project_electricity_mwh project_thermal_energy_gj project_electricity_emission_factor_tco2_per_mwh project_thermal_emission_factor_tco2_per_gj project_total_energy_mwh service_level_indicator operating_hours leakage_emissions_tco2e
building_01 1 2024 7 15 2024-07-15 2024-07 145.002 327.209 0.579 0.057 235.894 108.752 212.686 0.579 0.040 167.831 0.287 218.320 0.185
building_01 2 2024 8 19 2024-08-19 2024-08 117.973 399.600 0.598 0.060 228.973 88.480 259.740 0.598 0.042 160.630 0.423 228.207 0.239
building_01 3 2024 9 14 2024-09-14 2024-09 167.190 296.517 0.678 0.070 249.556 125.393 192.736 0.678 0.049 178.930 0.399 223.674 0.207
building_01 4 2024 10 3 2024-10-03 2024-10 157.336 409.723 0.570 0.072 271.148 118.002 266.320 0.570 0.050 191.980 0.384 255.575 0.295
building_01 5 2024 11 10 2024-11-10 2024-11 138.831 434.732 0.562 0.065 259.590 104.123 282.576 0.562 0.045 182.616 0.374 220.754 0.282
building_01 6 2024 12 18 2024-12-18 2024-12 123.528 368.787 0.568 0.063 225.969 92.646 239.712 0.568 0.044 159.233 0.324 243.524 0.231

The simulation includes monitoring metadata (monitoring_period, year, month, day, and monitoring_label) along with baseline/project parameters, service indicators, and leakage placeholders.

Equation Walkthrough

baseline_emissions <- calculate_baseline_building_emissions(example_data, group_cols = "building_id")
project_emissions <- calculate_project_building_emissions(example_data, group_cols = "building_id")
leakage_emissions <- calculate_leakage_emissions(
  example_data,
  group_cols = "building_id",
  leakage_col = "leakage_emissions_tco2e"
)
emission_reductions <- estimate_emission_reductions(
  baseline_emissions,
  project_emissions,
  leakage_emissions,
  group_cols = "building_id"
)
quiet_kable(emission_reductions, format = "html", digits = 3)
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
building_id emission_reductions_tco2e baseline_emissions_tco2e project_emissions_tco2e leakage_emissions_tco2e
building_01 203.438 649.651 444.773 1.440
building_02 202.291 654.058 450.407 1.361
building_03 204.982 646.809 440.308 1.519
building_04 196.521 612.917 414.877 1.519

Monitoring Period Aggregation

period_summary <- aggregate_monitoring_periods(
  monitoring_data = example_data,
  period_col = "monitoring_label",
  group_cols = "building_id"
)

quiet_kable(period_summary, format = "html", digits = 3)
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
building_id monitoring_period year month day baseline_electricity_mwh baseline_thermal_energy_gj baseline_electricity_emission_factor_tco2_per_mwh baseline_thermal_emission_factor_tco2_per_gj baseline_total_energy_mwh project_electricity_mwh project_thermal_energy_gj project_electricity_emission_factor_tco2_per_mwh project_thermal_emission_factor_tco2_per_gj project_total_energy_mwh service_level_indicator operating_hours leakage_emissions_tco2e
building_01 2024-07, 2024-08, 2024-09, 2024-10, 2024-11, 2024-12 12144 57 79 849.861 2236.569 3.555 0.386 1471.130 637.395 1453.770 3.555 0.270 1041.220 2.191 1390.054 1.440
building_02 2024-07, 2024-08, 2024-09, 2024-10, 2024-11, 2024-12 12144 57 94 810.919 2204.794 3.837 0.370 1423.362 608.190 1433.116 3.837 0.259 1006.277 2.269 1291.586 1.361
building_03 2024-07, 2024-08, 2024-09, 2024-10, 2024-11, 2024-12 12144 57 129 775.402 2399.155 3.820 0.379 1441.834 581.551 1559.451 3.820 0.265 1014.732 2.117 1418.183 1.519
building_04 2024-07, 2024-08, 2024-09, 2024-10, 2024-11, 2024-12 12144 57 98 779.285 2348.965 3.549 0.386 1431.775 584.463 1526.827 3.549 0.270 1008.582 2.308 1324.514 1.519

Meta-Function

estimate_emission_reductions_ams_iie(
  baseline_data = example_data,
  project_data = example_data,
  leakage_data = example_data,
  group_cols = "building_id",
  leakage_args = list(leakage_col = "leakage_emissions_tco2e")
)
## # A tibble: 4 × 5
##   building_id emission_reductions_tco2e baseline_emissions_tco2e
##   <chr>                           <dbl>                    <dbl>
## 1 building_01                      203.                     650.
## 2 building_02                      202.                     654.
## 3 building_03                      205.                     647.
## 4 building_04                      197.                     613.
## # ℹ 2 more variables: project_emissions_tco2e <dbl>,
## #   leakage_emissions_tco2e <dbl>

Function Reference

function_reference <- tibble::tibble(
  Function = c(
    "`calculate_baseline_building_emissions()`",
    "`calculate_project_building_emissions()`",
    "`calculate_leakage_emissions()`",
    "`estimate_emission_reductions()`",
    "`aggregate_monitoring_periods()`",
    "`estimate_emission_reductions_ams_iie()`",
    "`simulate_ams_iie_dataset()`"
  ),
  Signature = c(
    "`calculate_baseline_building_emissions(baseline_data, thermal_energy_col = \"baseline_thermal_energy_gj\", thermal_emission_factor_col = \"baseline_thermal_emission_factor_tco2_per_gj\", electricity_col = \"baseline_electricity_mwh\", electricity_emission_factor_col = \"baseline_electricity_emission_factor_tco2_per_mwh\", group_cols = NULL, output_col = \"baseline_emissions_tco2e\")`",
    "`calculate_project_building_emissions(project_data, thermal_energy_col = \"project_thermal_energy_gj\", thermal_emission_factor_col = \"project_thermal_emission_factor_tco2_per_gj\", electricity_col = \"project_electricity_mwh\", electricity_emission_factor_col = \"project_electricity_emission_factor_tco2_per_mwh\", group_cols = NULL, output_col = \"project_emissions_tco2e\")`",
    "`calculate_leakage_emissions(leakage_data, leakage_col = \"leakage_emissions_tco2e\", group_cols = NULL, output_col = \"leakage_emissions_tco2e\")`",
    "`estimate_emission_reductions(baseline_emissions, project_emissions, leakage_emissions = NULL, baseline_col = \"baseline_emissions_tco2e\", project_col = \"project_emissions_tco2e\", leakage_col = \"leakage_emissions_tco2e\", group_cols = NULL, output_col = \"emission_reductions_tco2e\")`",
    "`aggregate_monitoring_periods(monitoring_data, period_col = \"monitoring_period\", group_cols = NULL, summarise_cols = NULL, output_col = \"monitoring_period\")`",
    "`estimate_emission_reductions_ams_iie(baseline_data, project_data, leakage_data = NULL, group_cols = NULL, baseline_args = list(), project_args = list(), leakage_args = list(), reduction_args = list())`",
    "`simulate_ams_iie_dataset(n_buildings = 10, n_periods = 12, start_year = 2023, start_month = 1, seed = NULL)`"
  ),
  Purpose = c(
    "Aggregates baseline thermal and electricity energy into emissions.<br>\\(BE_y = \\sum_i Q^{th,BL}_{i,y} \\times EF^{th,BL}_{i,y} + \\sum_i E^{el,BL}_{i,y} \\times EF^{el,BL}_{i,y}\\)",
    "Summarises project thermal and electricity emissions after interventions.<br>\\(PE_y = \\sum_i Q^{th,PR}_{i,y} \\times EF^{th,PR}_{i,y} + \\sum_i E^{el,PR}_{i,y} \\times EF^{el,PR}_{i,y}\\)",
    "Collects leakage emissions associated with the building project activity.<br>\\(LE_y = \\sum_i LE_{i,y}\\)",
    "Combines baseline, project, and leakage totals to compute net reductions.<br>\\(ER_y = BE_y - (PE_y + LE_y)\\)",
    "Rolls monitoring data to the reporting periods for analysis.<br>\\(ER_{p,y} = BE_{p,y} - (PE_{p,y} + LE_{p,y})\\)",
    "High-level wrapper orchestrating baseline, project, and leakage helpers.<br>\\(ER_y = BE_y - (PE_y + LE_y)\\)",
    "Generates representative building datasets for demonstrations and tests."
  )
)

quiet_kable(function_reference, format = "html", escape = FALSE)
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
Function Signature Purpose
calculate_baseline_building_emissions() calculate_baseline_building_emissions(baseline_data, thermal_energy_col = "baseline_thermal_energy_gj", thermal_emission_factor_col = "baseline_thermal_emission_factor_tco2_per_gj", electricity_col = "baseline_electricity_mwh", electricity_emission_factor_col = "baseline_electricity_emission_factor_tco2_per_mwh", group_cols = NULL, output_col = "baseline_emissions_tco2e") Aggregates baseline thermal and electricity energy into emissions.
BEy=iQi,yth,BL×EFi,yth,BL+iEi,yel,BL×EFi,yel,BLBE_y = \sum_i Q^{th,BL}_{i,y} \times EF^{th,BL}_{i,y} + \sum_i E^{el,BL}_{i,y} \times EF^{el,BL}_{i,y}
calculate_project_building_emissions() calculate_project_building_emissions(project_data, thermal_energy_col = "project_thermal_energy_gj", thermal_emission_factor_col = "project_thermal_emission_factor_tco2_per_gj", electricity_col = "project_electricity_mwh", electricity_emission_factor_col = "project_electricity_emission_factor_tco2_per_mwh", group_cols = NULL, output_col = "project_emissions_tco2e") Summarises project thermal and electricity emissions after interventions.
PEy=iQi,yth,PR×EFi,yth,PR+iEi,yel,PR×EFi,yel,PRPE_y = \sum_i Q^{th,PR}_{i,y} \times EF^{th,PR}_{i,y} + \sum_i E^{el,PR}_{i,y} \times EF^{el,PR}_{i,y}
calculate_leakage_emissions() calculate_leakage_emissions(leakage_data, leakage_col = "leakage_emissions_tco2e", group_cols = NULL, output_col = "leakage_emissions_tco2e") Collects leakage emissions associated with the building project activity.
LEy=iLEi,yLE_y = \sum_i LE_{i,y}
estimate_emission_reductions() estimate_emission_reductions(baseline_emissions, project_emissions, leakage_emissions = NULL, baseline_col = "baseline_emissions_tco2e", project_col = "project_emissions_tco2e", leakage_col = "leakage_emissions_tco2e", group_cols = NULL, output_col = "emission_reductions_tco2e") Combines baseline, project, and leakage totals to compute net reductions.
ERy=BEy(PEy+LEy)ER_y = BE_y - (PE_y + LE_y)
aggregate_monitoring_periods() aggregate_monitoring_periods(monitoring_data, period_col = "monitoring_period", group_cols = NULL, summarise_cols = NULL, output_col = "monitoring_period") Rolls monitoring data to the reporting periods for analysis.
ERp,y=BEp,y(PEp,y+LEp,y)ER_{p,y} = BE_{p,y} - (PE_{p,y} + LE_{p,y})
estimate_emission_reductions_ams_iie() estimate_emission_reductions_ams_iie(baseline_data, project_data, leakage_data = NULL, group_cols = NULL, baseline_args = list(), project_args = list(), leakage_args = list(), reduction_args = list()) High-level wrapper orchestrating baseline, project, and leakage helpers.
ERy=BEy(PEy+LEy)ER_y = BE_y - (PE_y + LE_y)
simulate_ams_iie_dataset() simulate_ams_iie_dataset(n_buildings = 10, n_periods = 12, start_year = 2023, start_month = 1, seed = NULL) Generates representative building datasets for demonstrations and tests.

Workflow Overview

## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
Step Purpose
Input building monitoring data Collect baseline, project, and leakage measurements for each building.
calculate_baseline_building_emissions Translate baseline thermal and electricity use into emissions.
calculate_project_building_emissions Quantify project emissions after efficiency or fuel switching measures.
calculate_leakage_emissions Summarise leakage contributions for each monitoring group.
estimate_emission_reductions Derive net emission reductions from baseline, project, and leakage totals.
estimate_emission_reductions_ams_iie Return a tidy tibble with reductions and supporting diagnostics.