How can i define and plot Prediction interval for non-parametric distribution?

2 views (last 30 days)
I want to do probabilistic forecast from point forecast. I do have error distribution (non parametric) from point forecast. I want to define and plot prediction interval within which the deand data may lie, with a certain probability.

Answers (1)

Shubham
Shubham on 12 Feb 2024
Hi israt,
To create a probabilistic forecast from a point forecast using a non-parametric error distribution, you can follow these steps:
  1. Point Forecast: Have your point forecast ready for the period you are interested in.
  2. Error Distribution: Have the historical forecast errors (actual - forecast) at hand.
  3. Determine the Confidence Level: Choose the confidence level for your prediction interval (e.g., 90%, 95%, 99%).
  4. Calculate the Prediction Interval: Use the empirical percentiles from the error distribution to find the bounds of the prediction interval.
  5. Plot the Prediction Interval: Visualize the point forecast and the prediction interval.
Here is a MATLAB script that demonstrates these steps:
% Point forecast for a certain period
point_forecast = 100;
% Historical forecast errors (actual - forecast)
errors = [-5, -3, -1, 0, 1, 2, 4, 5];
% Confidence level for the prediction interval
confidence_level = 0.95;
% Calculate the empirical percentiles of the error distribution
lower_percentile = (1 - confidence_level) / 2 * 100; % e.g., 2.5 for 95% confidence
upper_percentile = (1 + confidence_level) / 2 * 100; % e.g., 97.5 for 95% confidence
% Calculate the prediction interval bounds
lower_bound = point_forecast + prctile(errors, lower_percentile);
upper_bound = point_forecast + prctile(errors, upper_percentile);
% Plotting the point forecast and prediction interval
figure;
% Plot the point forecast
line([0, 1], [point_forecast, point_forecast], 'Color', 'blue', 'LineStyle', '-', 'LineWidth', 2);
hold on;
% Plot the prediction interval as a shaded area
fill([0, 1, 1, 0], [lower_bound, lower_bound, upper_bound, upper_bound], 'k', 'FaceAlpha', 0.1, 'EdgeColor', 'none');
% Set the plot labels and title
xlabel('Time');
ylabel('Forecast Value');
title('Point Forecast with Prediction Interval');
legend('Point Forecast', 'Prediction Interval', 'Location', 'Best');
% Adjust the limits of the x-axis
xlim([0, 1]);
hold off;
This MATLAB script will plot your point forecast as a horizontal line and shade the area between the lower and upper bounds of the prediction interval. Adjust the point_forecast and errors variables to match your actual data. If you have multiple point forecasts for different periods, you can extend the script to include those in the visualization.

Community Treasure Hunt

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

Start Hunting!