# Linear fit with constraints for positive slope

#### chemist

##### New Member
I could use some help from a stats wiz on a linear regression issue:

I am working with a chemical process that increases the amount of a substance linearly in time and the trend CANNOT have a negative rate (i.e. negative slope). I am conducting a study which includes many reactions of this type. Each reaction data set consists of x and y values where x is time and y is the amount of a substance. There is noise in the y response variable due to measurement error. When the response of the system is small relative to the measurement error (i.e. noise-dominated) it is possible for a least-squares fit to output a line with a negative slope. Although it is the "Best Fit" of the data, it is an impossible scenario for this system and therefore meaningless. My downstream analysis includes calculating the log(rate) which is -inf for rate=0 and is complex for any rate<0. I am forced to treat negative slopes like missing data as they do not have valid outputs. However, the scenarios that most interest me for my study are the ones with low response as I am trying to demonstrate that the reaction rate is very slow. As a result, I end up with about 50% unusable data sets that have negative rates even though it is behaving as I would hope.

So my question is, does anyone have any ideas for how I can use these data sets, perhaps by applying constraints to a linear fit to guarantee a positive slope?

#### katxt

##### Member
I can't see any way to produce a positive slope from data that gives a negative slope, except to say that in these cases we will just make the slope = 0.001 or some other suitably small value. (This is the constraint you are hoping for, but it doesn't seem very satisfactory.)
The short answer, perhaps, is that the measurement system just won't allow any estimate of slope to be made in this case.
However, you can still make some sensible statements. A best fit slope is not the true slope, just an estimate of it. Each data set can provide a 95% (say) confidence interval for the true slope. If you know that the true slope is in fact greater than 0, then you can cut the lower bound of the CI off at 0.001 or something and say "we don't know what the true slope is, but we are reasonably sure that it is positive, and less than ..."