ngreifer / WeightIt

WeightIt: an R package for propensity score weighting
https://ngreifer.github.io/WeightIt/
102 stars 12 forks source link

Is this actually G-computation? #50

Closed lorenzoFabbri closed 1 year ago

lorenzoFabbri commented 1 year ago

With reference to the following piece of code, I am wondering whether this is actually G-computation. I thought G-computation would be performed with marginaleffects::avg_comparisons(). Aren't those just predicted values of the outcome when the exposure is set to specific values?

ngreifer commented 1 year ago

G-computation is a method of estimating a counterfactual mean. It is precisely computing "predicted values of the outcome when the exposure is set to specific values". This is exactly what avg_predictions() does. The contrast between two counterfactual means is the treatment effect. avg_comparisons() both generates predictions at specific values of the exposure and computes the contrast between the counterfactual means.