Oppure

Loading
29/11/09 16:41
andrea182
ho il seguente codice ma non riesco ad ottenere il valore della previsione perchè mi dice che ho superato i limiti della matrice...qualcuno può aiutarmi??

nel vettore data carico i dati e sono sicuro di caricarli tutti...

il pdf con tutti i passaggi che questa funzione dovrebbe trovare si trova qua:

papers.ssrn.com/sol3/…


clc;clear;close all;
% Load input data
load ('c:\file.mat', '-mat');
% T is the number of the days
T=length(data);
% We consider a random permutation of days
ord = randperm(T);
% We consider half-days of our data for first simulation
firstsample=(T/2);
% We consider the remaining days for second simulation
secondsample=T-(firstsample);
% From firstsample days we consider 10 data randomly selected
firstpoint=10;
% From secondsample days we consider 10 data randomly selected
secondpoint=10;
% We consider the simulation parameters
N=32; % length of input data
M=1; % length of predicted data
% We decompose our data with function db3
[dD] = dwt(data(1:firstsample) ,'db3');
% We define GARCH (1,1) process
[Kappa, Alpha, Beta] = ugarch(dD, 1, 1)
% We set the random number generator seed for reproducability
randn('seed', 10)
NumSamples = firstsample;
% We simulate the process with Monte Carlo
[U , H] = ugarchsim(Kappa, Alpha, Beta, NumSamples);
% Length of vector
V=1;
% From current day we extract firstpoint data randomly selected
currentprice = randperm(V+N-M);
currentprice= currentprice+N;
for j=1:firstpoint
Y1 = currentprice(j);
Y0 = Y1-N+1;
p = U(Y0:Y1);
p = p(:);
Y(1,:) = p(1,:);
pred = U(Y1+1:Y1+M);
end
% We decompose our data with function db3
[dD1]=dwt(data(firstsample+1:firstsample+secondsample),'db3')
% We define GARCH (1,1) process
[Kappa, Alpha, Beta] = ugarch(dD1, 1, 1)
% We set the random number generator seed for reproducability
randn('seed', 10)
NumSamples = secondsample;
% We simulate the process with Monte Carlo
[J , H] = ugarchsim(Kappa, Alpha, Beta, NumSamples);
V=1;
% From current day we extract secondpoint data randomly selected
currentprice = randperm(V+N-M);
currentprice= currentprice+N;
for j= 1:secondpoint
W1 = currentprice(j);
W0 = W1-N+1;
p = J(W0:W1);
p = p(:);
W(1,:) = p(1,:);
pred = J(W1+1:W1+M);
end 


qualcuno mi può aiutare a costruire una funzione che mettendo l'array con tutti i valori assunti del tempo mi restituisca la previsione??

grazie mille
Ultima modifica effettuata da andrea182 29/11/09 16:43
aaa