
Panel IV with unit (and optional time) fixed effects via within-transform
Source:R/iv.R
morie_iv_panel.RdPanel IV with unit (and optional time) fixed effects via within-transform
Usage
morie_iv_panel(
data,
outcome,
endogenous,
instruments,
unit,
exogenous = NULL,
time_fe = NULL,
alpha = 0.05
)Arguments
- data
Data frame.
- outcome
Name of the outcome column.
- endogenous
Character vector of endogenous regressor names.
- instruments
Character vector of excluded-instrument names.
- unit
Cluster / unit identifier column.
- exogenous
Optional character vector of exogenous covariate names.
- time_fe
Optional time-FE column.
- alpha
Significance level for confidence intervals.
Value
A named list with elements coefficients, std_errors, t_stats, p_values, ci_lower, ci_upper, variable_names, n_obs, method, details.
Examples
set.seed(1)
n_unit <- 30; n_time <- 5; n <- n_unit * n_time
df <- data.frame(
unit = rep(seq_len(n_unit), each = n_time),
z = rbinom(n, 1, 0.5))
df$d <- 0.5 * df$z + rnorm(n, sd = 0.5)
df$y <- 0.5 * df$d + rnorm(n, sd = 0.5)
res <- morie_iv_panel(df, "y", "d", "z", unit = "unit")
res$coefficients
#> (Intercept) d
#> 8.738609e-19 2.146647e-01