Skip to content
You Start with one site
Amounts in Start with one site
Control, Measurement & Energy · Course

Baselines: Energy Against Weather and Production

Lesson 4 of 10 25 min read
Found this useful?

A building owner pays for new chiller controls and the next electricity bill is higher than the bill for the same month last year. The contractor says the month was hotter. The owner says the controls do not work. Neither of them can prove it, because last year’s bill was never a fair comparison: the weather was different, and so was the number of working days. A baseline ends the argument. It is a formula, fitted to past data, that says how much energy the site should use on any day, given the weather and what the site was doing. #EnergyBaseline #Regression #DegreeDays

Learning Objectives

By the end of this lesson, you will be able to:

  1. Explain why a past bill is not a baseline and name the drivers a baseline must include
  2. Calculate cooling degree days and choose a base temperature from the data
  3. Fit a simple and a multiple linear regression with numpy.linalg.lstsq and read each coefficient as an engineering quantity
  4. Judge a baseline with a residual plot, R², RMSE, CV(RMSE) and NMBE
  5. Test a baseline on days it has not seen, and state where it must not be used

Real-World System Problem: An office building before an energy measure



An office building has one electricity meter that is read every day, and a record of the mean outdoor temperature of each day. Most of its energy goes to cooling, lighting and office equipment. The owner plans an energy-saving measure on day 500 of the record and wants to know, afterwards, how much it saved.

The difficulty is that the building never uses the same energy twice. In the first year, weekdays used a mean of 629.5 kWh and weekend days 440.9 kWh. A 30-day mean was 733 kWh in the hot season and 444 kWh in the cool season. Any saving of 10 percent is smaller than these ordinary movements, so a comparison of raw bills cannot find it.

The cure is to learn, from a period before the measure, how the energy depends on its drivers. A driver is a measured quantity that causes the energy to change: the weather, the day of the week, and in a factory the quantity produced. The baseline then gives the energy the building would have used on any later day without the measure, and the meter gives what it did use.

CompareEnergy meterOutdoor tempBaselinemodelDay of week,productionpredictedgapmeasured
A baseline predicts what the meter should read

Fundamental Theory: Fitting energy to its drivers



Degree days

Below some outdoor temperature the cooling plant is idle and energy does not respond to the weather; above it, the cooling energy rises roughly in proportion to how far the day is above that temperature. The cooling degree days of one day put this into a number.

Cooling degree days of one day

is the mean outdoor temperature of the day and is the base temperature, both in °C.

With a base of 18 °C, a day at 24.5 °C has 6.5 cooling degree days, and a day at 15 °C has zero. Heating degree days are the same idea reversed, , for a site that is heated. The base temperature is a property of the building, not a universal constant, and a later section finds it from the data.

kWhaday·······slope: kWh per·······degree day·····base loadbaseoutdoor °Ctemperature
Energy against outdoor temperature

A straight line by least squares

The simplest baseline has one driver and two numbers to find.

Here is the daily energy, is the intercept, is the slope and is the residual, the part of that day’s energy the line does not explain. For a fitted line the predicted value is , and the residual of a day is .

Least squares chooses and so that the sum of the squared residuals is as small as possible. For one driver the result can be written directly:

The second expression says that the fitted line always passes through the point of the two means.

More than one driver

Real sites have several drivers at once. The model grows by one term for each:

In this lesson is the cooling degree days and is a weekday indicator: 1 on Monday to Friday and 0 on Saturday and Sunday. An indicator is how a yes or no fact enters a regression. In a factory, would be the units produced that day, and would be the energy for each unit.

The computer does the arithmetic. Build a table with one row for each day and one column for each term: a column of ones for , a column of degree days, a column of the indicator. Then numpy.linalg.lstsq(X, y, rcond=None) returns the coefficients that make the sum of squared residuals smallest.

Reading the coefficients as engineering quantities

A baseline is useful because its numbers mean something on the site.

  • is the base load: the energy of a weekend day with no cooling. Servers, standby equipment, ventilation and lights that are never switched off are all inside it.
  • is the weather sensitivity, in kWh per cooling degree day. It reflects the heat gain of the building and the efficiency of the cooling plant.
  • is the weekday step: the extra energy of a day when the building is occupied.

