The multivariable linear regression analysis is used to create a model of a single variable, typically an energy consumption. We call this the dependent variable. The model is constructed as a linear combination of explanatory variables, like weather measurements or occupation. More information can be found on wikipedia.
The model is static. This means that the data set should not contain dynamic effects. For buildings, dynamic effects are mostly neglegible on a weekly basis unless the building has a very high thermal inertia.
Typical use of this analysis is to create a model of eg. the gas consumption of a building, and then use this model to detect and quantify changes in the gas consumption. For example, the savings resulting from a new gas boiler can be computed as the difference between the consumption predicted by the model and the actual consumption.
In [1]:
import opengrid as og
import pandas as pd
plt = og.plot_style()
In [2]:
df = og.datasets.get('gas_2016_hour')
# for this demo, we only compute a model for the sensor 313b
df = df[['313b']]
# load weather
dfw = og.datasets.get('weather_2016_hour')
First we compute heating degree-days for different base temperatures. More information on the computation of degree-days can be found in this demo.
In [3]:
%matplotlib inline
In [4]:
# resample weather data to daily values and compute degree-days
dfw = dfw.resample('D').mean()
dfw_HDD = og.library.weather.compute_degree_days(ts=dfw['temperature'],
heating_base_temperatures=range(8, 18, 2),
cooling_base_temperatures=range(16, 26, 2)).bfill()
In [5]:
# resample the gas consumption to daily values and add the weather data and the degree-days
df_day = df.resample('D').sum()/1000. # kWh/day
df_day = pd.concat([df_day, dfw, dfw_HDD], axis=1).loc['2016']
In [6]:
# resample to monthly data and plot
df_month = df_day.resample('MS').sum()
In [7]:
# create the model
mvlr = og.MultiVarLinReg(df_month, endog='313b')
In [8]:
print(mvlr.fit.summary())
mvlr.plot()
Out[8]:
In [ ]: