How can i find the variance of ATE by using g computation without bootstraping? I have a binary treatment and binary outcome and have estimated the average treatment effect (ATE) by using g-computation, which involves training a model for the outcome given the covariates and treatment, generating predicted values by setting the treatment to 1 and then to 0, and taking the average of the differences between the predicted values. Most sources recommend using bootstrapping to estimate the variance of the resulting estimate. Is it possible to get the variance without bootstrapping?

If you use a parametric outcome regression model like logistic regression, you can estimate the ATE as an average marginal effect, e.g., using the margins package in R or the margins function in Stata. These procedures use the delta method to compute the variance of the ATE.
It may also be possible to use an empirical Bayes approach, which is similar to bootstrapping in that you have to resample and compute the effect many times, but instead of sampling before fitting the model, you sample from the fitted model. That is, you assume the coefficients follow a multivariate normal distribution (which is asymptotically true), and from each draw of the coefficients, you compute the ATE for all units. The distribution of the ATE across all the coefficient draws is its sampling distribution, the variance of which can serve as the variance for the ATE. This is described in the context of mediation analysis by Imai, Keele, and Tingley (2010) and in the context of propensity score matching by Austin, Rubin, and Thomas (2021) (and probably others).
If you didn't use a parametric model and instead used a machine learning method to estimate the potential outcomes, there is no straightforward to estimate the variance of the ATE after g-computation. However, if you construct a doubly robust estimator like augmented inverse probability weighting (AIPW) or targeted minimum loss-based estimation (TMLE), you can use the influence function to estimate the variance. The influence functions for these estimators are functions only of the predicted values (i.e., the estimated potential outcomes and propensity scores). However, my understanding is that for the standard versions of both estimators, inference is not doubly robust, even though the effect estimate is; that is, both models need to be correct for the influence function to provide a valid estimate of the variance. There may be some robust versions of these methods that allow for doubly robust variance estimation as well, but they are somewhat arcane.
