Causal inference

Start with the expanded example for each command. Open the variants for options and alternative R approaches. Read the qualifications before adapting the code.

boottest

Null-imposed wild cluster bootstrap using rademacher weights

Stata

boottest treat, cluster(group) reps(199) weighttype(rademacher) seed(128)

R Package:fwildclusterboot

fwildclusterboot::boottest(fit, param = "treat", clustid = "group", B = 199, type = "rademacher", impose_null = TRUE, conf_int = FALSE, engine = "R-lean")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Small replication count is a runnable example, not an analysis recommendation. Align bootstrap variant, clustering and finite-sample correction. Installed fwildclusterboot emits a one-time seeding-change warning; both R and dqrng generators are explicitly seeded. fwildclusterboot 0.13 changed RNG seeding; seed-for-seed agreement with older versions is not expected.

Null-imposed wild cluster bootstrap using webb weights

Stata

boottest treat, cluster(group) reps(199) weighttype(webb) seed(128)

R Package:fwildclusterboot

fwildclusterboot::boottest(fit, param = "treat", clustid = "group", B = 199, type = "webb", impose_null = TRUE, conf_int = FALSE, engine = "R-lean")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Small replication count is a runnable example, not an analysis recommendation. Align bootstrap variant, clustering and finite-sample correction. Installed fwildclusterboot emits a one-time seeding-change warning; both R and dqrng generators are explicitly seeded. fwildclusterboot 0.13 changed RNG seeding; seed-for-seed agreement with older versions is not expected.

cem

Coarsened exact matching on a categorical covariate

Stata

cem category, treatment(treat)

R Package:MatchIt

MatchIt::matchit(treat ~ category, data = transform(data, category = as.integer(category) - 1L), method = "cem", estimand = "ATT", cutpoints = list(category = 0))

Fixed workflow; adapt the named data columns explicitly. Matching preprocessing only; categorical levels need no continuous cutpoints. For continuous variables, explicitly match cutpoints and estimand rather than relying on different software defaults.

did_imputation

Average imputation treatment effect over treated observations

Stata

did_imputation y id time cohort

R Package:stats

{ baseline <- stats::lm(y ~ factor(id) + factor(time) + x, data = data, subset = treated == 0); effects <- data$y - stats::predict(baseline, newdata = data); mean(effects[data$treated == 1]) }

Fixed workflow; adapt the named data columns explicitly. Point-estimation workflow only; untreated-outcome model, weighting and supported treated observations must be chosen explicitly.

Untreated-outcome imputation effects by event time

Stata

did_imputation y id time cohort, allhorizons

R Package:stats

{ untreated <- data$treated == 0; baseline <- stats::lm(y ~ factor(id) + factor(time) + x, data = data, subset = untreated); effects <- data$y - stats::predict(baseline, newdata = data); keep <- data$treated == 1; stats::aggregate(effects[keep], list(horizon = data$time[keep] - data$cohort[keep]), mean) }

Fixed workflow; adapt the named data columns explicitly. Point-estimation illustration with unit/time effects learned only from untreated observations. Never-treated Stata cohort should be missing, whereas this R fixture uses an out-of-range sentinel. Does not reproduce did_imputation’s influence-function variance, autosample or pretrend tests.

drdid

Two-period panel doubly robust DiD ATT point estimate

Stata

drdid y x, ivar(id) time(time) treatment(treated) dripw

R Package:stats

{ ps <- stats::fitted(stats::glm(treated ~ x, data = data, family = stats::binomial())); m0 <- stats::predict(stats::lm(dy ~ x, data = data, subset = treated == 0), data); weighted.mean(data$dy - m0, data$treated) - weighted.mean(data$dy - m0, (1 - data$treated) * ps / (1 - ps)) }

Fixed workflow; adapt the named data columns explicitly. Wide-data point-estimation workflow for the dripw variant: logistic propensity plus control-group outcome-change OLS. Stata expects long data. No influence-function variance or improved drimp estimator.

Panel outcome-regression DiD ATT point estimate

Stata

drdid y x, ivar(id) time(time) treatment(treated) reg

R Package:stats

