Code covered by the BSD License  

Highlights from
Electricity Load Forecasting for the Australian Market Case Study

image thumbnail

Electricity Load Forecasting for the Australian Market Case Study

by

 

19 Jun 2011 (Updated )

This is a case study of forecasting short-term electricity loads for the Australian market.

genPredictors(data, term, holidays)
function [X, dates, labels] = genPredictors(data, term, holidays)
% GENPREDICTORS generates a matrix of predictor variables for the price
% forecasting model. 
%
% USAGE:
% [X, dates, labels] = genPredictors(data, term, holidays)
%
% Inputs:
% data     : A Dataset array of historical weather, price and load information
% term     : 'long' or 'short' indicating the horizon of the forecast.
%            Predictors such as previous day load are not included in the 
%            long term forecast.
% holidays : A vector of holidays. If this is not specified, holidays are
%            generated by the function CREATEHOLIDAYDATES
%
% Outputs:
% X     : A matrix of predictor data where each row corresponds to an
%         observation (hourly load) and each column corresponds to a variable
% dates : A vector of dates for each observation
% labels: A cell array of strings describing each predictor


% Convert Dates into a Numeric Representation
if ~isfield(data,'NumDate')
    dates = datenum(data.Date, 'yyyy-mm-dd HH:MM:SS') + (data.Hour-1)/24;
else
    dates = data.NumDate;
    if all(floor(dates)==dates) % true if dates don't include any hour information
        dates = dates + (data.Hour-1)/24;
    end
end

% Process Holidays
if nargin < 3 || isempty(holidays)
    holidays = createHolidayDates(min(dates), max(dates));
else
    holidays = datenum(holidays);
end

% Create Predictors

% Short term forecasting inputs
% Lagged load inputs
prevDaySameHourLoad = [NaN(24,1); data.SYSLoad(1:end-24)];
prevWeekSameHourLoad = [NaN(168,1); data.SYSLoad(1:end-168)];
prev24HrAveLoad = filter(ones(1,24)/24, 1, data.SYSLoad);

% Lagged electricity price inputs
prevDaySameHourPrice = [NaN(24,1); data.ElecPrice(1:end-24)];
prevWeekSameHourPrice = [NaN(168,1); data.ElecPrice(1:end-168)];
prev24HrAvePrice = filter(ones(1,24)/24, 1, data.ElecPrice);

% Lagged fuel price inputs
prevDayNGPrice = [NaN(24,1); data.NGPrice(1:end-24)];
prevWeekAveNGPrice = filter(ones(1,168)/168, 1, data.NGPrice);

% Date predictors
dayOfWeek = weekday(dates);

% Non-business days
isWorkingDay = ~ismember(floor(dates),holidays) & ~ismember(dayOfWeek,[1 7]);
%[~,~,isWorkingDay] = createHolidayDates(data.NumDate);


if strncmpi(term, 'long', 4);
    % Long Term Forecast Predictors
    X = [data.DryBulb data.DewPnt daily5dayHighAve daily5dayLowAve data.Hour dayOfWeek isWorkingDay];
    labels = {'DryBulb', 'DewPoint', 'Prev5DayHighAve', 'Prev5DayLowAve', 'Hour', 'Weekday', 'IsWorkingDay'};
else
    % Short Term
    X = [data.DryBulb data.DewPnt data.Hour dayOfWeek isWorkingDay data.SYSLoad prevWeekSameHourLoad prevDaySameHourLoad prev24HrAveLoad...
        prevWeekSameHourPrice prevDaySameHourPrice prev24HrAvePrice prevDayNGPrice prevWeekAveNGPrice];
    labels = {'DryBulb', 'DewPoint', 'Hour', 'Weekday', 'IsWorkingDay', 'CurrentLoad', 'PrevWeekSameHourLoad', 'prevDaySameHourLoad', 'prev24HrAveLoad'...
        'PrevWeekSameHourPrice', 'prevDaySameHourPrice', 'prev24HrAvePrice', 'prevDayNGPrice', 'prevWeekAveNGPrice'};
end


function y = rep24(x)
y = repmat(x(:), 1, 24)';
y = y(:);

Contact us