Each can be checked against the equipment. If is 300 kWh a day, something draws a steady 12.5 kW when nobody is there.

Residuals and the residual plot

The residuals are the most informative output of a fit. Plot them against the predicted energy, against each driver and against time. A sound model leaves a level band around zero with no shape; any pattern is information that the model has not used.

Good: a level bandBad: a curve+·· ···+·················0······0······ ·· ···········predicted energypredicted energy
Two residual plots
Pattern in the residualsWhat it means
A curveThe shape is wrong: a straight line through a bent relation, or a wrong base temperature
Two separate bandsA yes or no driver is missing, such as weekday or a second shift
A band that widens with loadThe scatter grows with the energy, so RMSE understates the error on high days
A slope against timeThe building or the meter is changing: wear, added equipment, drift
A few points far from the bandHolidays, shutdowns or bad data. Find the cause before you remove any

The intervals on the coefficients, and every “more than chance” test made with the RMSE, rest on three assumptions about the residuals: one day’s residual says nothing about the next (check the lag-1 autocorrelation of the residuals), their spread is the same at low and high load, and they are roughly symmetric about zero. Daily data from a real building often has a clearly positive , because hot spells and busy weeks last several days. Then the intervals are too narrow, as for the mean of correlated readings in how sure an average is.

Measures of fit

Four numbers summarise a baseline. Let be the number of days, the number of fitted coefficients and the mean energy.

Goodness of fit of a baseline

RMSE, the root mean square error, is the typical size of a residual in kWh. The denominator is and not , because each fitted coefficient consumes one piece of the data. CV(RMSE) is the same quantity as a fraction of the mean, so sites of different size can be compared. NMBE, the normalised mean bias error, shows whether the model is high or low on average. R² is the fraction of the variation in energy that the model explains.

Limits for a usable baseline come from ASHRAE Guideline 14, and two sets of them are often confused:

  • For a regression baseline at a whole-facility meter, as here, it asks for a CV(RMSE) of at most 20 percent when fewer than 12 months of reporting data will be used (25 percent for 12 to 60 months, 30 percent beyond), a bias over the baseline period of practically zero (it states 0.005 percent), and a savings uncertainty below 50 percent of the saving at 68 percent confidence.
  • The figures quoted most often, a CV(RMSE) of 15 percent with an NMBE within ± 5 percent for monthly data, and 30 percent with ± 10 percent for hourly data, are its tests for calibrating a simulation model. Many practitioners also apply them to regression baselines as a stricter screen.

Check the guideline itself for your case before you rely on a limit in a contract.

Choosing the base temperature

Fit the model several times, each time with degree days calculated to a different base, and compare the RMSE: the base with the smallest RMSE is the one the building itself shows. A base that is too low counts mild days as cooling days; a base that is too high ignores days when the plant was already running.

Overfitting

Every added term lowers the residuals in the fitting period, whether or not the term is real. A model with many terms and little data begins to fit the noise, and noise does not repeat, like a student who memorises last year’s exam answers and fails the new paper. The script shows it with 30 days of data. The honest model with 3 coefficients leaves residuals of 23.3 kWh and predicts the other 335 days of the year with an error of 30.8 kWh. With 6 coefficients the residuals fall to 21.6 kWh and the prediction error rises to 37.9 kWh. With 10 coefficients the residuals fall to 20.4 kWh and the prediction error is 17,358 kWh, which is nonsense.

Use drivers that have a physical reason to matter, keep the coefficients few against the number of days, and always test the model on days that were not used to fit it.

Extrapolation

A fitted model describes the range of conditions in its data and nothing outside it. If the hottest day in the fitting year was 29 °C, the model has never seen what the chiller does at 35 °C, yet it will still print a number. The plant may reach its capacity or a second chiller may start, and none of that is in the coefficients. State the range of each driver beside every baseline.

Application 1: Fit the baseline of the first year



Step 1: Model 1, temperature alone