{ m0 <- stats::predict(stats::lm(dy ~ x, data = data, subset = treated == 0), data); mean((data$dy - m0)[data$treated == 1]) }

Fixed workflow; adapt the named data columns explicitly. Two-period wide-data regression-adjustment workflow; requires conditional parallel trends and no anticipation. No standard errors.

Stabilized inverse-probability-weighted DiD ATT

Stata

drdid y x, ivar(id) time(time) treatment(treated) stdipw

R Package:stats

{ ps <- stats::fitted(stats::glm(treated ~ x, data = data, family = stats::binomial())); mean(data$dy[data$treated == 1]) - weighted.mean(data$dy, (1 - data$treated) * ps / (1 - ps)) }

Fixed workflow; adapt the named data columns explicitly. Two-period wide-data point estimate; no influence-function variance and no repeated-cross-section implementation.

ebalance

Entropy balancing treated/control covariate moments through order 1

Stata

ebalance treat x z, targets(1)

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "ebal", estimand = "ATT", moments = 1)

Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors.

Entropy balancing treated/control covariate moments through order 2

Stata

ebalance treat x z, targets(2)

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "ebal", estimand = "ATT", moments = 2)

Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors.

estat

IV weak-instrument and endogeneity diagnostics

Stata

estat endogenous

R Package:AER

summary(AER::ivreg(y ~ x + w | z + w, data = data), diagnostics = TRUE)$diagnostics

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Wu-Hausman tests depend on model assumptions; exactly identified models have no overidentification test.

1 more examples and alternatives

First-stage instrument relevance regression

Stata

estat firststage

R Package:stats

summary(stats::lm(x ~ z + w, data = data))

Fixed workflow; adapt the named data columns explicitly. This is the full first-stage regression; a joint excluded-instrument F test may require a nested comparison.

eventstudyinteract

Aggregate cohort-interacted post-treatment effects

Stata

eventstudyinteract y lead3 lead2 lag0 lag1 lag2, absorb(id time) cohort(cohort) control_cohort(never)

R Package:fixest

{ fit <- fixest::feols(y ~ sunab(cohort, time, ref.p = -1) | id + time, data = data, vcov = ~id, nthreads = 1); stats::aggregate(fit, agg = "ATT") }

Fixed workflow; adapt the named data columns explicitly. ATT aggregation is an R postestimation step; match event-time/cohort weights rather than averaging coefficients unweighted.

Sun-Abraham cohort-interacted event-study estimation

Stata

eventstudyinteract y lead3 lead2 lag0 lag1 lag2, absorb(id time) cohort(cohort) control_cohort(never) covariates(x) vce(cluster id)

R Package:fixest

fixest::feols(y ~ sunab(cohort, time, ref.p = -1) + x | id + time, data = data, vcov = ~id, nthreads = 1)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Uses never-treated reference cohorts and -1 event-time reference. Match supported horizons, cohort-share aggregation and covariance conventions to eventstudyinteract.

gencohort

Create first-treatment cohorts including never-treated units

Stata

gencohort cohort, group(id) time(time) treat(treated)

R Package:stats

transform(data, cohort = ave(ifelse(treated == 1, time, Inf), id, FUN = function(v) { first <- min(v); rep(if(is.infinite(first)) 0 else first, length(v)) }))

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Uses zero as a never-treated category for cohort-based DiD. An absorbing treatment history and unique unit/time records are prerequisites; imputation estimators may instead require missing never-treatment times.

ivreghdfe

Instrumental variables with two absorbed effects

Stata

ivreghdfe y z (x = instrument), absorb(id time)

R Package:fixest

fixest::feols(y ~ z | id + time | x ~ instrument, data = data, vcov = "iid", nthreads = 1)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output.

Cluster-robust absorbed-effects IV

Stata

ivreghdfe y z (x = instrument), absorb(id time) cluster(id)

R Package:fixest

fixest::feols(y ~ z | id + time | x ~ instrument, data = data, vcov = ~id, nthreads = 1)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output.

Heteroskedasticity-robust absorbed-effects IV

Stata

ivreghdfe y z (x = instrument), absorb(id time) robust

R Package:fixest

