print g11res llf = loglike_GARCH11(g11res, errgjr4-errgjr4.mean()) print llf[0] if 'rpyfit' in examples: from rpy import r r.library('fGarch') f = r.formula('~garch(1, 1)') fit = r.garchFit(f, data = errgjr4-errgjr4.mean(), include_mean=False) if 'rpysim' in examples: from rpy import r f = r.formula('~garch(1, 1)') #fit = r.garchFit(f, data = errgjr4) x = r.garchSim( n = 500) print 'R acf', tsa.acf(np.power(x,2))[:15] arma3 = Arma(np.power(x,2)) arma3res = arma3.fit(start_params=[-0.2,0.1,0.5],maxiter=5000) print arma3res.params arma3b = Arma(np.power(x,2)) arma3bres = arma3b.fit(start_params=[-0.2,0.1,0.5],maxiter=5000, method='bfgs') print arma3bres.params xr = r.garchSim( n = 100) x = np.asarray(xr) ggmod = Garch(x-x.mean()) ggmod.nar = 1 ggmod.nma = 1 ggmod._start_params = np.array([-0.6, 0.1, 0.2, 0.0]) ggres = ggmod.fit(start_params=np.array([-0.6, 0.1, 0.2, 0.0]), maxiter=1000)
print(g11res) llf = loglike_GARCH11(g11res, errgjr4 - errgjr4.mean()) print(llf[0]) if 'rpyfit' in examples: from rpy import r r.library('fGarch') f = r.formula('~garch(1, 1)') fit = r.garchFit(f, data=errgjr4 - errgjr4.mean(), include_mean=False) if 'rpysim' in examples: from rpy import r f = r.formula('~garch(1, 1)') #fit = r.garchFit(f, data = errgjr4) x = r.garchSim(n=500) print('R acf', tsa.acf(np.power(x, 2))[:15]) arma3 = Arma(np.power(x, 2)) arma3res = arma3.fit(start_params=[-0.2, 0.1, 0.5], maxiter=5000) print(arma3res.params) arma3b = Arma(np.power(x, 2)) arma3bres = arma3b.fit(start_params=[-0.2, 0.1, 0.5], maxiter=5000, method='bfgs') print(arma3bres.params) xr = r.garchSim(n=100) x = np.asarray(xr) ggmod = Garch(x - x.mean()) ggmod.nar = 1 ggmod.nma = 1