📄 decompb.m
字号:
function [stochc,stochcf,VYEAR]=decompB(L,cal_beg_i,cal_end_i,for_end_i);
%DECOMPB Moving average with rolling volatility daily data decomposition.
% [STOCHC,STOCHCF]=DECOMPB(L,CAL_BEG_I,CAL_END_I,FOR_END_IN) decomposes
% daily data L and returns stochastic components STOCHC and STOCHCF for
% the calibration period (CAL_BEG_I:CAL_END_I) and the full
% (CAL_BEG_I:FOR_END_I) period, respectively, using rolling volatility
% coupled with the moving average technique, see [1], Sections 2.4.3 and
% 2.4.5.
% [STOCHC,STOCHCF,VYEAR]=DECOMPB(L,CAL_BEG_I,CAL_END_I,FOR_END_IN)
% additionally returns the annual seasonal component VYEAR for the full
% (i.e. CAL_BEG_I:FOR_END_I) period.
%
% Reference(s):
% [1] R.Weron (2006) "Modeling and Forecasting Electricity Loads and
% Prices: A Statistical Approach", Wiley, Chichester.
% Written by Adam Misiorek and Rafal Weron (2006.09.22)
% Revised by Rafal Weron (2006.12.14)
% Copyright (c) 2006 by Rafal Weron
% Remove 7-day seasonality (moving average technique) in the calibration
% period (two years)
[L7,s7] = remst(L(cal_beg_i:cal_end_i),7,-1);
% Compute the stochastic component (rolling volatility technique) in
% the calibration period (two years)
vyear = rollingvol(L7);
stochc = logret(L7)./repmat(vyear,floor(length(L7)/length(vyear)),1);
% Full sample seasonal component (two calibration years + forecast years)
VYEAR = repmat(vyear,ceil((1+for_end_i-cal_beg_i)/365),1);
VYEAR = VYEAR(1:for_end_i-cal_beg_i);
% Remove 7-day seasonality (MA technique) using precomputed component in
% the whole sample (calibration + forecast periods)
L7f = remst(L(cal_beg_i:for_end_i),7,s7);
% Rescale the full sample by the annual season, i.e. compute the stochastic
% component for the full sample
stochcf = logret(L7f)./VYEAR;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -