mmeierer / REndo

REndo - A R package to control for endogeneity by using internal instrumental variable models
15 stars 4 forks source link

Problems with intercept estimation with the Copula correction method #33

Closed awayt039 closed 5 years ago

awayt039 commented 5 years ago

Does the copula correction method work for models where an intercept is estimated with an intercept? After skimming the Park and Gupta paper proposing the copula correction method, I noticed the data generating process does not add an intercept into the data generating process. I tried imitating their data generating process without an intercept and with an intercept and got less than satisfying results (see the code below) which makes me think the data has to be mean centered and estimated with without an intercept.

Any feedback you all have would be appreciated! Thanks!

## create an endogenous regressor
Sigma <- matrix(c(1.8,1.65,1.65,2),2,2)
x1 <-mvtnorm::rmvnorm(n = 100, c(2, 0), Sigma)
cor(x1)## check correlation
error <- x1[,2]
x1<- x1[,1]
## create an exogenous regressor
x2 <- rnorm(100, 2, 3)
## generate some data
y <-3*x1 + 4*x2 + error

#mle methodd
model <- REndo::copulaCorrection(y ~0+ x1+x2| continuous(x1),
                                 data=data.frame(y, x1, x2))
summary(model)
## ols method
p_star <- REndo:::copulaCorrectionContinuous_pstar(x1)
summary(lm(y ~ 0+x1+x2))
summary(lm(y ~ 0+x1+x2+p_star))

### allow the models to estimate an intercept
#mle methodd
model <- REndo::copulaCorrection(y ~ x1+x2| continuous(x1),
                                 data=data.frame(y, x1, x2))
summary(model)
## ols method
p_star <- REndo:::copulaCorrectionContinuous_pstar(x1)
summary(lm(y ~ x1+x2))
summary(lm(y ~ x1+x2+p_star))

### add intercept to the data
y <- y + 3

#mle methodd
model <- REndo::copulaCorrection(y ~ x1+x2| continuous(x1),
                                 data=data.frame(y, x1, x2))
summary(model)
## ols method
p_star <- REndo:::copulaCorrectionContinuous_pstar(x1)
summary(lm(y ~ x1+x2))
summary(lm(y ~ x1+x2+p_star))
awayt039 commented 5 years ago

Disregard. It was because the x1 above was normally distributed.