Click to reveal model 1
  1. Fit. The table has two columns: ones and the temperature. Least squares gives

    The slope is 35.70 kWh for each °C. ✅

  2. RMSE. Two coefficients were fitted, so .

    A typical day is 91 kWh away from the line. ✅

  3. R² and CV(RMSE).

    The NMBE is 0.00 percent, as it must be in the fitting period. ✅

  4. Look at the residuals. The mean residual of the weekdays is +52.3 kWh and of the weekend days kWh. The residuals form two separate bands. The model is missing a yes or no driver. ✅

  5. Test the coefficients against the building. The intercept says the building uses kWh at 0 °C, and the line reaches zero energy at 4.86 °C. Neither is possible. ✅

Step 2: Model 2, cooling degree days and weekday

Click to reveal model 2
  1. Fit. The table has three columns: ones, the cooling degree days to base 18 °C, and the weekday indicator. Least squares gives

    The base load is 306.6 kWh a day, the weather sensitivity is 41.61 kWh per degree day, and the weekday step is 182.1 kWh. ✅

  2. RMSE. Three coefficients, so .

    The typical error has fallen from 91.24 to 27.30 kWh. ✅

  3. R² and CV(RMSE).

    The NMBE is again 0.00 percent by construction. ✅

  4. Look at the residuals. The lag-1 autocorrelation of the residuals is 0.09, close to zero, so one day’s error says little about the next. Of the 365 residuals, 18 are larger than twice the RMSE, which is 4.9 percent, about what random noise gives. The residuals are a level band. ✅

  5. Check a second way. A least squares fit passes through the means of all its columns. The mean degree days are 3.339 and the weekday fraction is .

    This agrees with the mean energy of 575.8 kWh within rounding. ✅

Step 3: Compare with the truth

Data set B is made by a formula, so for once the true values are known. Before day 500 the generator uses a base load of 310 kWh, 42 kWh per cooling degree day to base 18 °C, 180 kWh more on weekdays, and random noise with a standard deviation of 28 kWh.

Click to reveal the comparison
  1. Coefficients against truth.

    QuantityTrueModel 295 percent interval
    Base load (kWh)310306.6± 6.1
    kWh per degree day4241.61± 0.93
    Weekday step (kWh)180182.1± 6.2
    Noise (kWh)2827.30 (RMSE)

    Every true value lies inside the interval of its estimate. ✅

  2. What the RMSE measures. The RMSE of 27.30 kWh is an estimate of the noise of 28 kWh, the part of the energy that no driver explains. ✅

  3. Why model 1 failed with the same data. Model 1 gave 35.70 kWh per °C against a true 42. It drew one line through the flat part below 18 °C and the rising part above it, so the slope is a mixture of zero and 42. It had no weekday term, so the weekday step of 180 kWh stayed in the residuals. ✅

  4. A warning about thresholds. Model 1 has a CV(RMSE) of 15.85 percent. Against the 20 percent of Guideline 14 for a whole-facility baseline it passes, and it is a poor baseline. The thresholds are a minimum. The residual plot is the real test. ✅

Step 4: Check the base temperature

Click to reveal the base temperature search
  1. Refit model 2 with nine bases.

    Base (°C) (kWh) (kWh per degree day) (kWh)RMSE (kWh)Days below base
    14196.835.39184.037.392
    15229.535.79183.636.209
    16259.136.78182.933.5927
    17284.838.64182.529.6553
    18306.641.61182.127.3089
    19324.045.90183.230.96123
    20341.451.32183.739.93153
    21357.059.11182.850.26191
    22373.070.28179.861.20219

    The RMSE is smallest at 18 °C. ✅

  2. Read the table. The weekday step hardly moves, from 179.8 to 184.0 kWh, because it does not depend on the weather. The base load and the slope move a great deal: from 196.8 to 373.0 kWh and from 35.39 to 70.28 kWh per degree day. A wrong base gives a wrong base load. The search needs days on both sides of the base: at 18 °C there are 89 days below it and 276 above. ✅

Application 2: Test the baseline on days it has not seen



aftermeasuretest135 daysfitting year(365 days)day 0365500729coefficientspredictionsavingscomefromherechecked here (later)
Fit on one period, test on another

Step 1: The prediction error

Click to reveal the error of the prediction
  1. Mean error. The error of a day is actual minus predicted.

    The building used 3.58 kWh a day more than the baseline said. ✅

  2. RMSE of the prediction. No coefficient was fitted to these days, so the denominator is the number of days.

    The RMSE on new days is 28.79 kWh, against 27.30 kWh in the fitting year. ✅

  3. Judge it. A model that has fitted noise does much worse on new days than on its own. This one is 1.5 kWh worse. The baseline is sound. ✅

