In estimating GMM with more than one independent variables, The codes are
do_gmm <- function(X)
{
DE <- X[, "DE"]
rmrf_local <- X[, "rmrf_local"]
SMB_L <- X[,"SMB_L"]
h <- cbind(as.numeric(DE,rmrf_local,SMB_L))
coef(gmm(DE ~ rmrf_local,~SMB_L, x = h))
}
r <- rollapplyr(ALLX0, 24, do_gmm, by.column = FALSE, fill = NA)
The code works but in the output, i have only the first variable as follows
> r
(Intercept) rmrf_local
[1,] 0.21 -0.32
[2,] 0.32 -0.04
[3,] -0.43 -0.03
[4,] -0.42 -0.23
I NEED SOME THING LIKE
> r
(Intercept) rmrf_local SMB_L
[1,] 0.21 -0.32 0.34
[2,] 0.32 -0.04 0.01
[3,] -0.43 -0.03 0.21
[4,] -0.42 -0.23 0.12
I don't know why, the second variable is missed in the output. Any idea please?