标签: r simulation
如何在R中为tsls进行模拟研究? 这就是我所拥有的:
K <- N <- beta <- 1 g <-matrix(ncol=K,nrow=N) for(i in 1: K) g[,i]<-rbinom(N,2,0.3) u <- rnorm(N) gamma <- runif(K,0.5,4) x <-rnorm(N,t(gamma)%*%g+u) alpha <- runif(K,-0.5,0.5) y <- rnorm(N, t(alpha)%*%g+beta*x+u)