Step 2: The total energy

Click to reveal the comparison of totals
  1. Difference of the totals.

    The predicted total is 0.53 percent below the actual total. ✅

  2. NMBE on the test period. The mean actual energy is kWh a day.

    This is well inside the ± 5 percent often used as a screen, and on new days it is a real test. ✅

  3. Is 484 kWh more than chance? If the daily errors are independent, the error of a sum of days is about .

    The difference of 484 kWh is 1.5 times this value, which is ordinary random variation. The rule needs independent errors, and the residuals here have . With correlated errors, multiply by , as for a mean: here that gives 346 kWh, and the conclusion stands. ✅

  4. Check a second way. The mean error times the number of days must return the difference of the totals: kWh, which agrees with 484 kWh within rounding. The script prints the same values from the daily data. ✅

Step 3: Where the baseline stops

Click to reveal the limit of use
  1. Range of the fitting year. The hottest day was 29.0 °C, which is 11.0 cooling degree days. On a weekday at 29.0 °C the baseline gives 945 kWh, and the standard error of that fitted value is 4.0 kWh. That 4.0 kWh is the uncertainty of the mean of all such days, the confidence interval of the line. One single day also has its own noise, so the prediction interval of one day uses kWh: kWh at 95 percent (). Use the prediction interval when you check one day’s meter reading against the baseline. ✅

  2. A day at 35 °C. The formula gives

    Its standard error is 6.6 kWh, larger because the day is far from the centre of the data. But that standard error still assumes the straight line continues for 6 °C beyond the last day that was measured. Nothing in the data supports that. ✅

  3. State the limit. This baseline is valid for mean daily temperatures from 12.6 to 29.0 °C and for the building as it was in the fitting year. The 135 test days lie between 17.7 and 28.6 °C, inside that range, which is one reason the prediction worked. ✅

Verify It in Python



The script makes data set B with a fixed seed and reproduces every number of this lesson. It saves one plot: the daily energy against temperature with the fitted lines of model 2, and the residuals of model 2.

