# Generalized regression with both additive and multiplicative errors

For measurements of chemical concentrations, it is often the case that the error in the data increases as the true (or estimated) concentration increases. That is, the error is multiplicative and has a constant coefficient of variation (CV), rather than being additive with a constant variance. The latter is assumed in classic linear regression of the model $$y=\beta x + \epsilon$$, $$\epsilon \sim N(0, \sigma)$$, where $$y$$ are the measured data and $$x$$ the measured predictors (in a vector). I read about the former being modeled using gamma regression, a case of generalized linear models (GLiMs) where the link function is either the log link $$g(E[y])=\log(E[y])=\beta x$$ or the reciprocal link $$g(E[y])=\frac{1}{E[y]}=\beta x$$, and the residuals are gamma distributed. I understand (I could be wrong) that multiplicative errors afe often written as $$y=e^{\beta x}e^{ \epsilon}$$, so that we can linearize the equation as $$\log(y)=\beta x + \epsilon$$.

1. More generally, can multiplicative errors be written as $$y=f(\beta, x)\epsilon$$, and additive errors as $$y=f(\beta, x)+\epsilon$$? Here, $$f$$ is some function of the coefficients and predictors linear or non-linear in the coefficients. To get a GLiM, we use $$f(\beta, x)=g^{-1}(\beta x)$$.

It seems proper to model one's standard curve measurements of chemical concentrations with gamma regression. But it is also observed in practice that the assumption of constant CV will break down at low concentrations. Constant CV implies that the error keeps shrinking until it becomes 0 when one is measuring blank samples. In reality, there is another component of noise that emerges, one that is additive and has a constant variance. Even blank samples are expected to have some background of positive noise, and this positive noise is always present until it is dwarfed by the error with constant CV.

The main question I have is whether it is kosher to write a statistical model as follows:

$$y=f(\beta, x)\epsilon_1 + \epsilon_2$$ , where the epsilons are error terms distributed by some distribution, like gamma for $$\epsilon_1$$ and Poisson for $$\epsilon_2$$.

1. If so, how does one translate this model into the form more commonly used for GLiMs, namely the three equations $$E[y]= ...$$ , $$Var[y]= ...$$ , and $$Y \sim SomeDistribution()$$? How does one do such a regression? Is there a name for this kind of model?

2. Also, when gamma regression assumes $$y \sim Gamma(\nu, \lambda)$$ so that $$Var(y)=\frac{1}{\nu} E[y]^2$$ for constant CV $$\sqrt{\frac{1}{\nu}}$$ (using the parameterization here), how should $$\epsilon_1$$ be distributed?

I actually want to write such a model in Stan to fit data of bacteria growth curves, and my $$f$$ is thus a non-linear function with several predictors and parameters. My code currently models (I think) a constant CV as follows:

data{
int nData;
real<lower=0> time[nData];
... //other predictors passed in as vectors of length nData.
}
parameters{
real<lower=0> coef_var; //coefficient of variance I want to estimate
real<lower=0> FP; //false positives, the additive error. I don't know where to put this.

//parameters that are arguments to the function f, a.k.a. a_long_function
real<lower=0> alpha;
real<lower=0> beta;
... //more parameters
}
transformed parameters{
real<lower=0> y_mean[nData];
for (i in 1:nData){
y_mean[i] = a_long_function(alpha, beta, time[i], ...) + FP; //Is currently giving every observation a fixed false positive rate.
}
}
model{
for (i in 1:nData){
y_observed[i] ~ gamma( 1/(coef_var^2), 1/(y_mean[i]*(coef_var^2)) )
//Stan follows this parameterization: https://mc-stan.org/docs/2_22/functions-reference/gamma-distribution.html
}
coef_var ~ gamma( 0.01, 0.01 ); //vague prior that is non-negative
FP ~ gamma( 0.01, 0.01);

alpha ~ gamma(...); //priors for my parameter of interest
...
}

1. Any ideas on where the additive error term should go in my code to correctly model $$y=f(\beta, x)\epsilon_1+\epsilon_2$$?

Previous questions: