I'd like to fit integer coefficients, e.g. summing to 10, to a regression equation. The absolute values of the coefficients (i.e. predicted y) aren't important, I just want to retain the appropriate relative values. The use case is for an easily interpretable scoring system.
For example, this regression yields the following coefficients (ignoring the intercept):
set.seed(0)
y <- rnorm(100)
x <- matrix(rnorm(300), ncol=3)
m <- lm(y ~ x)
(coef <- m$coefficients[-1])
# x1 x2 x3
# 0.12100965 0.05506511 0.14708549
Rounding with the below code yields a rounding error (sums to 11):
round(10 * coef / sum(coef))
# x1 x2 x3
# 4 2 5
A method like this also doesn't guarantee maximally similar weights to the regression equation.
This was asked here without satisfactory answers, and might be addressed in this paywalled research paper.
Edit: looks like http://stackoverflow.com/questions/792460/how-to-round-floats-to-integers-while-preserving-their-sumhttps://stackoverflow.com/questions/792460/how-to-round-floats-to-integers-while-preserving-their-sum may be able to help minimize the roundoff error. If my question is further specified as minimizing the error of a predicted (scaled) y, I'm unsure whether this is an equivalent optimization.