energy_baseline.py
"""An energy baseline by least squares: daily energy against weather and weekday (data set B)."""
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
def building_daily(seed=23, days=730):
rng = np.random.default_rng(seed)
d = np.arange(days)
temp = 21.0 + 4.5 * np.sin(2 * np.pi * (d - 20) / 365.0) + rng.normal(0, 1.6, days)
weekday = (d % 7) < 5 # day 0 is a Monday
cdd = np.clip(temp - 18.0, 0.0, None) # cooling degree days, base 18 °C
energy = 310.0 + 42.0 * cdd + np.where(weekday, 180.0, 0.0) + rng.normal(0, 28.0, days)
# an energy-saving measure is installed on day 500: 12 percent less from then on
energy[500:] *= 0.88
return d, temp, weekday, energy # kWh a day
def fit(X, y):
"""Least squares. Returns coefficients, R2, RMSE, CV(RMSE), NMBE and residuals."""
b, *_ = np.linalg.lstsq(X, y, rcond=None)
res = y - X @ b
n, p = X.shape
rmse = np.sqrt((res ** 2).sum() / (n - p))
r2 = 1.0 - (res ** 2).sum() / ((y - y.mean()) ** 2).sum()
nmbe = round(res.sum() / ((n - p) * y.mean()), 6) + 0.0
return b, r2, rmse, rmse / y.mean(), nmbe, res
def design(temp, weekday, base=18.0):
"""Columns: 1, cooling degree days to the given base, weekday (1 or 0)."""
cdd = np.clip(temp - base, 0.0, None)
return np.column_stack([np.ones(temp.size), cdd, weekday.astype(float)])
d, temp, weekday, energy = building_daily()
FIT = slice(0, 365) # the fitting year
TEST = slice(365, 500) # later days, still before the measure
T, W, E = temp[FIT], weekday[FIT], energy[FIT]
n = E.size
print(f"Fitting year: n = {n}, mean energy = {E.mean():.1f} kWh, "
f"temperature {T.min():.1f} to {T.max():.1f} degC")
print(f" weekdays: mean {E[W].mean():.1f} kWh, weekend days: mean {E[~W].mean():.1f} kWh")
print(" 30-day means from days 0, 90, 180, 270: "
+ ", ".join(f"{E[k:k + 30].mean():.0f}" for k in (0, 90, 180, 270)) + " kWh")
# ---------- Model 1: temperature alone ----------
b1, r2, rmse1, cv, nmbe, res1 = fit(np.column_stack([np.ones(n), T]), E)
print("Model 1: energy = b0 + b1 * temperature")
print(f" b0 = {b1[0]:.1f} kWh, b1 = {b1[1]:.2f} kWh per degC")
print(f" R2 = {r2:.4f}, RMSE = {rmse1:.2f} kWh, CV(RMSE) = {100 * cv:.2f} %, "
f"NMBE = {100 * nmbe:.2f} %")
print(f" sum of squared residuals = {(res1 ** 2).sum():.0f}")
print(f" mean residual: weekdays {res1[W].mean():+.1f} kWh, "
f"weekend days {res1[~W].mean():+.1f} kWh")
print(f" energy falls to zero at {-b1[0] / b1[1]:.2f} degC")
# ---------- Model 2: cooling degree days and weekday ----------
X2 = design(T, W)
b2, r2, rmse2, cv2, nmbe, res2 = fit(X2, E)
print("Model 2: energy = b0 + b1 * CDD(18) + b2 * weekday")
print(f" b0 = {b2[0]:.1f} kWh, b1 = {b2[1]:.2f} kWh per degree day, b2 = {b2[2]:.1f} kWh")
print(f" R2 = {r2:.4f}, RMSE = {rmse2:.2f} kWh, CV(RMSE) = {100 * cv2:.3f} %, "
f"NMBE = {100 * nmbe:.2f} %")
cov = rmse2 ** 2 * np.linalg.inv(X2.T @ X2)
half = stats.t.ppf(0.975, n - 3) * np.sqrt(np.diag(cov))
print(f" 95 % intervals: b0 +/- {half[0]:.1f}, b1 +/- {half[1]:.2f}, b2 +/- {half[2]:.1f}")
print(f" sum of squared residuals = {(res2 ** 2).sum():.0f}, "
f"total sum of squares = {((E - E.mean()) ** 2).sum():.0f}")
print(f" mean CDD = {X2[:, 1].mean():.3f}, weekdays = {W.sum()} of {n}")
print(f" r1 of the residuals = {np.corrcoef(res2[:-1], res2[1:])[0, 1]:.2f}, "
f"residuals beyond 2 RMSE: {(np.abs(res2) > 2 * rmse2).sum()} of {n}")
# ---------- Choosing the base temperature ----------
print("Base temperature (degC), b0, b1, b2, RMSE (kWh), days below the base")
for base in range(14, 23):
bb, _, rm, _, _, _ = fit(design(T, W, base), E)
print(f" {base}: {bb[0]:6.1f} {bb[1]:6.2f} {bb[2]:6.1f} {rm:5.2f} {(T < base).sum():3d}")
# ---------- Application 2: predict days 365 to 499 ----------
Et = energy[TEST]
pred = design(temp[TEST], weekday[TEST]) @ b2
err = Et - pred
m = Et.size
print(f"Prediction of days 365 to 499: {m} days, "
f"temperature {temp[TEST].min():.1f} to {temp[TEST].max():.1f} degC")
print(f" mean error (actual - predicted) = {err.mean():+.2f} kWh a day")
print(f" sum of squared errors = {(err ** 2).sum():.0f}, "
f"RMSE of the prediction = {np.sqrt((err ** 2).mean()):.2f} kWh")
print(f" predicted total = {pred.sum():.0f} kWh, actual total = {Et.sum():.0f} kWh")
print(f" difference = {pred.sum() - Et.sum():+.0f} kWh "
f"= {100 * (pred.sum() - Et.sum()) / Et.sum():+.2f} % of actual")
print(f" NMBE of the prediction = {100 * err.sum() / (m * Et.mean()):+.2f} %")
print(f" RMSE x sqrt({m}) = {rmse2 * np.sqrt(m):.0f} kWh")
# ---------- Extrapolation ----------
print("Outside the range of the fitting year (weekday)")
for t_out in (T.max(), 35.0):
v = np.array([1.0, max(t_out - 18.0, 0.0), 1.0])
print(f" {t_out:.1f} degC: model 2 gives {v @ b2:.0f} kWh, "
f"standard error of the fitted mean {np.sqrt(v @ cov @ v):.1f} kWh")
# ---------- Overfitting: 30 days of data, more and more parameters ----------
def poly_design(temp, weekday, degree):
cols = [design(temp, weekday)]
z = (temp - 21.0) / 4.0
cols += [(z ** k)[:, None] for k in range(2, degree + 1)]
return np.hstack(cols)
print("Fitted on days 0 to 29 only, tested on days 30 to 364")
for degree in (1, 4, 8):
Xa = poly_design(T[:30], W[:30], degree)
ba, *_ = np.linalg.lstsq(Xa, E[:30], rcond=None)
inside = np.sqrt(((E[:30] - Xa @ ba) ** 2).mean())
outside = np.sqrt(((E[30:] - poly_design(T[30:], W[30:], degree) @ ba) ** 2).mean())
print(f" {Xa.shape[1]:2d} parameters: residual RMS {inside:.1f} kWh, "
f"prediction RMSE {outside:.1f} kWh")
# ---------- Plot ----------
fig, ax = plt.subplots(2, 1, figsize=(8, 8))
ax[0].plot(T[W], E[W], ".", label="weekday")
ax[0].plot(T[~W], E[~W], ".", label="weekend day")
tt = np.linspace(T.min(), T.max(), 200)
for flag, style in ((1.0, "-"), (0.0, "--")):
ax[0].plot(tt, b2[0] + b2[1] * np.clip(tt - 18.0, 0.0, None) + b2[2] * flag,
"k" + style, linewidth=1.0)
ax[0].set_xlabel("mean outdoor temperature (degC)")
ax[0].set_ylabel("energy (kWh a day)")
ax[0].set_title("Daily energy and the fitted baseline (model 2)")
ax[0].legend()
ax[1].plot(X2 @ b2, res2, ".")
ax[1].axhline(0.0, color="gray", linewidth=0.8)
ax[1].axhline(2 * rmse2, color="gray", linewidth=0.8, linestyle=":")
ax[1].axhline(-2 * rmse2, color="gray", linewidth=0.8, linestyle=":")
ax[1].set_xlabel("predicted energy (kWh a day)")
ax[1].set_ylabel("residual (kWh)")
ax[1].set_title("Residuals of model 2: a level band with no pattern")
fig.tight_layout()
fig.savefig("energy_baseline.png", dpi=120)
print("Saved energy_baseline.png")

