Rolling Generalized Method of Moment (gmm) estimation


#1

I have this zoo series.

> str(ALLXbm)
    ‘zoo’ series from 1998-01-01 to 2017-12-01
      Data: num [1:240, 1:19] 0.00289 0.00992 -0.00424 0.07958 -0.035 ...
     - attr(*, "dimnames")=List of 2
      ..$ : NULL
      ..$ : chr [1:19] "DE" "DB" "DM" "IE" ...
      Index:  Date[1:240], format: "1998-01-01" "1998-02-01" "1998-03-01" "1998-04-01" "1998-05-01" "1998-06-01" "1998-07-01" ...

I wanted a gmm rolling regression and i set up the below code.

dogmm <- function(x) coef(gmm(ALLX$DE~ ALLX$SMB_L, x = ALLXbm))
    kk=rollapply(dogmm, ALLXbm,width=24, by.column = FALSE)

Error message is

`Error in zoo(data) : “x” : attempt to define invalid zoo object`

I really can't figure out even if i spent much time. when i tried the gmm code alone, it does work
gmm(ALLXbm$DE~ ALLXbm$SMB_L, x = ALLXbm). I'm thinking that, the problem is in the rollapply code. I'm sorry this's my first attempt to GMM. Please some help?