Skip to contents

Summarize and aggregate impacts from run_fredi() (calculate national totals, average across models, sum impact types, and interpolate between impact estimate years).

Usage

aggregate_impacts(
  data,
  aggLevels = c("national", "modelaverage", "impacttype", "impactyear"),
  columns = c("physical_impacts", "annual_impacts"),
  groupByCols = c(c(c(c("sector", "variant", "impactType", "impactYear"), "region",
    "state", "postal"), "model_type", "model"), "includeaggregate", "sectorprimary"),
  silent = TRUE
)

Arguments

data

Data frame of results FrEDI (outputs from run_fredi())

aggLevels

Levels of aggregation at which to summarize data: one or more of c("national", "modelAverage", "impactYear", "impactType", "all" ). Defaults to all levels (i.e., aggLevels = "all"). Note that, if "impacttype" is in aggLevels (e.g., aggLevels = "all"), column "physical_measure" is dropped from the groupByCols and column "physical_impacts" is dropped from columns. This is because aggregating over impact types for some sectors requires summing costs over different types of physical impacts, so reporting the physical impacts would be nonsensical.

columns

Character vector of columns for which to aggregate results (defaults to columns = c( "physical_impacts", "annual_impacts")).

groupByCols

Character vector indicating which columns to use for grouping. Defaults to groupByCols = c("sector", "variant", "impactYear", "impactType", "model_type", "model", "sectorprimary", "includeaggregate", "physicalmeasure", "region", "state", "postal"). Note that the "variant" column referred to below contains information about the variant or adaptation name (or “N/A”), as applicable.

Details

This function can be used to aggregate and summarize the FrEDI results to levels of aggregation specified by the user (passed to aggLevels). Users can specify all aggregation levels at once by specifying aggLevels = "all" (default) or no aggregation levels (aggLevels = "none"). Users can specify a single aggregation level or multiple aggregation levels by passing a single character string or character vector to aggLevels. Options for aggregation include calculating national totals (aggLevels= "national"), averaging across model types and models (aggLevels = "modelAverage"), summing over all impact types (aggLevels = "impactType"), and interpolating between impact year estimates (aggLevels = "impactYear").

Before aggregating impacts for national totals and/or model averages, aggregate_impacts() will drop any pre-summarized results (i.e., values for which region = "National Total" and/or for which model = "Average", respectively) that are already present in the data and then re-summarize results at those respective levels.

If users specify aggLevels = "none", aggregate_impacts() returns the data frame passed to the data argument.

If users specify aggLevels = "all" or other combinations of aggregation levels, the aggregate_impacts() function uses performs the following calculations using the grouping columns specified by the groupByCols argument: "sector", "variant", "impactType", "impactYear", "region", "state", "postal", "model_type", "model", "sectorprimary", "includeaggregate", "physicalmeasure", and "year".

Aggregation LevelDescription
impactyearTo aggregate over impact years, aggregate_impacts() first separates results for sectors with only one impact year estimate (i.e., impactYear = "N/A") from from observations with multiple impact year estimates (i.e., sectors with results for both impactYear = "2010" and impactYear = "2090"). For these sectors with multiple impact years, physical impacts and annual costs (columns "physical_impacts" and "annual_impacts") are linearly interpolated between impact year estimates. For any model run years above 2090, annual results for sectors with multiple impact years return the 2090 estimate. The interpolated values are then row-bound to the results for sectors with a single impact year estimate, and column impactYear set to impactYear = "Interpolation" for all values. If "impactyear" is included in aggLevels (e.g., aggLevels = "all"), aggregate_impacts() aggregates over impact years before performing other types of aggregation.
modelaverageTo aggregate over models for temperature-driven sectors, aggregate_impacts() averages physical impacts and annual costs (columns "physical_impacts" and "annual_impacts", respectively) across all GCM models present in the data. aggregate_impacts() drops the column "model" from the grouping columns when averaging over models. Averages exclude observations with missing values. However, If all values within a grouping are missing, the model average is set to NA. The values in column "model" are set to "Average" for model averages and the model averages data frame is then row-bound to the main results data frame. For SLR-driven sectors, there is no need for additional model aggregation; these values already have model = "Interpolation". If "modelaverage" is included in aggLevels (e.g., aggLevels = "all"), aggregate_impacts() first aggregates over impact years (if "impactyear" present in aggLevels or if aggLevels = "all") before aggregating over models.
nationalTo aggregate values to the national level, aggregate_impacts() sums physical impacts and annual costs (columns "physical_impacts" and "annual_impacts", respectively) across all states present in the data. aggregate_impacts() drops the columns "region", "state", and "postal" when summing over states and regions. Years which have missing column data for all states return as NA. Values for columns "region", "state", and "postal" are set to "National Total", All, and US, respectively. The data frame with national totals is then row-bound to the main results data frame. If "national" is included in aggLevels (e.g., aggLevels = "all"), aggregate_impacts() first aggregates over impact years and/or models (if "impactyear" and/or "modelaverage" are present in aggLevels or if aggLevels = "all") before aggregating over models.
impacttypeTo aggregate values over impact types, aggregate_impacts() sums annual impacts (column "annual_impacts") across all impact types for each sector. aggregate_impacts() drops the column "impactType" and "physicalmeasure" from the grouping columns when summing over impact types. Years which have missing column data for all impact types return as NA. All values in column "impactType" are set to "all". Aggregating over impact types, drops columns related to physical impacts (i.e., columns "physicalmeasure" and "physical_impacts"). These columns are dropped since aggregating over impact types for some sectors requires summing costs over different types of physical impacts, so reporting the physical impacts would be nonsensical.

After aggregating values, aggregate_impacts() joins the data frame of impacts with information about "driverType", "driverUnit", "driverValue", "gdp_usd", "national_pop", "gdp_percap", and "state_pop".

References

Environmental Protection Agency (EPA). 2021. Technical Documentation on The Framework for Evaluating Damages and Impacts (FrEDI). Technical Report EPA 430-R-21-004, EPA, Washington, DC. Available at https://epa.gov/cira/FrEDI/.

Examples

### Create temperature binning scenario
df_results1 <- run_fredi(aggLevels="none", silent=TRUE)
#> Checking scenarios...
#> Calculating impacts...
#> 		Formatting initial results...
#> 		Calculating temperature-driven scaled impacts...
#> 		Calculating SLR-driven scaled impacts...
#> Formatting results...
#> 
#> Finished.

### Aggregate temperature binning summary across multiple columns
df_results2 <- df_results1 |> aggregate_impacts(columns=c("annual_impacts"), aggLevels="all")