# Linear Regression and cost per employee vs total cost

Thank you for taking a look at my question!

Here's some background info: my employer has a lot of (very confidential) data on numerous corporations, both public and private, across a wide range of industries.

I was exploring some departmental cost data, and have some questions about the results of my analysis. I have access to the departmental cost per end user and total number of end users for a few hundred companies. So for company ABC Inc., it might be \$1000 per end user, with 275 end users, for a total department cost of \$275,000.

My first attempt to build a simple regression model for this data resulted in $ln(\text{Total Cost}) = \beta_0 + \beta_1 ln(\text{End Users})$

The model looked great! R-squared around 0.8, residuals appeared approximately normal (histogram and quantile quantile plot), and the residuals vs fitted plot did not display heteroskedasticity! Also, the log-log model has a pretty straight forward interpretation of the slope coefficient.

As my boss was interested in determining if economies of scale were present for the cost per end user data, I back-transformed the fitted values (no worries, I DID NOT back transform any confidence intervals. I know that's a no-no) using the exponential, and then divided each fitted cost by the end-users to get an estimate of cost per end user.

Plotting this data against the observed cost per end user vs end user scatter plot yielded a curve that fit the trend in the data quite nicely! Cost per end user decreases (with a decreasing rate) as end users increases.

However, when I attempt to perform regression with cost per end user as the response and end users as the predictor, no transforms yield a linear relationship, and the regression models all have R-squared around 0.07.

Why is this the case when the relationship between total cost and end users is modeled almost perfectly by the log-log model? I'm sure there's something from math stats that I'm forgetting.

I worry that my analysis is erroneous due to something that I'm not aware of.

Thanks for any tips!

Edit: picture added per my comment to Whuber. Axis values removed to help preserve confidentiality of data. My employer takes that stuff very seriously.

• Let $X$ be end users and $Y$ be total cost. Take the original model $\log(Y)=\beta_0+\beta_1\log(X)$, which "fit the trend quite nicely." Dividing $Y$ by $X$ is equivalent to subtracting $\log(X)$ from $\log(Y)$. Thus your model implies $$\log(Y/X)=\beta_0+(\beta_1-1)\log(X),$$ which is a beautiful linear relationship between the logs. This makes it difficult to believe that "no transforms yield a linear relationship." Since $R^2$ is next to useless for evaluating linearity, that's of no help. Could you describe what you're doing more specifically?
– whuber
Nov 15 '16 at 21:33
• Hey Whuber, thanks again for responding to one of my posts! I feel like every question I've asked on here has received a helpful comment or answer from you. I guess this cold has impeded my ability to think clearly. You're absolutely right about the relationship between $Y$, $X$, and $Y/X$. The two models I made in R are related how you said, and the back-transformed cost per end user values are the same from both (makes sense). Nov 15 '16 at 22:09
• I guess this is my concern: when I log total cost and end users, and then make a scatter plot, the relationship is almost perfectly linear (Pearson correlation is 0.875). The data clusters nicely around the regression line. However, when I plot logged cost per end user against logged end users, the scatterplot (see edited post above) looks mostly random, with a very very weak negative trend. Plotting the regression line against this data makes me think another model (nonlinear?) would be better. Both models are used to predict cos/end-user, but one approach feels less valid than the other. Nov 15 '16 at 22:11
• Your plot is a version of a residual plot. By construction, there should be no trend at all (but in going back and forth between logs and original values you appear to have introduced a slight trend). It's impossible to read, because you haven't supplied scales on the axes: what is most important are the magnitudes of the cost per user values. If they don't vary much, you have a great model.
– whuber
Nov 15 '16 at 22:23
• As far as I understand your original model can be represented as ln(CostPerUser*EndUsers) = b0 + b1*ln(EndUsers). It is rather obvious that it will have high R-square. But why do you expect that models ln(CostPerUser) = b0' + b1'*ln(EndUsers) or CostPerUser = b0'' + b1''*EndUsers also will have high R-square? Nov 15 '16 at 22:25

"As my boss was interested in determining if economies of scale were present for the cost per end user data...

I guess this means whether cost per user goes down as number of users increases.

You start by assuming something like

$$TC_i = B_0U_i^{\beta_1}e^{v_i} = f(U_i)$$

which to a degree is validated as a postulated specification because it provides a "good" descriptive relation at log-log level.

Then note that $f(U_i)$ is a homogeneous function in $U_i$, with degree of homogeneity $\beta_1$, because

$$f(\alpha U_i) = \alpha^{\beta_i}f(U_i)$$

The degree of homogeneity and economies of scale are closely linked. Here if $\beta_i < 1$ we get "cost economies of scale": if number of users doubles, total cost won't double and so average cost will go down.

So you can use the regression specification with Total Cost as the dependent variable, and see what estimate and what confidence interval you get on $\hat \beta_1$.