fixest::feols(y ~ z | id + time | x ~ instrument, data = data, vcov = "hetero", nthreads = 1)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output.

Instrumental variables with individual fixed effects

Stata

ivreghdfe y z (x = instrument), absorb(id)

R Package:fixest

fixest::feols(y ~ z | id | x ~ instrument, data = data, vcov = "iid", nthreads = 1)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata command. Match singleton handling, covariance correction and absorbed-effect degrees of freedom before comparing inferential output.

ivregress

Formula-based instrumental-variable regression

Stata

ivregress 2sls y w (x = z)

R Package:AER

AER::ivreg(y ~ x + w | z + w, data = data)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Separate structural regressors and instruments with the formula bar.

5 more examples and alternatives

Cluster-robust two-stage least squares

Stata

ivregress 2sls y w (x = z), vce(cluster cluster)

R Package:estimatr

estimatr::iv_robust(y ~ x + w | z + w, data = data, clusters = cluster, se_type = "stata")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Small-cluster reference degrees of freedom are explicit.

Two-stage least squares with HC2 covariance

Stata

ivregress 2sls y w (x = z), vce(robust)

R Package:estimatr

estimatr::iv_robust(y ~ x + w | z + w, data = data, se_type = "HC2")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. HC corrections differ; estimatr stata aliases HC1 for unclustered IV inference.

Two-stage least squares with HC3 covariance

Stata

ivregress 2sls y w (x = z), vce(robust)

R Package:estimatr

estimatr::iv_robust(y ~ x + w | z + w, data = data, se_type = "HC3")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. HC corrections differ; estimatr stata aliases HC1 for unclustered IV inference.

Two-stage least squares with HC1 covariance

Stata

ivregress 2sls y w (x = z), vce(robust) small

R Package:estimatr

estimatr::iv_robust(y ~ x + w | z + w, data = data, se_type = "HC1")

Differs from Stata Stata small requests the N/(N-K) HC1 correction and t-based inference. estimatr se_type=“stata” aliases HC1 for unclustered IV. Without small, ivregress vce(robust) uses HC0 and normal reference inference, so it is a different default.

Two-stage least squares with stata covariance

Stata

ivregress 2sls y w (x = z), vce(robust) small

R Package:estimatr

estimatr::iv_robust(y ~ x + w | z + w, data = data, se_type = "stata")

Differs from Stata Stata small requests the N/(N-K) HC1 correction and t-based inference. estimatr se_type=“stata” aliases HC1 for unclustered IV. Without small, ivregress vce(robust) uses HC0 and normal reference inference, so it is a different default.

kmatch

Entropy balancing treated/control covariate moments through order 1

Stata

kmatch eb treat x z (y), att targets(1)

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "ebal", estimand = "ATT", moments = 1)

Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors.

Entropy balancing treated/control covariate moments through order 2

Stata

kmatch eb treat x z (y), att targets(2)

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "ebal", estimand = "ATT", moments = 2)

Fixed workflow; adapt the named data columns explicitly. Preprocessing weights targeting the treated population; normalization, higher moments and optimization tolerances must match. No outcome standard errors.

Inverse-probability weighting for the treated population

Stata

kmatch ipw treat x z (y), att

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Weights only; outcome contrasts and propensity-estimation variance require a separate estimator.

Multivariate Mahalanobis matching

Stata

kmatch md treat x z (y), att nn(1)

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "mahalanobis", replace = TRUE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Explicit nearest-neighbor alternative to kmatch’s kernel defaults; matching preprocessing only.

Propensity-score nearest-neighbor matching

Stata

kmatch ps treat x z (y), att nn(1)

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", replace = TRUE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Explicit nearest-neighbor alternative to kmatch’s kernel defaults; matching preprocessing only.

1 more examples and alternatives

Exact matching on categorical covariates

Stata

kmatch em treat category (y), att

R Package:MatchIt

