# What is the best way to form a confidence interval for a weighted sum of expected responses in a GLM?

Suppose you have a generalised linear model (GLM) with link function $$g$$ so that the true expected responses in your model (with $$n$$ data points) are:

$$\mu_i \equiv \mathbb{E}(Y_i | \mathbf{x}_i) = g^{-1}(\mathbf{x}_i \boldsymbol{\beta}) \quad \quad \quad \text{for } i = 1,...,n.$$

Now, suppose you have a set of known weights $$\omega_1,...,\omega_n$$ and you want to make an inference about the weighted sum of the expected responses:

$$\mu_\omega \equiv \sum_{i=1}^n \omega_i \mu_i = \sum_{i=1}^n \omega_i \cdot g^{-1}(\mathbf{x}_i \boldsymbol{\beta}).$$

This kind of problem arises in certain applications where you want to form some kind of "standardised" or "weighted" expected response using a set of exogenous weights. In most models of interest, the link function $$g$$ is nonlinear, so its inverse $$g^{-1}$$ is also nonlinear. Thus, the inference here is (usually) about a nonlinear function of the parameter vector $$\boldsymbol{\beta}$$. Presumably this means that forming a confidence interval involves use of the asymptotic normal distribution for the coefficient vector, combined with the delta method to deal with the nonlinear transform. I am aware of some general ways this could be done (e.g., delta method, simulation, etc.), but I'm not sure what is "best practice" here.

Question: What is the best way to form a confidence interval for $$\mu_\omega$$? How is this implemented using a glm model in R? (An example for a logistic regression would be lovely.)

Thus, the inference here is (usually) about a nonlinear function of the parameter vector $$\beta$$. Presumably this means that forming a confidence interval involves use of the asymptotic normal distribution for the coefficient vector, combined with the delta method to deal with the nonlinear transform. I am aware of some general ways this could be done, but I'm not sure what is "best practice" here.
This is precisely what you should do if you want a confidence interval. If the data are independent, then it's fairly easy to derive. After you compute your Delta method distribution, you're just multiplying by a vector. So, $$\sqrt{n}\left(w^T g^{-1}(X\beta) - w^T\mu_\delta \right) \sim N\left(0, w^T \Sigma_\delta w \right)$$
You have to be careful about how you define the covariance matrix you use in your Delta method approximation. Do you want a confidence interval for the mean (in which case you want to use the $$\Sigma = \Sigma_\beta$$ from the coefficient estimates)? Or do you want a prediction interval for the quantity (in which case you'll want to use $$\Sigma = \Sigma_\beta + \sigma^2 I$$ combining the prediction uncertainty as well)?
You should be able to derive the necessary quantities for logistic regression with this. You seem to know the Delta method already. You know $$g^{-1}$$ for logistic regression, $$\frac{\exp(X\beta)}{1 + \exp{X\beta}}$$. You can get the necessary covariance matrix from glm. It's just a matter of plugging it in.