USEPA / useeior

Estimating potential environmental impacts of goods and services in the US economy
MIT License
31 stars 19 forks source link

Fixes #262. Sets M and N to respective domestic versions in calculateEEIOmodel #263

Closed WesIngwersen closed 11 months ago

WesIngwersen commented 11 months ago

@bl-young please determine the best place to pull this fix into and merge when ready

Performed this test to check that this fix is valid

## Test that the fix to the FINAL perspective calc for domestic models is valid (useeior issue #262)

library(devtools)
load_all()

# Use a summary GHG model
model <- useeior::buildModel("USEEIOv2.0-s-GHG")

# First check that calculateEEIOModel with FINAL perspective and use_domestic_requirements=TRUE is the same as manual calculation

LCI_final <- calculateEEIOModel(model, perspective = "FINAL", demand = "Consumption", use_domestic_requirements = TRUE)$LCI_f

LCI_final_check <- calculateFinalPerspectiveLCI(model$M_d,model$DemandVectors$vectors$`2012_US_Consumption_Domestic`)
all.equal(LCI_final,LCI_final_check)

> TRUE

## LCI colsums (sum by flow) should be the same in both FINAL or DIRECT calcs. Check this is true.

LCI_final_sum <- colSums(LCI_final)

LCI_direct <- calculateEEIOModel(model, perspective = "DIRECT", demand = "Consumption", use_domestic_requirements = TRUE)$LCI_d

LCI_direct_sum <- colSums(LCI_direct)

all.equal(LCI_final_sum,LCI_direct_sum)

>TRUE