MatchIt::matchit(treat ~ category, data = data, method = "exact", estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Exact-match preprocessing; estimand and stratum normalization are explicit.

psmatch2

Matched ATT point contrast after propensity-score preprocessing

Stata

psmatch2 treat x z, outcome(y) logit neighbor(1)

R Package:MatchIt

{ match <- MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", replace = TRUE, estimand = "ATT"); matched <- MatchIt::match_data(match); with(matched, weighted.mean(y[treat == 1], weights[treat == 1]) - weighted.mean(y[treat == 0], weights[treat == 0])) }

Fixed workflow; adapt the named data columns explicitly. Point contrast only; variance is not estimated, and matching ties/order may differ.

Propensity-score nearest matching with replacement

Stata

psmatch2 treat x z, outcome(y) logit neighbor(1) 

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", link = "logit", replace = TRUE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Returns matching preprocessing, not psmatch2’s outcome estimate or variance. Replacement, tie-breaking and match order must be explicit.

Propensity-score matching with an absolute caliper

Stata

psmatch2 treat x z, outcome(y) logit neighbor(1) caliper(.1)

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", link = "logit", replace = TRUE, caliper = .1, std.caliper = FALSE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Absolute probability-scale caliper; MatchIt defaults to standardized calipers unless explicitly disabled. Outcome estimation remains separate.

Propensity-score nearest matching without replacement

Stata

psmatch2 treat x z, outcome(y) logit neighbor(1) noreplacement

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", link = "logit", replace = FALSE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Returns matching preprocessing, not psmatch2’s outcome estimate or variance. Replacement, tie-breaking and match order must be explicit.

Mahalanobis matching with replacement

Stata

psmatch2 treat, outcome(y) mahalanobis(x z) neighbor(1)

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "mahalanobis", replace = TRUE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Matching preprocessing; covariance normalization and ties may differ from psmatch2.

pstest

Standardized covariate balance before and after matching

Stata

pstest x z, both

R Package:cobalt

cobalt::bal.tab(match, un = TRUE)

Fixed workflow; adapt the named data columns explicitly. Companion command supplied with psmatch2. Choose the same standardization denominator; cobalt’s balance table does not reproduce every pstest t-test or omnibus summary.

rdbwdensity

Bandwidth selection for density discontinuity

Stata

rdbwdensity x

R Package:rddensity

rddensity::rdbwdensity(x)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Bandwidths optimize density-estimation criteria, not treatment-effect estimation.

rdbwselect

RD bandwidth selection: cerrd

Stata

rdbwselect y x, bwselect(cerrd)

R Package:rdrobust

rdrobust::rdbwselect(y, x, bwselect = "cerrd")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria.

RD bandwidth selection: certwo

Stata

rdbwselect y x, bwselect(certwo)

R Package:rdrobust

rdrobust::rdbwselect(y, x, bwselect = "certwo")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria.

RD bandwidth selection: mserd

Stata

rdbwselect y x, bwselect(mserd)

R Package:rdrobust

rdrobust::rdbwselect(y, x, bwselect = "mserd")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria.

RD bandwidth selection: msetwo

Stata

rdbwselect y x, bwselect(msetwo)

R Package:rdrobust

rdrobust::rdbwselect(y, x, bwselect = "msetwo")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Official rdrobust companion command; bandwidth selectors target different criteria.

rddensity

Density continuity at the treatment threshold

Stata

rddensity x

R Package:rddensity

rddensity::rddensity(x)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Tests density continuity, not the RD identification assumptions as a whole.

Density continuity with fixed bandwidths

Stata

rddensity x, h(.4 .4)

R Package:rddensity

rddensity::rddensity(x, h = c(.4, .4))

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Tests density continuity, not the RD identification assumptions as a whole.

Cubic local-polynomial density discontinuity

Stata

rddensity x, p(3)

R Package:rddensity

rddensity::rddensity(x, p = 3)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Tests density continuity, not the RD identification assumptions as a whole.

rdrobust

Sharp local-linear RD

Stata

rdrobust y x

R Package:rdrobust

rdrobust::rdrobust(y, x)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

10 more examples and alternatives

Coverage-error-optimal RD bandwidth

Stata

rdrobust y x, bwselect(cerrd)

R Package:rdrobust

rdrobust::rdrobust(y, x, bwselect = "cerrd")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

Separate MSE-optimal bandwidths by side

Stata

rdrobust y x, bwselect(msetwo)

R Package:rdrobust

rdrobust::rdrobust(y, x, bwselect = "msetwo")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

Cluster-robust RD inference

Stata

rdrobust y x, cluster(cluster)

R Package:rdrobust

rdrobust::rdrobust(y, x, cluster = cluster)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

Covariate-adjusted RD

Stata

rdrobust y x, covs(z)

R Package:rdrobust

rdrobust::rdrobust(y, x, covs = z)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

Fuzzy regression discontinuity

Stata

rdrobust y x, fuzzy(treat)

R Package:rdrobust

rdrobust::rdrobust(y, x, fuzzy = treat)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Requires an exclusion restriction, a treatment-probability discontinuity and a suitable monotonicity assumption.

RD with fixed symmetric bandwidth

Stata

rdrobust y x, h(.4)

R Package:rdrobust

rdrobust::rdrobust(y, x, h = .4)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

RD with Epanechnikov kernel

Stata

rdrobust y x, kernel(epanechnikov)

R Package:rdrobust

rdrobust::rdrobust(y, x, kernel = "epanechnikov")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

RD with uniform kernel

Stata

rdrobust y x, kernel(uniform)

R Package:rdrobust

rdrobust::rdrobust(y, x, kernel = "uniform")

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

RD with ninety-percent confidence intervals

Stata

rdrobust y x, level(90)

R Package:rdrobust

rdrobust::rdrobust(y, x, level = 90)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

Local-quadratic RD

Stata

rdrobust y x, p(2)

R Package:rdrobust

rdrobust::rdrobust(y, x, p = 2)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. User-written Stata rdrobust command. Match version, bandwidth, kernel and variance settings; no finite-fixture cross-software parity claim.

tebalance

Covariate balance before and after weighting

Stata

tebalance summarize

R Package:cobalt

cobalt::bal.tab(w, un = TRUE)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Standardization denominator and binary-variable scaling must be aligned.

teffects

Augmented inverse-probability ATE point estimate

Stata

teffects aipw (y x z) (treat x z)

R Package:stats

{ ps <- stats::fitted(stats::glm(treat ~ x + z, data, family = stats::binomial())); m0 <- stats::predict(stats::lm(y ~ x + z, data, subset = treat == 0), data); m1 <- stats::predict(stats::lm(y ~ x + z, data, subset = treat == 1), data); mean(m1 - m0 + data$treat * (data$y - m1) / ps - (1 - data$treat) * (data$y - m0) / (1 - ps)) }

Differs from Stata Fixed workflow; adapt the named data columns explicitly. No standard errors; double robustness still requires overlap and identifying assumptions.

13 more examples and alternatives

Propensity-score weights targeting ATC

Stata

teffects ipw (y) (treat x z) 

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATC")

Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults.

Propensity-score weights targeting ATE

Stata

teffects ipw (y) (treat x z) 

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATE")

Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults.

Propensity-score weights targeting ATO

Stata

teffects ipw (y) (treat x z) 

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATO")

Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults.

Normalized IPW point effect for ATE

Stata

teffects ipw (y) (treat x z) 

R Package:WeightIt

{ w <- WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATE")$weights; weighted.mean(data$y[data$treat == 1], w[data$treat == 1]) - weighted.mean(data$y[data$treat == 0], w[data$treat == 0]) }

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Point estimate only; outcome-free weighting assumes conditional exchangeability and overlap. Weight-estimation uncertainty is not quantified.

Propensity-score weights targeting ATT

Stata

teffects ipw (y) (treat x z) , atet

R Package:WeightIt

WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Computes weights only, not treatment effects or standard errors. ATO and ATC are alternative target populations, not Stata teffects defaults.

Normalized IPW point effect for ATT

Stata

teffects ipw (y) (treat x z) , atet

R Package:WeightIt

{ w <- WeightIt::weightit(treat ~ x + z, data = data, method = "glm", estimand = "ATT")$weights; weighted.mean(data$y[data$treat == 1], w[data$treat == 1]) - weighted.mean(data$y[data$treat == 0], w[data$treat == 0]) }

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Point estimate only; outcome-free weighting assumes conditional exchangeability and overlap. Weight-estimation uncertainty is not quantified.

Inverse-probability-weighted outcome-regression ATE

Stata

teffects ipwra (y x z) (treat x z)

R Package:stats

{ ps <- stats::fitted(stats::glm(treat ~ x + z, data, family = stats::binomial())); data$w <- ifelse(data$treat == 1, 1 / ps, 1 / (1 - ps)); m0 <- stats::predict(stats::lm(y ~ x + z, data, subset = treat == 0, weights = w), data); m1 <- stats::predict(stats::lm(y ~ x + z, data, subset = treat == 1, weights = w), data); mean(m1 - m0) }

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Point estimation only; Stata jointly computes the estimating-equation variance.

Mahalanobis nearest-neighbor preprocessing

Stata

teffects nnmatch (y x z) (treat), atet

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "mahalanobis", replace = TRUE, estimand = "ATT")

Matches with replacement, as teffects does. MatchIt returns preprocessing weights and matches, not the treatment-effect estimate; tie handling, distance conventions, bias correction and Abadie-Imbens standard errors require separate alignment.

Matching with replacement

Stata

teffects psmatch (y) (treat x z), nneighbor(1) atet

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", ratio = 1, replace = TRUE, estimand = "ATT")

Fixed workflow; adapt the named data columns explicitly. Preprocessing only; MatchIt does not reproduce teffects matching bias correction or Abadie-Imbens standard errors.

One-to-one nearest propensity-score matching

Stata

teffects psmatch (y) (treat x z), nneighbor(1) atet

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", ratio = 1, replace = TRUE, estimand = "ATT")

Matches with replacement, as teffects does. MatchIt returns preprocessing weights and matches, not the treatment-effect estimate; tie handling, distance conventions, bias correction and Abadie-Imbens standard errors require separate alignment.

One-to-two nearest propensity-score matching

Stata

teffects psmatch (y) (treat x z), nneighbor(2) atet

R Package:MatchIt

MatchIt::matchit(treat ~ x + z, data = data, method = "nearest", distance = "glm", ratio = 2, replace = TRUE, estimand = "ATT")

Matches with replacement, as teffects does. MatchIt returns preprocessing weights and matches, not the treatment-effect estimate; tie handling, distance conventions, bias correction and Abadie-Imbens standard errors require separate alignment.

Regression-adjustment average treatment effect

Stata

teffects ra (y x z) (treat)

R Package:stats

{ fit0 <- stats::lm(y ~ x + z, data, subset = treat == 0); fit1 <- stats::lm(y ~ x + z, data, subset = treat == 1); mean(stats::predict(fit1, data) - stats::predict(fit0, data)) }

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Point-estimate g-computation under correctly specified potential-outcome models; no causal identification is established by fitting alone.

Regression-adjustment effect among treated units

Stata

teffects ra (y x z) (treat), atet

R Package:stats

{ fit0 <- stats::lm(y ~ x + z, data, subset = treat == 0); fit1 <- stats::lm(y ~ x + z, data, subset = treat == 1); treated <- data[data$treat == 1, ]; mean(stats::predict(fit1, treated) - stats::predict(fit0, treated)) }

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Averages counterfactual differences over the treated covariate distribution.

teoverlap

Propensity-score overlap summary by treatment

Stata

teoverlap

R Package:stats

{ ps <- stats::fitted(stats::glm(treat ~ x + z, data, family = stats::binomial())); lapply(split(ps, data$treat), function(v) stats::quantile(v, c(0, .05, .5, .95, 1))) }

Fixed workflow; adapt the named data columns explicitly. Numeric overlap diagnostic; no density plot or automatic trimming.

xtdidregress

Panel difference-in-differences with unit and period fixed effects

Stata

xtdidregress (y x) (treated), group(id) time(time)

R Package:fixest

fixest::feols(y ~ treated + x | id + time, data = data, vcov = ~id, nthreads = 1)

Differs from Stata Fixed workflow; adapt the named data columns explicitly. Homogeneous-effect two-group design with parallel trends and no anticipation. Under staggered timing and heterogeneous effects, TWFE is not a replacement for modern cohort-specific estimators; covariance finite-sample conventions can differ.