1-day ahead Load forecasting using AR and ARX models

조회 수: 7 (최근 30일)
Ben Russell
Ben Russell 2023년 3월 20일
답변: Nayan 2023년 4월 11일
Hi folks, I am trying to build both linear AR and ARX models to perform 1-day ahead load forecasting using historical electricity load data (And some exogenous parameters like temeperature). However, I am not getting expected results and can't figure out why. The code i am using is as follows:
%% Build an LINEAR Auto-regressive models of the form y(k) = a1y(k-1) + a2
% This is a first order AR model and we will use the AR function
sampleTime = 1;
IDdata = iddata(ModelTrainingData11, [], sampleTime, 'TimeUnit', 'Days');
trend = getTrend(IDdata, 0);
IDdata = detrend(IDdata, 0);
opts = arOptions('Approach', 'ls', 'window', 'ppw');
% Set model order (Here the order is 1, since we are only interested in
% the previous day)
modelOrder = 1; % Increase this to improve accuarcy.
% Build model
arModel = ar(IDdata, modelOrder, opts);
% Predict data to validate model performance
yp = predict(arModel, ModelTrainingData11, 1);
figure(1);
plot(yp, 'r');
hold on
plot(ModelTrainingData11, 'b'); %% MODEL WORKS OK
% Once we have validated the model, we use forecast.
[yPrediction] = forecast(arModel, IDdata, numel(ModelValidationData11));
% retrend
IDdata = retrend(IDdata, trend);
Y = retrend(yPrediction, trend);
predictedData = Y.OutputData;
% Compute performance stats
mse = mean((ModelValidationData11 - predictedData).^2);
rmse = sqrt(mse);
% Plot
figure(2);
plot(predictedData, 'r');
hold on
plot(ModelValidationData11, 'b');
title('order = ' + string(modelOrder) + ' AR model on electricty load'...
+ '|| Model RMSE : ' + string(rmse));
legend('predicted Data', 'Actual Data');
xlabel('Days');
ylabel('Electricity load (kW)');
The following plots show the training data (1), predicted data (on training set) and then the forecasted values plotted alongside the validation data (3).
I will make a separate Question for the ARX model, but essentially I am getting a similar problem where the model does not predict very well. Can anyone help with this?

답변 (1개)

Nayan
Nayan 2023년 4월 11일
Hi,
As I understand you are trying to train an order AR(1) model for forecasting from historical electricity load data. To design an AR model it is necessary to analyse the data closely and estimate the order of AR model required for the dataset. I would suggest yot to use the "[acf,lags] = autocorr(y)" in matlab for estimating the lag.
I would also suggest you to refer to the following link for better help :-
It would be easier to resolve any further query if you could share the dataset used in the question.
Hope this helps !

카테고리

Help CenterFile Exchange에서 Nonlinear ARX Models에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by