gmm 估计误差 [英] gmm estimation error

查看:52
本文介绍了gmm 估计误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在估计具有多个自变量的 GMM 时,代码是

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

我需要一些东西

> 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?

推荐答案

最后我解决了如下

      do_gmm <- function(X) {
      DE <- DE[,1]<- X[, "DE"]
      rmrf_local <- X[, "rmrf_local"]
      SMB_L <- X[,"SMB_L"]
      HML_L <- X [, "HML_L"]
     h <- cbind(rmrf_local,SMB_L, HML_L)
      coef(gmm(DE ~ rmrf_local+SMB_L+HML_L, x = h))
    }

    r <- rollapplyr(ALLX0, 24, do_gmm, by.column = FALSE, fill = NA)
    r <- data.frame(r)
    r
 #   X.Intercept.   rmrf_local        SMB_L         HML_L
#1  -5.555761e-02  0.022837356 -0.937533698 -0.0424317893
#2  -4.264533e-02  0.032031878 -0.793814606 -0.0856941501
#3  -4.468413e-02  0.023003578 -0.789339020 -0.0968315078
#4  -5.088025e-02  0.028099687 -0.866812624 -0.0189772617

这篇关于gmm 估计误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