Matlab garchset / garchfit / garchsim to new functions -
good day,
i found following code online adapt. however, uses functions date old version of toolbox. understand, garchset , garchfit substituted garch function. , garchsim estimate / simulate function. able me correct syntax?
original code:
%% simulate stressed returns % introduce volatility shock % update garch specifications user inputs shock volatility constant of correspondig equity garch process volashock = volashock'; % transpose fit loop operation i=1:nequities spec(i)=garchset(spec(i),'k',garchget(spec(i), 'k')* volashock(i,1)^2); % apply stress input garch volatility constants end s = randstream.getdefaultstream(); reset(s) % create , reset default random number stream z = zeros(horizon, npaths, nequities); % standardized residuals array u = copularnd('t', rstress, dofstress, horizon * npaths); % t copula simulation j = 1:nequities z(:,:,j) = reshape(obj{j}.icdf(u(:,j)), horizon, npaths); end stressedsimulatedreturns = zeros(horizon, npaths, nequities);% preallocate array improved speed % simulation of multiple return paths single share = 1:nequities [~, ~, stressedsimulatedreturns(:,:,i)] = garchsim(spec(i), horizon, npaths, z(:,:,i), [], [], preresidual(i), presigma(i), prereturn(i)); end`
i need estimate garch(1,1) model. first time garchset used thought can substituted following:
model = arima('ar', nan, 'distribution', 't', 'variance', gjr(1,1));
but need introduce volatility shock. , when tried add here didn't work.
for second case, garchsim used. think estimate function can used... since garch setting doesn't work couldn't go step.
any / advice appreciated.
Comments
Post a Comment