1

I am trying to perform the estimation of the following Autoregressive Stochastic Volatility model $$ y_t=\sigma_t u_t = exp(w_t/2)u_t \\ w_t = \omega + \phi w_{t-1} + \eta_t $$ in R via the function gmm of the homonymous package.

The following lines of code contain the function, with the 12 moment conditions that I am using, and the estimation command

  target_f = function(theta, x){
  omega = theta[1]
  phi = theta[2]
  sigma2_eta = theta[3]
  data = x
  alpha_w = omega / (1 - phi)
  beta2_w = sigma2_eta / (1 - phi^2)
  
  m1 = (sqrt(2/pi) * exp(0.5 * alpha_w + 0.125 * beta2_w) - abs(data))[-(1:10)]
  m2 = (exp(alpha_w + 0.5*beta2_w) - data ^ 2)[-(1:10)]
  m3 = (2 * sqrt(2/pi)*exp(3/2*alpha_w + 9/8 * beta2_w) - abs(data^3))[-(1:10)]
  m4 = (3 * exp(2 * alpha_w + 2 * beta2_w) - data^4)[-(1:10)]
  
  m5 = ((2/pi) * exp(0.5 * alpha_w + 0.125 * beta2_w)^2 * (phi*beta2_w/4) - abs(data * lag(data)))[-(1:10)]
  m6 = ((2/pi) * exp(0.5 * alpha_w + 0.125 * beta2_w)^2 * exp(phi^2 * beta2_w/4) - abs(data * lag(data, 2)))[-(1:10)]
  m7 = ((2/pi) * exp(0.5 * alpha_w + 0.125 * beta2_w)^2 * exp(phi^5 * beta2_w/4) - abs(data * lag(data, 5)))[-(1:10)]
  m8 = ((2/pi) * exp(0.5 * alpha_w + 0.125 * beta2_w)^2 * exp(phi^10 * beta2_w/4) - abs(data * lag(data, 10)))[-(1:10)]
  
  m9 = (exp(alpha_w + 0.5*beta2_w)^2 * exp(phi * beta2_w) - data^2 * lag(data)^2)[-(1:10)]
  m10 = (exp(alpha_w + 0.5*beta2_w)^2 * exp(phi^2 * beta2_w) - data^2 * lag(data, 2)^2)[-(1:10)]
  m11 = (exp(alpha_w + 0.5*beta2_w)^2 * exp(phi^5 * beta2_w) - data^2 * lag(data, 5)^2)[-(1:10)]
  m12 = (exp(alpha_w + 0.5*beta2_w)^2 * exp(phi^10 * beta2_w) - data^2 * lag(data, 10)^2)[-(1:10)]
  return(
    cbind(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12)
  )
}

# Estimation
ret = rnorm(1000)
ARSV_fit =
  gmm(g = target_f, x = ret, t0 = c(0, 0, 1), wmatrix = "optimal")

.

Unfortunately, the optimization is very reliable on the starting point that I provide, and in this way, it happens that it returns negative values for the variance parameter. Is there any way to insert constraint on the parameters within gmm or do you know any other function that allows so?

Richard Hardy
  • 54,375
  • 10
  • 95
  • 219
Mr Frog
  • 87
  • 5

0 Answers0