Understand model

Updated 2021-04-08 By simularis

This blog post answers some questions about your baseline model generated in RMV2.0. However, you will need to use my fork of RMV2.0 to generate the model and save the project to a project.rds file. E.g. use this command in RStudio to install this version of RMV2.0.

devtools::install_github("simularis/RMV2.0")

What information was missing in project files before my updates to RMV2.0?

What ideas are not yet put in place here?

About this post

This is a technical article that does not discuss using RMV2.0. It just shows details of the regression model that are not available to find using the tool. There are other solutions for these problems: write your own script, or try another NMEC tool like nmecr or open-eemeter.

The blog is generated from a Jupyter notebook with the IRkernel, which is fairly easy to install with conda. This is convenient if you already use Python. You can also use the R script understand_model.R from the repository to try out the code. Wherever you see a box like below, that is the command sent to R and its output.

If you need to look up basic syntax or built-in data types, try these:

Load libraries

Read the "project.rds" file stored by RMV2.0

There Project object is a list. Elements of the list can be any data type. To understand what was stored, we want to look at a few important elements:

Note that Data_pre_2_2.csv was the name of the data file when we created the model. That name is used to organize the data, in case we had multiple models in the project. We can also refer to that element as models_list[[1]].

As we dive in to explore, note that there is some redundant information and obvious names, so I won't explain it all.

image.png

models[["Data_pre_2_2.csv"]]$train stores the data used to train regression models, including load and temperature.

image.png

In the towt_model data structure:

image-2.png

Here is the regression model data structure for the first block, regOutList[[1]]. Note:

image-10.png

The amod element is the output of a call to the lm function which performs regression (linear model).

image-4.png

The occupied periods include only some of the time-of-week hours (e.g. 33, 34, ...), which are called the levels of the ftow factor. Other levels (e.g. 1, 2, ...) appear in the bmod linear model for unoccupied periods.

image-8.png

Here we can also see the coefficients. To count them up,

All together, there are 80 coefficients in the amod linear model.

image-5.png

image-6.png

In the bmod linear model, we can see a different set of coefficients for the ftow factor.

image-10.png

Now that we know a little about the stored data structure, let's start scripting something useful.

These commands will just print text info summary of the project file structure.

Here is how RMV2.0 actually used the hyperparameter, timescaleDays, to determine the season blocks.

Note