I am trying to follow the example given in Section 3.2 of this paper on the use of the gmm
R
package. So I wish to estimate the parameters of a stable distribution. I am using the following code
library(gmm)
library(stabledist)
library(StableEstim)
g1 <- function(theta, x){
tau <- seq(1, 5, length.out = 10)
pm <- 1
x <- matrix(c(x), ncol = 1)
x_comp <- x%*%matrix(tau, nrow = 1)
x_comp <- matrix(complex(imaginary = x_comp), ncol = length(tau))
emp_car <- exp(x_comp)
the_car <- charStable(theta, tau, pm)
gt <- t(t(emp_car) - the_car)
gt <- cbind(Im(gt), Re(gt))
return(gt)
}
x1 <- returns$log.return[2:6966]
t0 <- McCullochParametersEstim(x1)
res1 <- gmm(g1, x1, t0, optfct = "nlminb",
lower = c(0, -1, 0, -Inf),
upper = c(2, 1, Inf, Inf))
summary(res1)
Note that the McCullochParametersEstim()
is a quantiles based method of parameter estimation used here to calculate starting values. When I run this code I receive the following error
Error in AA %*% t(X) : requires numeric/complex matrix/vector arguments
In addition: Warning message:
In ar.ols(x, aic = aic, order.max = order.max, na.action = na.action, :
model order: 1 singularities in the computation of the projection
matrix results are only valid up to model order 0
My data can be found here. In the data set I have prices, log prices, logarithmic returns, and non-logarithmic returns. When I run the code on data in the price
and return
columns, e.g. x1 <- returns.return[2:6966]
, there is no issue. The error message appears when I run the code using data from the log
or log.return
column. I am not sure if the logarithmic transform alters the data class in some way to lead to the error. Any help is appreciated.