Skip to content

Commit

Permalink
Re-organize model matrices in model$Matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLi7 committed May 5, 2021
1 parent 9fba136 commit 00b8c21
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/BuildModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ constructEEIOMatrices <- function(model) {
}
# Generate matrices
model$C_m <- generateCommodityMixMatrix(model) # normalized t(Make)
model$V <- as.matrix(model$MakeTransactions) # Make
model$V_n <- generateMarketSharesfromMake(model) # normalized Make
model$U <- as.matrix(dplyr::bind_rows(cbind(model$UseTransactions,

This comment has been minimized.

Copy link
@WesIngwersen

WesIngwersen May 25, 2021

Collaborator

@MoLi7 Did you ever check the rownames of U after using deplyr here to build it? The rownames are NULL. I discovered this only because the validation is breaking where it tries to index model$U by rowname.

This comment has been minimized.

Copy link
@MoLi7

MoLi7 May 25, 2021

Author Collaborator

Yes, last time I checked the rownames are viable. This commit was 20 days ago and after this I was able to run the validation script without any problem. I'm posting testing code in #134.

model$FinalDemand),
model$UseValueAdded)) # Use
model$U_d <- as.matrix(dplyr::bind_rows(cbind(model$DomesticUseTransactions,
model$DomesticFinalDemand),
model$UseValueAdded)) # DomesticUse
model$U_n <- generateDirectRequirementsfromUse(model, domestic = FALSE) #normalized Use
model$U_d_n <- generateDirectRequirementsfromUse(model, domestic = TRUE) #normalized DomesticUse
model$W <- as.matrix(model$UseValueAdded)
Expand Down Expand Up @@ -90,6 +97,12 @@ constructEEIOMatrices <- function(model) {
logging::loginfo("Calculating Phi matrix (producer over purchaser price ratio)...")
model$Phi <- calculateProducerbyPurchaserPriceRatio(model)

# Re-organize matrices in model$Matrices
model$Matrices
matrices <- c("V", "U", "U_d", "A", "A_d", "B", "C", "D", "L", "L_d", "M", "M_d", "N", "N_d", "Rho", "Phi")
model$Matrices <- model[matrices]
model[matrices] <- NULL

logging::loginfo("Model build complete.")
return(model)
}
Expand Down

0 comments on commit 00b8c21

Please sign in to comment.