1

我试图以隐式形式估计以下非线性模型的参数:它的表达式不是由 y = f(x;theta) + u 给出,而是由 u = g(x,y;theta) 给出,其中 u 是随机项, x 和 y 是解释和解释变量。不可能从 g 获得 f(因为 g 不能在 y 中反转和/或 g 在 u 中不是加法的)。下面的 NLS 和 GMM 都不会运行。我在 NLS 和 GMM 文档中找不到有关此问题的任何信息,所以我想知道该怎么做。我将不胜感激有关此主题的任何帮助。

更具体地说,我考虑了以下 g 规范(但 NLS 和 GMM 不运行):

#
# The DGP
#
set.seed(34567)
N <- 1000 # sample size
x <- rnorm(N) # explanatory variable
u <- rnorm(N) # u is the random term or the model
y <- (81 - 3*x*x)*(1+exp(u)) # y = h(x,u;theta) is the explained variable
summary(y)
#
# The NLS regression: we know that the true functional form is u = g(x,y;theta) and E[u]=0 
# but we do not know that the DGP is obtained for theta_0=81 and theta_1=3 
#
x2 <- x*x
NLS_reg <- function(theta_0, theta_1) {
  log( y / (theta_0 - theta_1*x2) - 1 ) 
}
nls_out <- nls(0 ~ NLS_reg(theta_0, theta_1), start = list(theta_0 = 84.3, theta_1 = 3.25), trace = T)
summary(nls_out)
#
# The GMM regression
#
require("gmm")
iota <- rep(1,N)
data <- data.matrix(cbind(y, iota, x, x2))
GMM_reg <- function(data, theta_0, theta_1) {
  y <- as.numeric(data[,1])
  x2 <- as.numeric(data[,4])
  return( log( y / (theta_0*iota-theta_1*x2) - 1 ) )
}
moments <- function(data, theta_0, theta_1) {
  z <- data.matrix(data[, 2:4])
  m <- z * as.vector(GMM_reg(data, theta_0, theta_1))
  return(cbind(m))
}
GMM_out <- gmm(g=moments, x = data, t0 = c(78,2.6), type = "iterative", crit = 1e-3, wmatrix = "optimal", method = "Nelder-Mead", control = list(reltol = 1e-3, maxit = 100))
summary(GMM_out)
4

0 回答 0