Forecasting / Input response series data must be non-empty and a column vector.
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello i am trying to creat a simple forecasting algo for long terms (foraward 10 yrs based on the data from yrs back ) so my code is below, when i run it, i got this error
Input response series data must be non-empty and a column vector.
Error in Untitled2 (line 18)
EstMdl = estimate(Mdl,data);
Please some help guys.
.
.
.
load data
yrs = evolutiondelademand.VarName1;
demand = evolutiondelademand.VarName2;
A= [yrs,demand];
data = iddata(A,[]);
plot (yrs,demand)
%%figure
plot(yrs,demand)
xlabel('years')
ylabel('demand')
past_data = data.OutputData(1:50);
Mdl = arima(2,0,0);
opt = forecastOptions('InitialCondition','e');
K = 100;
EstMdl = estimate(Mdl,data);
[yF,yMSE] = forecast(EstMdl,60,'Y0',data);
legend('Measured','Forecasted')
0 commentaires
Réponses (1)
Pavl M.
le 21 Nov 2024 à 12:49
Modifié(e) : Pavl M.
le 21 Nov 2024 à 14:10
%load data
%yrs = evolutiondelademand.VarName1;
%demand = evolutiondelademand.VarName2;
odata = xlsread('TitanX Historical Numbers.xlsx');
Dlength = 88;
ts = 1
time = (0:ts:Dlength-1)' %odata(1:Dlength,1) % Time column (1st column)
demand = odata(1:Dlength,2)
%areTimestampsRegular = isregular(demand)
areTimestampsSorted = issorted(demand)
%w = convert2weekly(odata,Aggregation="mean")
%areTimestampsWRegular = isregular(w,"years")
yrs = double(time)
A= [yrs,demand];
data = iddata(A,[])
figure
plot(yrs,demand)
xlabel('years')
ylabel('demand')
title('InputData')
Npastsamples = 50;
past_data = data.OutputData(1:Npastsamples);
%nMdl0 = nlarx(data, [2 2 1;2 2 1])
Mdl0 = arima(3,2,1)
Mdl = gjr(9,21)
Mdl2 = garch(Constant=0.05,GARCH=0.91,ARCH=0.04) %Stationary Model
opt = forecastOptions('InitialCondition','e');
K = 100;
Nhor = 60; %actual forecasting horizon
rng("default") % For reproducibility
[vS,yS] = simulate(Mdl2,50)
figure
plot(vS)
figure
plot(yS)
y0 = yS(1);
v0 = vS(1);
y = yS(2:end);
v = vS(2:end);
res = infer(Mdl2,y) % Retrieve inferred residuals
figure
plot(res)
foreValues2 = forecast(Mdl2,Npastsamples,'Y0',demand) % forecast
figure
plot(foreValues2)
data(:,1)'
EstMdl = estimate(Mdl0,demand);
[yF,MSEError] = forecast(EstMdl,Nhor,'Y0',demand)
tn = [yrs; (yrs(end):1:yrs(end)+Nhor-1)']
figure
plot(tn,[demand; zeros(1,Nhor)'],'b',tn,[zeros(1,Dlength)'; yF],'g')
xlabel('years')
ylabel('demand')
title('Historical in blue and Forecast in green')
figure
plot(tn,[demand; yF])
xlabel('years')
ylabel('demand')
title('Merged Historical and Forecast Data')
%Green curve after input max year Dlength=88 is predicted(forseen,anticipated),
% so the predictions/forecast are correct
% correct )))
0 commentaires
Voir également
Catégories
En savoir plus sur Conditional Mean Models dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!