Expected output

Fitting year: n = 365, mean energy = 575.8 kWh, temperature 12.6 to 29.0 degC
weekdays: mean 629.5 kWh, weekend days: mean 440.9 kWh
30-day means from days 0, 90, 180, 270: 557, 733, 577, 444 kWh
Model 1: energy = b0 + b1 * temperature
b0 = -173.5 kWh, b1 = 35.70 kWh per degC
R2 = 0.6531, RMSE = 91.24 kWh, CV(RMSE) = 15.85 %, NMBE = 0.00 %
sum of squared residuals = 3021881
mean residual: weekdays +52.3 kWh, weekend days -131.2 kWh
energy falls to zero at 4.86 degC
Model 2: energy = b0 + b1 * CDD(18) + b2 * weekday
b0 = 306.6 kWh, b1 = 41.61 kWh per degree day, b2 = 182.1 kWh
R2 = 0.9690, RMSE = 27.30 kWh, CV(RMSE) = 4.741 %, NMBE = 0.00 %
95 % intervals: b0 +/- 6.1, b1 +/- 0.93, b2 +/- 6.2
sum of squared residuals = 269698, total sum of squares = 8711427
mean CDD = 3.339, weekdays = 261 of 365
r1 of the residuals = 0.09, residuals beyond 2 RMSE: 18 of 365
Base temperature (degC), b0, b1, b2, RMSE (kWh), days below the base
14: 196.8 35.39 184.0 37.39 2
15: 229.5 35.79 183.6 36.20 9
16: 259.1 36.78 182.9 33.59 27
17: 284.8 38.64 182.5 29.65 53
18: 306.6 41.61 182.1 27.30 89
19: 324.0 45.90 183.2 30.96 123
20: 341.4 51.32 183.7 39.93 153
21: 357.0 59.11 182.8 50.26 191
22: 373.0 70.28 179.8 61.20 219
Prediction of days 365 to 499: 135 days, temperature 17.7 to 28.6 degC
mean error (actual - predicted) = +3.58 kWh a day
sum of squared errors = 111865, RMSE of the prediction = 28.79 kWh
predicted total = 90526 kWh, actual total = 91010 kWh
difference = -484 kWh = -0.53 % of actual
NMBE of the prediction = +0.53 %
RMSE x sqrt(135) = 317 kWh
Outside the range of the fitting year (weekday)
29.0 degC: model 2 gives 945 kWh, standard error of the fitted mean 4.0 kWh
35.0 degC: model 2 gives 1196 kWh, standard error of the fitted mean 6.6 kWh
Fitted on days 0 to 29 only, tested on days 30 to 364
3 parameters: residual RMS 23.3 kWh, prediction RMSE 30.8 kWh
6 parameters: residual RMS 21.6 kWh, prediction RMSE 37.9 kWh
10 parameters: residual RMS 20.4 kWh, prediction RMSE 17358.0 kWh
Saved energy_baseline.png

