📄 mrs_plot.m
字号:
function mrs_plot(PrSpike,Data)
%MRS_PLOT Plot calibration results for a 2-state MRS model.
% MRS_PLOT(PRSPIKE,DATA) generates a figure with two panels visualizing
% calibration results for a 2-state (Markov) regime switching model
% fitted to time series DATA. In the bottom panel probability PRSPIKE
% that an observation comes from the spike regime is plotted. In the top
% panel the time series is displayed with observations identified as
% belonging to the spike regime (i.e. having PRSPIKE>0.5) plotted in red.
%
% See also MRS_EST, MRS_SIM.
%
% Reference(s):
% [1] R.Weron (2007) 'Modeling and Forecasting Electricity Loads and
% Prices: A Statistical Approach', Wiley, Chichester.
% Written by Jakub Jurdziak and Rafal Weron (2006.09.21)
% Copyright (c) 2006 by Rafal Weron
% Define spike regime, non-spiky data and spiky data
SpikeInd = PrSpike > 0.5;
NonSpikyData = Data;
NonSpikyData(find(SpikeInd == 1)) = nan;
SpikeInd = min(length(Data),max(1,[find(SpikeInd == 1); find(SpikeInd == 1)+1; find(SpikeInd == 1)-1]));
SpikyData = nan*Data;
SpikyData(SpikeInd) = Data(SpikeInd);
% Plot data with red spikes
subplot(2,1,1)
plot(1:length(Data), SpikyData, 'red', 1:length(Data), NonSpikyData, 'black');
legend('spike', 'base');
ylabel('Data');
xlim([1 length(Data)]);
% Plot the probability of being in the spike regime
subplot(2,1,2);
plot(1:length(Data), PrSpike);
ylabel('Pr(spike)');
xlim([1 length(Data)]);
ylim([0 1]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -