mmeierer / REndo

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

Enhanced OLS for copulaCorrection single continuous endogenous regressor #52

Open pschil opened 4 years ago

pschil commented 4 years ago

Currently, the case of a single continuous endogenous regressor in copulaCorrection can only be estimated using LL. Because bootstrapping with LL takes much longer it would be convenient to also provide the possibility to use enhanced OLS. As by Raluca, this would theoretically be correct as shown in the paper by Park and Gupta.

Suggested syntax: use continuousLL() and continuousOLS() to mark the regressors in favour of continuous() which should be depreciated.

This is not expected to be implemented in the near future.

hannesdatta commented 3 years ago

I was skimming through the code and issues, but couldn't easily discern whether the estimation with multiple endogenous regressors is supported already. When using OLS, it should be enough to use the copula transformation function (i.e., to extract the normally-distributed and potentially endogenous part of PStar), and inserting that as an additional regressor for each potentially endogenous variable. Should be straightforward to implement. The function may be sensitive to the increment to prevent qnorm to evaluate to NA.

    make_copula <- function(x, increment = .00001) {
        if (length(unique(x))==1) return(as.numeric(rep(NA, length(x))))
        return(ifelse(ecdf(x)(x)==1, qnorm(1-increment), qnorm(ecdf(x)(x))))
        }
Rgui commented 3 years ago

Copula correction method with multiple endogenous regressors is already implemented, as explained also in the vignette: https://rdrr.io/cran/REndo/f/vignettes/REndo-introduction.Rmd