@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
@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