LinearModelFit[{m,v}]
will return a coefficients list $\beta$ from the design matrix $m$ and response vector $v$, where $m.\beta$ is fitted to $v$. However, the parameters in $\beta$ could be negative. For example,
LinearModelFit[{{{1, 2, 3, 4}, {2, 3, 7, 6}}, {2, 3}}]["BestFitParameters"]
will return {0.0381679, 0.198473, -0.00763359, 0.396947}
, where the third parameter is negative.
How could I force LinearModelFit[{m,v}]
to fit with only positive parameters? Is there an Option I can set constrain on coefficients?
I use LinearModelFit[{m,v}]
because the length of $m$ (the number of variable) could vary from case to case.
Seems I raise a bad example. In reality the number of unknowns is less than the number of equations, that is Length@m[[1]]<Length@v
.
NonlinearModelFit[Append @@@ Transpose[{{{1, 2, 3, 4}, {2, 3, 7, 6}}, {2, 3}}], {Array[c, 4].Array[x, 4], And @@ Thread[Array[c, 4] > 0]}, Array[c, 4], Array[x, 4]]
$\endgroup$