【问题标题】:Solving for 2 variables under GMM在 GMM 下求解 2 个变量
【发布时间】:2017-09-03 01:02:12
【问题描述】:

我尝试使用以下代码求解 GMM 估计器的 2*1 矩阵:

x<-rnorm(50, mean = 3, sd = 2)
y<-rnorm(50, mean = 4, sd = 1)
z_1<-as.matrix(x)
z_2<-as.matrix(y)
e<-function(RGAAA,x,y)
          {m1<-exp(-x/RGAAA[1])-1
          m2<-exp(-y/RGAAA[2])-1
          f<-cbind(m1,m2)  
          return(f)}


summary(gmm(e,cbind(z_1,z_2),c(1,1),method="BFGS",control=1e-12)) 

但是,它们会产生错误消息:

Error in P$g(P$t0, x) : argument "y" is missing, with no default

谁能帮我找出问题所在? 非常感谢!

【问题讨论】:

    标签: gmm


    【解决方案1】:

    Gmm 函数只能有一个变量矩阵和一个参数向量。给你:

    set.seed(123)#to replicate the results
    x<-rnorm(50, mean = 3, sd = 2)
    y<-rnorm(50, mean = 4, sd = 1)
    z_1<-as.matrix(x)
    z_2<-as.matrix(y)
    z <- cbind(z_1,z_2) #make one matrix from both vectors
    e<-function(RGAAA,x) #one input for the parameters and one input for the variables
              {m1<-exp(-x[,1]/RGAAA[1])-1
              m2<-exp(-x[,2]/RGAAA[2])-1
              f<-cbind(m1,m2)  
              return(f)}
    summary(gmm(e,z,c(1,1),method="BFGS",control=1e-12))
    

    使用我的伪随机数种子,您会得到以下输出:

    Call:
    gmm(g = e, x = z, t0 = c(1, 1), method = "BFGS", control = 1e-12)
    
    
    Method:  twoStep 
    
    Kernel:  Quadratic Spectral
    
    Coefficients:
              Estimate     Std. Error   t value      Pr(>|t|)   
    Theta[1]   4.5256e+02   3.8809e+01   1.1661e+01   2.0121e-31
    Theta[2]   4.9367e+02   1.5265e+01   3.2341e+01  1.8683e-229
    
    J-Test: degrees of freedom is 0 
                    J-test               P-value            
    Test E(g)=0:    0.00577448313404338  *******            
    
    #############
    Information related to the numerical optimization
    Convergence code =  0 
    Function eval. =  25 
    Gradian eval. =  24 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-15
      • 1970-01-01
      • 1970-01-01
      • 2016-02-23
      • 1970-01-01
      相关资源
      最近更新 更多