# ARMA/GARCH estimation with standard errors

#### Cyn

I want to estimate the parameters and standard errors of the following ARMA/GARCH model:

$y_t=a+b y_{t−6}+cy_{t−8}+dϵ_{t−1}+ϵ_t$​
$σ^2_t=ω+αϵ^2_{t−1}+βσ^2_{t−1}$​

The code I use is:
Code:
def main():
x0 = (0.01,0.01,0.01,0.01,0.01, 0.01, 0.01)
b = minimize(garch_loglike, x0, R_bel, bounds = ((None,None),(None,None),(None,None),(None,None),(0.0001, None), (0.0001, None), (0.0001, None)), options={'disp':True})
print(b.x)
value = garch_loglike(b.x, R_bel)
print("Log likelihood value:", -value)

a = nd.Hessian(garch_loglike)
print(a(b.x, R_bel))

def garch_filter(omega, alpha, beta1, eps, R):
iT = len(R)-8
sigma_2 = np.zeros(iT)

for i in range(iT):
if i==0:
sigma_2[i] = omega + alpha*eps[i-1]**2 + beta1*np.var(eps)
else:
sigma_2[i] = omega + alpha*eps[i-1]**2 + beta1*sigma_2[i-1]
return sigma_2

def eps1(a, b, c, d, R):
eps = np.zeros(len(R)-8)
for t in range(len(R)-8):
if t ==0:
eps[t] = R-R
else:
eps[t] = R[t+8]-a - b*R[t+2] - c*R[t] -d*eps[t-1]
return eps

def garch_loglike(vP, R):
iT = len(R)
a = vP
b=vP
c=vP
d=vP
omega = vP
alpha = vP
beta1 = vP

eps = eps1(a,b,c,d,R)
sigma_2 = garch_filter(omega, alpha, beta1, eps, R)

logL = -(-len(eps)/2 * np.log(2*math.pi) -0.5 *np.sum(np.log(sigma_2) + eps**2/sigma_2))
return logL
Here, my data is R_bel. I get parameter estimates, but I do not get the hessian. I thought that with the hessian I could calculate the standard errors. But I get errors such as: RuntimeWarning: overflow encountered in double_scalars. And as output, I get a matrix with nan. How can I solve this problem?

Thank in advance!

[moderator; latex fixed]

Last edited by a moderator:
Related Programming and Computer Science News on Phys.org

#### Mark44

Mentor
I want to estimate the parameters and standard errors of the following ARMA/GARCH model:

$y_t=a+b y_{t−6}+cy_{t−8}+dϵ_{t−1}+ϵ_t$​
$σ^2_t=ω+αϵ^2_{t−1}+βσ^2_{t−1}$​

The code I use is:
Code:
def main():
x0 = (0.01,0.01,0.01,0.01,0.01, 0.01, 0.01)
b = minimize(garch_loglike, x0, R_bel, bounds = ((None,None),(None,None),(None,None),(None,None),(0.0001, None), (0.0001, None), (0.0001, None)), options={'disp':True})
print(b.x)
value = garch_loglike(b.x, R_bel)
print("Log likelihood value:", -value)

a = nd.Hessian(garch_loglike)
print(a(b.x, R_bel))

def garch_filter(omega, alpha, beta1, eps, R):
iT = len(R)-8
sigma_2 = np.zeros(iT)

for i in range(iT):
if i==0:
sigma_2[i] = omega + alpha*eps[i-1]**2 + beta1*np.var(eps)
else:
sigma_2[i] = omega + alpha*eps[i-1]**2 + beta1*sigma_2[i-1]
return sigma_2

def eps1(a, b, c, d, R):
eps = np.zeros(len(R)-8)
for t in range(len(R)-8):
if t ==0:
eps[t] = R-R
else:
eps[t] = R[t+8]-a - b*R[t+2] - c*R[t] -d*eps[t-1]
return eps

def garch_loglike(vP, R):
iT = len(R)
a = vP
b=vP
c=vP
d=vP
omega = vP
alpha = vP
beta1 = vP

eps = eps1(a,b,c,d,R)
sigma_2 = garch_filter(omega, alpha, beta1, eps, R)

logL = -(-len(eps)/2 * np.log(2*math.pi) -0.5 *np.sum(np.log(sigma_2) + eps**2/sigma_2))
return logL
Here, my data is R_bel. I get parameter estimates, but I do not get the hessian. I thought that with the hessian I could calculate the standard errors. But I get errors such as: RuntimeWarning: overflow encountered in double_scalars. And as output, I get a matrix with nan. How can I solve this problem?

Thank in advance!

[moderator; latex fixed]
There's not enough information here for us, or at least me, to be able to help.
How is the minimize function defined?
What is nd? In sum of your following code I see np, which I assume is a numpy class/module.
What does nd.Hessian() return? Presumably it returns a Hessian matrix.
One line of your code is a = nd.Hessian(garch_loglike). In the next line you have print (a(b.x, R_bel)) - this might be the cause of your error, due to two problems:
If a is a two-dimensional matrix, you need to use a pair of brackets - [] -for each index, as in a.
Second, the indexes in the matrix must be integer values. It's not likely that b.x and R_bel are integers.

### Want to reply to this thread?

"ARMA/GARCH estimation with standard errors"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving