please i need your help
Posted: Sun Nov 17, 2019 5:50 am
Hi,
i just starting with programming and i need your help
i want to add arfima to this program
* Replication file for Bollerslev and Mikkelson(1996), "Modeling and
* pricing long memory in stock market volatility", Journal of
* Econometrics, vol 73, pp 151-184.
*
* Data set is a reconstruction, rather than being the author's original,
* so the results are very similar but not identical.
*
* FIGARCH models
*
open data sp500.xls
data(format=xls,org=columns) 1 9559 open high low close adjclose volume gap
*
* We scale this by 100, which increases the variance parameters to a
* magnitude closer to 1.
*
set r = 100.0*log(close/close{1})
linreg r
# constant r{1 2 3}
*
frml(lastreg,vector=mu) meanf
compute omega=%seesq,delta=0.0
nonlin(parmset=meanparms) mu
*
clear u h
compute gstart=%regstart(),gend=%regend()
*
nonlin(parmset=garchparms) omega delta
frml varf = omega+delta*gap
frml logl = u=r-meanf,h=varf,%logdensity(h,u)
maximize(parmset=meanparms+garchparms) logl gstart gend
compute omega0=omega
*
* Same model done using GARCH (with zero for p and q)
*
garch(p=0,q=0,reg,xreg,hseries=h) / r
# constant r{1 2 3}
# gap
*
* AR3-GARCH
*
* The standard GARCH instruction handles the GARCH-X part differently
* than the specification in the paper so we have to use a MAXIMIZE
* method.
*
nonlin(parmset=garchparms) omega delta beta1 phi1 phi2
compute beta1=.8,phi1=1.0,phi2=0.0
*
compute uupresample=omega0
set uuadj = uupresample
set h = uupresample
*
frml varf = beta1*h{1}+omega+delta*(gap-beta1*gap{1})+$
(phi1+phi2-beta1)*uuadj{1}-phi1*phi2*uuadj{2}
frml logl = u=r-meanf,uuadj=u^2-delta*gap,h=varf,%logdensity(h,u)
maximize(parmset=meanparms+garchparms) logl gstart gend
*
* AR3-I-GARCH
*
* Same as the previous with PHI1 pegged
*
nonlin(parmset=ipeg) phi1=1.0
maximize(parmset=meanparms+garchparms+ipeg) logl gstart gend
*
* AR3-FIGARCH
*
* Take phi2 out and put d into the parmset
*
nonlin(parmset=figarchparms) omega delta beta1 phi1 d
compute d=.1,phi1=.6
*
* %uufilter is called on each function evaluation to compute the
* fractionally differenced values of u^2-delta*gap
*
function %uufilter d
type real d %uufilter
*
set u = r-meanf
set uuadj = %if(t<gstart,uupresample,u^2-delta*gap)
if d>=0.0.and.d<1.0
diff(fraction=d,pad=uupresample) uuadj / uufilter
end
****************
frml varf = beta1*h{1}+omega+delta*(gap-beta1*gap{1})+$
(uuadj-beta1*uuadj{1})-(uufilter-phi1*uufilter{1})
frml logl = h=varf,%logdensity(h,u)
*
* We need to be *very* careful with the guess values. It's very easy to
* produce negative variances when solving recursively for the varinace
* in this model. Zeroing out delta (which eliminates the possibility of
* negative values for uuadj) and moving beta1 and phi1 away from 1 seem
* to help. Once you have guess values that are ok for the full data set,
* estimation can proceed.
*
compute delta=0.0,d=.10,beta1=.5,phi1=.5
maximize(start=%uufilter(d),reject=(d<0.0.or.d>=1.0),$
parmset=meanparms+figarchparms,trace) logl gstart gend
i just starting with programming and i need your help
i want to add arfima to this program
* Replication file for Bollerslev and Mikkelson(1996), "Modeling and
* pricing long memory in stock market volatility", Journal of
* Econometrics, vol 73, pp 151-184.
*
* Data set is a reconstruction, rather than being the author's original,
* so the results are very similar but not identical.
*
* FIGARCH models
*
open data sp500.xls
data(format=xls,org=columns) 1 9559 open high low close adjclose volume gap
*
* We scale this by 100, which increases the variance parameters to a
* magnitude closer to 1.
*
set r = 100.0*log(close/close{1})
linreg r
# constant r{1 2 3}
*
frml(lastreg,vector=mu) meanf
compute omega=%seesq,delta=0.0
nonlin(parmset=meanparms) mu
*
clear u h
compute gstart=%regstart(),gend=%regend()
*
nonlin(parmset=garchparms) omega delta
frml varf = omega+delta*gap
frml logl = u=r-meanf,h=varf,%logdensity(h,u)
maximize(parmset=meanparms+garchparms) logl gstart gend
compute omega0=omega
*
* Same model done using GARCH (with zero for p and q)
*
garch(p=0,q=0,reg,xreg,hseries=h) / r
# constant r{1 2 3}
# gap
*
* AR3-GARCH
*
* The standard GARCH instruction handles the GARCH-X part differently
* than the specification in the paper so we have to use a MAXIMIZE
* method.
*
nonlin(parmset=garchparms) omega delta beta1 phi1 phi2
compute beta1=.8,phi1=1.0,phi2=0.0
*
compute uupresample=omega0
set uuadj = uupresample
set h = uupresample
*
frml varf = beta1*h{1}+omega+delta*(gap-beta1*gap{1})+$
(phi1+phi2-beta1)*uuadj{1}-phi1*phi2*uuadj{2}
frml logl = u=r-meanf,uuadj=u^2-delta*gap,h=varf,%logdensity(h,u)
maximize(parmset=meanparms+garchparms) logl gstart gend
*
* AR3-I-GARCH
*
* Same as the previous with PHI1 pegged
*
nonlin(parmset=ipeg) phi1=1.0
maximize(parmset=meanparms+garchparms+ipeg) logl gstart gend
*
* AR3-FIGARCH
*
* Take phi2 out and put d into the parmset
*
nonlin(parmset=figarchparms) omega delta beta1 phi1 d
compute d=.1,phi1=.6
*
* %uufilter is called on each function evaluation to compute the
* fractionally differenced values of u^2-delta*gap
*
function %uufilter d
type real d %uufilter
*
set u = r-meanf
set uuadj = %if(t<gstart,uupresample,u^2-delta*gap)
if d>=0.0.and.d<1.0
diff(fraction=d,pad=uupresample) uuadj / uufilter
end
****************
frml varf = beta1*h{1}+omega+delta*(gap-beta1*gap{1})+$
(uuadj-beta1*uuadj{1})-(uufilter-phi1*uufilter{1})
frml logl = h=varf,%logdensity(h,u)
*
* We need to be *very* careful with the guess values. It's very easy to
* produce negative variances when solving recursively for the varinace
* in this model. Zeroing out delta (which eliminates the possibility of
* negative values for uuadj) and moving beta1 and phi1 away from 1 seem
* to help. Once you have guess values that are ok for the full data set,
* estimation can proceed.
*
compute delta=0.0,d=.10,beta1=.5,phi1=.5
maximize(start=%uufilter(d),reject=(d<0.0.or.d>=1.0),$
parmset=meanparms+figarchparms,trace) logl gstart gend