diff --git a/R/BuildModel.R b/R/BuildModel.R index 9c0cbcfc..c1cd4fe7 100644 --- a/R/BuildModel.R +++ b/R/BuildModel.R @@ -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)...") diff --git a/R/WriteModel.R b/R/WriteModel.R index 514cd550..71a12ae4 100644 --- a/R/WriteModel.R +++ b/R/WriteModel.R @@ -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 = "",