ARMA/GARCH estimation with standard errors

So you need to convert them to integers, like in a[int(b.x)][int(R_bel)] but I'm guessing that's not what you want.
  • #1
Cyn
8
0
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[1]-R[0]
        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[0]
    b=vP[1]
    c=vP[2]
    d=vP[3]
    omega = vP[4]
    alpha = vP[5]
    beta1 = vP[6]

    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:
Technology news on Phys.org
  • #2
Cyn said:
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[1]-R[0]
        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[0]
    b=vP[1]
    c=vP[2]
    d=vP[3]
    omega = vP[4]
    alpha = vP[5]
    beta1 = vP[6]

    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[2][3].
Second, the indexes in the matrix must be integer values. It's not likely that b.x and R_bel are integers.
 

1. What is ARMA/GARCH estimation and why is it important in scientific research?

ARMA (Autoregressive Moving Average) and GARCH (Generalized Autoregressive Conditional Heteroskedasticity) estimation is a statistical method used to model and forecast time series data. It combines the concepts of both autoregression and moving average to capture the underlying patterns and dynamics of the data. This method is important in scientific research as it allows for the analysis and prediction of complex time series data, which is commonly found in fields such as finance, economics, and environmental studies.

2. How are standard errors calculated in ARMA/GARCH estimation?

In ARMA/GARCH estimation, standard errors are calculated using the maximum likelihood method. This involves estimating the parameters of the model that best fit the data and then calculating the standard errors based on the likelihood function. Alternatively, standard errors can also be calculated using the bootstrap method, which involves resampling the data and estimating the standard errors based on the bootstrap samples.

3. What factors can affect the accuracy of standard errors in ARMA/GARCH estimation?

There are several factors that can affect the accuracy of standard errors in ARMA/GARCH estimation. These include the number of observations in the time series, the complexity of the model, the presence of outliers or extreme values in the data, and the assumptions made about the underlying distribution of the data. It is important to carefully consider these factors when interpreting the results of ARMA/GARCH estimation and to conduct sensitivity analyses to assess the robustness of the standard errors.

4. How can I interpret the standard errors in ARMA/GARCH estimation?

The standard errors in ARMA/GARCH estimation represent the uncertainty associated with the estimated parameters of the model. They can be used to calculate confidence intervals, which can help determine the range of values within which the true parameter values are likely to lie. Generally, smaller standard errors indicate more precise estimates, while larger standard errors suggest greater uncertainty in the estimates.

5. Are there any limitations to using ARMA/GARCH estimation with standard errors?

Like any statistical method, there are limitations to using ARMA/GARCH estimation with standard errors. These include the assumptions made about the underlying data, the potential for misspecification of the model, and the potential for biased estimates if the data is not properly preprocessed. It is important to carefully consider these limitations and to use caution when interpreting the results of ARMA/GARCH estimation with standard errors.

Similar threads

  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Atomic and Condensed Matter
Replies
3
Views
843
Back
Top