Skip to content

Commit

Permalink
Use household consumption instead of complete consumption as y vector…
Browse files Browse the repository at this point in the history
… for exporting useeior data for SPA
  • Loading branch information
jvendries committed Mar 8, 2024
1 parent 316168b commit d4bc671
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/SPAFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,30 @@ exportModelObjectsForMatlab <- function(model, filename = "matlab_data") {

library(R.matlab) # load matlab library
data <- list()


# List objects that are needed to Run SPA in Matlab
A <- model$A
L <- model$L
EIOsecnames <- model$Commodities$Name
EIOsecs <- model$Commodities$Code
final_ConsumptionComplete <- as.matrix(model$DemandVectors$vectors$`2012_US_Consumption_Household`)
EIvect <- model$C %*% model$B
indicatorNames <- rownames(model$C)
flowNames <- rownames(model$B)
y <- as.matrix(model$DemandVectors$vectors$`2012_US_Consumption_Household`) # Get Household consumption vector
y[which(y < 0)] <-0 # Remove negative inputs into household consumption


# Format filename
filename <- paste(filename, ".mat", sep = "")
# Write as a .mat file
writeMat(filename,
A = A,
L = L,
EIOsecnames = EIOsecnames,
EIOsecs = EIOsecs,
y = final_ConsumptionComplete,
EIvect = EIvect,
indicatorNames = indicatorNames,
flowNames = flowNames
flowNames = flowNames,
y = y
)


Expand Down

0 comments on commit d4bc671

Please sign in to comment.