moritzpschwarz / osem

A novel Open-Source Empircial Macro (OSEM) Model to study Climate Policies and the wider Macro-economy that can easily be applied to all EU countries
http://moritzschwarz.org/osem/
GNU Affero General Public License v3.0
5 stars 4 forks source link

Deal with log(0) -> -Inf situations #22

Open moritzpschwarz opened 1 year ago

moritzpschwarz commented 1 year ago

Consider:


specification <- dplyr::tibble(
  type = c(
    "d",
    "n",
    "n",
    "n",
    "n"
  ),
  dependent = c(
    "TOTS",
    "Import",
    "EmiCO2Combustion",
    "EmiCO2Industry",
    "GValueAddIndus"
  ),
  independent = c(
    "GValueAdd + Import",
    "FinConsExpHH + GCapitalForm",
    "HDD + CDD + HICP_Gas + HICP_Electricity + GValueAdd", # HERE IS THE PROBLEM
    "HICP_Gas + HICP_Electricity + GValueAddIndus",
    "HICP_Gas + HICP_Electricity + Export"
  )
)
print(specification)

model <- run_model(specification = specification,
                   dictionary = cur_dict,
                   inputdata_directory = "data-raw/EMCC",
                   primary_source = "local",
                   save_to_disk = "data-raw/EMCC/emcc_data.csv",
                   present = FALSE,
                   quiet = FALSE)

Note that isat() fails due to log(0) within CDD.

moritzpschwarz commented 4 months ago

This also applies to negative numbers in any x-variables

moritzpschwarz commented 4 months ago

And this is also relevant for forecasting - in this case, the auto option using auto.arima() is forecasting the exogenous variables to go negative

replicate.txt

# load the code in the txt file as faulty_model
forecast_model(faulty_model, n.ahead = 16, exog_fill_method = "auto")