# Kernel Estimation to Estimate Treatment Effect

I am trying to determine whether an estimator I came up with is just a non-parametric kernel estimator. I am performing a simulation study to estimate a treatment effect that I impose on my data.

My "idea": The counterfactual for a treated observation is the weighted average of nearby untreated observations, where being "near" the treated observation results in higher weight. Likewise, the counterfactual for an untreated observation is the weighted average of nearby treated observations. To estimate the ATE (average treatment effect), simply average the differences (treated observation - counterfactual) and (counterfactual - untreated observation).

To my knowledge, this is sort of similar to kernel regression but maybe a special case that I would have to code up on my own. For instance, to estimate the counterfactual for a treated observation, $$y_1$$, I'd have:

$$\hat{y_1} = \frac{\sum y_i K(\frac{x_1-x_i}{h})}{\sum K(\frac{x_1-x_i}{h})}$$

Where $$i$$ is all untreated observations, and $$h$$ is selected by CV.

So my question is, am I just stumbling into something that can easily be punched into a regression command (say, in R), where the function is $$Y = \eta(X, t)$$ and $$X$$ are covariates and $$t$$ is the treatment indicator, and from which the coefficient for $$t$$ is my ATE?

I actually have not seen an R implementation of it, which is a shame. I believe it is available in Stata using the kmatch library.