In the upper plot the points form two bands, weekdays above weekend days, each flat below 18 °C and rising above it. In the lower plot the residuals lie in a level band.

Common Mistakes



  • Comparing this year’s bill with last year’s and calling the difference a saving. Compare the meter with a baseline adjusted to this year’s weather and working days.
  • Fitting energy against raw temperature when part of the year is below the base temperature. Use degree days, and find the base from the data.
  • Taking a high R² as proof. Look at the residual plot and at RMSE in kWh.
  • Quoting NMBE from the fitting period. It is zero by construction there. Quote it for days that were not used in the fit.
  • Using the baseline outside the range of temperature and production in its data, or after the building itself has changed.

Summary



  • A baseline is a fitted formula for the energy a site should use, given its drivers. A past bill is not a baseline, because the drivers were different.
  • Cooling degree days, , describe a building that does not respond to weather below its base temperature. The base is found by trying several and taking the smallest RMSE.
  • numpy.linalg.lstsq fits any number of drivers. For data set B the baseline is kWh a day, with RMSE 27.30 kWh and CV(RMSE) 4.74 percent. Its coefficients are the base load, the weather sensitivity and the weekday step.
  • Residuals must look like noise. A pattern means a missing driver or a wrong shape.
  • A baseline must be tested on days outside the fit, and it is valid only inside the range of its data. Here it predicted 135 new days within 0.53 percent.

Exercises



1. Use model 2 of this lesson to predict the energy of (a) a Wednesday with a mean temperature of 24.0 °C and (b) a Sunday at 15.0 °C.

Answer

(a) , so kWh. (b) and the indicator is 0, so the prediction is the base load, 307 kWh.

2. A model with two coefficients was fitted to six days. The actual energies are 520, 610, 480, 700, 655 and 590 kWh, and the predictions are 505, 630, 470, 690, 670 and 600 kWh. Find the RMSE, the CV(RMSE) and the NMBE.

Answer

The residuals are 15, , 10, 10, and . Their squares sum to 1,150 and they sum to . kWh. The mean energy is 592.5 kWh, so percent and percent.

3. A cold store has monthly energy of 10,400, 12,100, 14,300, 15,800 and 13,400 kWh in months with 20, 60, 110, 150 and 90 cooling degree days. Fit a straight line by the formulas for and . State the base load and predict a month with 130 degree days.

Answer

The means are 86 degree days and 13,200 kWh. and , so kWh per degree day and kWh a month, which is the base load. For 130 degree days the prediction is kWh.

4. Change the script to fit model 2 on days 0 to 179 only, and predict days 180 to 364. Give the coefficients, the RMSE of the fit, and the mean error, RMSE and percentage difference of the totals for the prediction.

Answer

Use fit(X2[:180], E[:180]) and predict with X2[180:] @ b. The coefficients are 312.7, 41.11 and 177.7, with RMSE 26.79 kWh. On days 180 to 364 the mean error is kWh a day, the RMSE is 28.06 kWh, and the predicted total is 0.54 percent above the actual total. Half a year is enough here because it contains both cool and hot days.

