Created
September 11, 2021 22:28
-
-
Save baogorek/a5f10698c269aba86c89b8e8a4e7d7fe to your computer and use it in GitHub Desktop.
Environmentally Extended Input Output example with eeior and matrix math
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See Wiki @ https://github.com/USEPA/useeior/Wiki for install instructions | |
library(useeior) | |
seeAvailableModels() | |
# explanation of model names can be found at | |
# https://github.com/USEPA/USEEIO/blob/master/VersioningScheme.md | |
# LCI: direct perspective life cycle inventory result | |
# LCIA: life cycle impact assessment | |
# Build USEEIO v2.0-GHG | |
model <- buildModel("USEEIOv2.0s-GHG") | |
# Use the package function to calcuate CO2 emmissions | |
result <- calculateEEIOModel(model, perspective = "DIRECT", demand = "Production") | |
co2_by_sector <- result$LCI_d[, 1] | |
# Use the model matrices to calculate GHGs | |
y <- model$DemandVectors$vectors[["2012_US_Production_Complete"]] # Amt avail for consumption | |
x <- model$L %*% y # Total Output needed so that society can consume amount y | |
B <- diag(model$B[1, ]) # CO2 multiplier matrix | |
co2_by_sector2 <- B %*% x # 1rst row is CO2 | |
# Ensure they are effectively the same | |
cor(co2_by_sector, co2_by_sector2) | |
summary(co2_by_sector) | |
summary(co2_by_sector2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
History: