Generates garch gradient
[g,dht,gradt]=garch_grad2(parm,nar,nma,y,x)
* parm = vector of parameters (beta, a0, ar and ma in that order)
* nar = # of ar parameters
* nma = # of ma parameters
* y = (n x 1) vector of the endogenous variable
* x = (n x k) vector of the exogenous variables
* g = (k+nar+nma+1 x 1) -gradient at param
* dht = (nobs x nar+nma+1) derivative of sigt w.r.t a0, ar, ma
* scores = (k+nar+nma+1 x 1) sub-gradient at each date
load(GROCERDIR+'/data/garchd.dat') bounds('1949q1','1983q4') r1 = ols('gnpdef','cte','lagts(gnpdef)','lagts(2,gnpdef)','lagts(3,gnpdef)','lagts(4,gnpdef)'); bet = r1('beta'); s = r1('ser'); [y,namey,x]=explouniv('gnpdef',list('cte','lagts(gnpdef)','lagts(2,gnpdef)','lagts(3,gnpdef)','lagts(4,gnpdef)')); p=[bet ; s ; 0 ; 0 ] g=garch_grad2(p,1,1,y,x) // the gradient, derivate of sigt and scores have been caluclated at ols solution. Note that the ser is entered since it is squared in garch_gard2 (contrary to garch_grad) | ![]() | ![]() |