5. Change the script to fit energy against raw temperature and the weekday indicator, with no base temperature. Give the coefficients, RMSE and CV(RMSE), and explain why this model is worse than model 2 although it has the same number of coefficients.

Answer

Use np.column_stack([np.ones(n), T, W.astype(float)]). The result is with RMSE 37.78 kWh and CV(RMSE) 6.56 percent, against 27.30 kWh for model 2. The weekday step is found correctly, but 89 of the 365 days are below 18 °C, where energy does not respond to temperature. A straight line cannot be flat on one side and rising on the other.

References



  • D. C. Montgomery and G. C. Runger, Applied Statistics and Probability for Engineers, 7th edition, Wiley, 2018.
  • ASHRAE, Guideline 14: Measurement of Energy, Demand, and Water Savings, 2014.
  • Efficiency Valuation Organization, International Performance Measurement and Verification Protocol: Core Concepts, 2016.


© 2021-2026 SiliconWit®. All rights reserved.
Outdoor temp Day of week, production Energy meter Baseline model Compare predicted measured gap
A baseline predicts what the meter should read
Good: a level band + 0 - predicted energy Bad: a curve + 0 - predicted energy example points
Two residual plots
fitting year (365 days) test 135 days after measure day 0 day 365 day 500 day 729 coefficients come from here prediction checked here savings (later) to scale: one year, then 135 days, then the days after the measure
Fit on one period, test on another
Predict first

New chiller controls are installed in a building. The next electricity bill is 8 percent higher than the bill for the same month last year. What does this show?

Watch it build: a baseline
400800 12182430 °C 24.5 °C is 6.5 degree days one line: residuals 87 kWh weekday and weekend: 27.3 41 days: kWh against °C b₀ 306.6 b₂ 182.1 b₁ 41.61 a degree day three numbers, each a meaning
  1. Daily energy against outdoor temperature, 41 days of the first year. Mild days stay flat; hot days climb.
  2. Above a base of 18 °C, each degree counts: a day at 24.5 °C has 6.5 cooling degree days.
  3. Least squares sets one line with the smallest squared residuals. They are still large, about 87 kWh.
  4. A weekday indicator gives two parallel lines. The typical residual falls to 27.3 kWh.
  5. Base load 306.6 kWh, 41.61 kWh for each degree day, and 182.1 kWh more on a weekday.
See it: fit the baseline by hand, then by least squares

RMSE
CV(RMSE)
NMBE
R²
Mean residual, weekdays
Mean residual, weekend days

The points are the lesson's own data: the 365 days of the fitting year of data set B, stored in this page. The model is energy = b₀ + b₁ × CDD + b₂ × weekday, where CDD is the day's temperature above the base temperature, or zero. The solid line is the model for a weekday and the dashed line is the model for a weekend day. The strip shows the residual of each day, actual minus predicted, against the day number. A sound model leaves a level band around zero. The four measures are calculated here from the 365 points, with n − p = 362 for the three coefficients. "Best fit" solves the least squares for the base temperature you have chosen. It does not choose the base temperature: try several and compare the RMSE. "Temperature only" is the lesson's model 1, one straight line through the raw temperature, with n − p = 363.

base 18 °C12 °C30 °C base load b₀: 307weekday b₂: +182slope b₁: 41.6 kWh per degree day kWh a day. Check each number against the equipment.
23.330.8 21.637.9 20.417,358 3 terms6 terms10 terms error on the 30 fitted dayserror on 335 new days (kWh) Test every model on days it has not seen.

Check yourself

Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.

1. The baseline is 306.6 + 41.61 × CDD + 182.1 × weekday, with a base temperature of 18 °C. What does it predict for a Saturday with a mean temperature of 25.0 °C?

2. Model 1, energy against temperature alone, has an NMBE of 0.00 percent in the fitting year. Model 2 also has 0.00 percent. What does this say about model 1?

3. Model 2 is fitted again with a base temperature of 21 °C in place of 18 °C. The RMSE rises from 27.30 to 50.26 kWh. What happens to the coefficients?

Found this useful?

Discussion

    Comments show your name. Be kind, stay on the topic.