Cooling degree days of one day
Baselines: Energy Against Weather and Production
On this page
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:
- Explain why a past bill is not a baseline and name the drivers a baseline must include
- Calculate cooling degree days and choose a base temperature from the data
- Fit a simple and a multiple linear regression with
numpy.linalg.lstsqand read each coefficient as an engineering quantity - Judge a baseline with a residual plot, R², RMSE, CV(RMSE) and NMBE
- 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.
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.
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,
A straight line by least squares
The simplest baseline has one driver
Here
Least squares chooses
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
The computer does the arithmetic. Build a table 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
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.
| Pattern in the residuals | What it means |
|---|---|
| A curve | The shape is wrong: a straight line through a bent relation, or a wrong base temperature |
| Two separate bands | A yes or no driver is missing, such as weekday or a second shift |
| A band that widens with load | The scatter grows with the energy, so RMSE understates the error on high days |
| A slope against time | The building or the meter is changing: wear, added equipment, drift |
| A few points far from the band | Holidays, 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
Measures of fit
Four numbers summarise a baseline. Let
Goodness of fit of a baseline
RMSE, the root mean square error, is the typical size of a residual in kWh. The denominator is
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
-
Fit. The table
has two columns: ones and the temperature. Least squares gives The slope is 35.70 kWh for each °C. ✅
-
RMSE. Two coefficients were fitted, so
. A typical day is 91 kWh away from the line. ✅
-
R² and CV(RMSE).
The NMBE is 0.00 percent, as it must be in the fitting period. ✅
-
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. ✅ -
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
-
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. ✅
-
RMSE. Three coefficients, so
. The typical error has fallen from 91.24 to 27.30 kWh. ✅
-
R² and CV(RMSE).
The NMBE is again 0.00 percent by construction. ✅
-
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. ✅
-
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
-
Coefficients against truth.
Quantity True Model 2 95 percent interval Base load (kWh) 310 306.6 ± 6.1 kWh per degree day 42 41.61 ± 0.93 Weekday step (kWh) 180 182.1 ± 6.2 Noise (kWh) 28 27.30 (RMSE) Every true value lies inside the interval of its estimate. ✅
-
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. ✅
-
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. ✅
-
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
-
Refit model 2 with nine bases.
Base (°C) (kWh) (kWh per degree day) (kWh) RMSE (kWh) Days below 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 The RMSE is smallest at 18 °C. ✅
-
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
Step 1: The prediction error
Click to reveal the error of the prediction
-
Mean error. The error of a day is actual minus predicted.
The building used 3.58 kWh a day more than the baseline said. ✅
-
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. ✅
-
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
-
Difference of the totals.
The predicted total is 0.53 percent below the actual total. ✅
-
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. ✅
-
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. ✅ -
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
-
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. ✅ -
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. ✅
-
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.
"""An energy baseline by least squares: daily energy against weather and weekday (data set B)."""import numpy as npfrom scipy import statsimport 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 yearTEST = slice(365, 500) # later days, still before the measureT, W, E = temp[FIT], weekday[FIT], energy[FIT]n = E.sizeprint(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]) @ b2err = Et - predm = Et.sizeprint(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 kWhModel 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 degCModel 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 365Base 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 219Prediction 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 kWhOutside 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 kWhFitted 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 kWhSaved energy_baseline.pngIn 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.lstsqfits any number of drivers. For data set B the baseline iskWh 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)
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,
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
Answer
The means are 86 degree days and 13,200 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
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
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.
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?
- Daily energy against outdoor temperature, 41 days of the first year. Mild days stay flat; hot days climb.
- Above a base of 18 °C, each degree counts: a day at 24.5 °C has 6.5 cooling degree days.
- Least squares sets one line with the smallest squared residuals. They are still large, about 87 kWh.
- A weekday indicator gives two parallel lines. The typical residual falls to 27.3 kWh.
- Base load 306.6 kWh, 41.61 kWh for each degree day, and 182.1 kWh more on a weekday.
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.
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?
Discussion
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
My notes on this page
Kept on this device only. Nothing is sent anywhere.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
Notes on earlier wording
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.