# How to model the regression coefficient of a sum as a function of the sum elements?

I wonder if it is somehow possible to model the regression coefficient of a sum as a function of the sum's elements by any transformation of the model/the regressors.

If you ask yourself what the idea behind this is, you can imagine for example the effectiveness of advertising. Spending money in advertising results in a certain effect on the outcome (e.g. sales). But there is no "the" advertising since you spend money in different advertising channels like TV, print, digital etc.

Assume that our outcome is generated as $${\bf y} = \alpha + {\bf Adv} {\boldsymbol \beta}+ {\bf \boldsymbol \gamma} {\bf CV} + {\boldsymbol \epsilon}$$, where $${\bf Adv}$$ is a matrix of the channel-specific spendings in the different advertising channels and $${\bf CV}$$ are some other variables that may correlate with both $${\bf y}$$ and the advertising spendings. If I now regress the outcome on the sum of the advertising spendings, my $$\beta$$ for the sum of the spendings, i.e. the aggregated effect of the channel-specific spendings, is the weighted average of the individual betas weighted by the variance of the corresponding regressor.

This can be easily shown:

set.seed(2409)

n <- 1000 #number of observations
k <- 5 #number of regressors
beta <- rnorm(k, 5, 5) #true regression coefficients
var <- round(runif(k, 0.1, 10)) #variance of the regressors

coef <- numeric()

#this for loop runs the data generation and regression analysis 10,000 times
#and saves the regression coefficient

for (i in 1:10000){
x <- matrix(NA, n, k)

for (l in 1:k){
x[,l] <- rnorm(n, 0, sqrt(var[l]))
}

sumX <- rowSums(x)

y <- 2 + x%*%beta + rnorm(n,0,0.1)

model <- summary(lm(y~sumX))

coef[i] <- model$coefficients[2] } #this is the mean of the regression coefficients mean(coef) [1] 5.632283 #this is the weighted average of the true coefficients weighted by the #variance of the regressors beta%*%var/sum(var) [,1] [1,] 5.6326  I now wonder if there is any way to estimate the aggregated effect (i.e. the effect of the sum of the regressors) and the contribution of the sum elements to the aggregated effect in one model by any type of interactions. Coming back to the advertising example, we would be interested, for example, which channels in particular influence the overall advertising effectiveness and how exactly (strong / weak? positive / negative?). Of course, this is interesting to know because a realloction of the budget can lead to a higher overall effectiveness of advertising. Of course there are also other applications for this. Imagine, for example, that you know how many units of a product you have distributed in total and how this number of units affects a certain success measure. But you also know exactly how many united you have distributed to e.g. which supermarket. Of course, it could make sense to distribute more to the markets that have a strong contribution to the overall effect and less to the markets with a weaker or even negative contribution. I really hope, I could make my question clear and I am looking forward to your ideas! ## 1 Answer If you add a sum of regressors as a single regressor, then that is equivalent to imposing the constraint that the effects of all of the variables that went into that sum are the same. So let's say we called our sum regressor $$sum$$ and we included it in our regression model: $$\hat{y} = \beta_0+ \beta_1 sum$$ Now $$sum$$ is $$x_1+ x_2 + x_3$$, so we can substitute that in the equation above: $$\hat{y} = \beta_0+ \beta_1 (x_1+ x_2 + x_3)$$ We can write that out as: $$\hat{y} = \beta_0+ \beta_1 x_1 + \beta_1 x_2 + \beta_1 x_3$$ Notice that all three $$x$$s have the exact same effect $$\beta_1$$. So adding a sum of variables is an old-school technique of imposing the constraint that the effects are the same. So you can't use this technique to figure out which $$x$$ has the stronger effect. For that you will just have to add each $$x$$ separately to your model. • Thanks for your comment and explanation! Actually, we would like to consider both the sum of the regressors and the individual regressors in one model and would not like to run two separate models. That's why I was thinking about something like moderation effect with$y = \alpha + \beta sum + \epsilon$and$\beta = F(x_1,...,x_k)\$ Sep 16, 2020 at 12:59
• It is a bit strange to try to constrain and not constrain effects to be equal in the same model. Sep 16, 2020 at 13:29
• Maybe what you are looking for is a sheafcoefficient: Heise, David R. (1972). Employing nominal variables, induced variables, and block variables in path analysis. Sociological Methods & Research, 1(2): 147--173. This will give you an overall effect and contributions of each of the variables feeding into that overall effect. Sep 17, 2020 at 12:05