Skip to content

Commit

Permalink
can't construct Phi if no margins, #290
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed May 16, 2024
1 parent 210b1cf commit dde2d8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions R/BuildModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ constructEEIOMatrices <- function(model, configpaths = NULL) {
logging::loginfo("Calculating Rho matrix (price year ratio)...")
model$Rho <- calculateModelIOYearbyYearPriceRatio(model)

# Calculate producer over purchaser price ratio.
logging::loginfo("Calculating Phi matrix (producer over purchaser price ratio)...")
model$Phi <- calculateProducerbyPurchaserPriceRatio(model)
if (model$specs$IODataSource!="stateior") {
# Calculate producer over purchaser price ratio.
logging::loginfo("Calculating Phi matrix (producer over purchaser price ratio)...")
model$Phi <- calculateProducerbyPurchaserPriceRatio(model)
}

# Calculate basic over producer price ratio.
logging::loginfo("Calculating Tau matrix (basic over producer price ratio)...")
Expand Down
7 changes: 5 additions & 2 deletions R/WriteModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,11 @@ writeModelMetadata <- function(model, dirs) {
years <- data.frame(ID=colnames(model$Rho), stringsAsFactors = FALSE)
years$Index <- c(1:length(years$ID)-1)
years <- years[, fields$years]
checkNamesandOrdering(years$ID, colnames(model$Phi),
"years in years.csv and cols in Phi matrix")

if(!is.null(model$Phi)) {
checkNamesandOrdering(years$ID, colnames(model$Phi),
"years in years.csv and cols in Phi matrix")
}
checkNamesandOrdering(years$ID, colnames(model$Rho),
"years in years.csv and cols in Rho matrix")
utils::write.csv(years, paste0(dirs$model, "/years.csv"), na = "",
Expand Down

0 comments on commit dde2d8f

Please sign in to comment.