Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Hello dear mathematicians,

I'm not entirely sure what to tag this question with since I'm new here but I hope some more experienced user can guide me. Here is my problem:

I'm using an internal software in which we use equations to calculate the value of an article. The value is calculated by a linear equation multiplied with up to 5 constants (or some might use addition instead of multiplication). Here is an example of an equation for the value of a bolt:

y=value x=length a=diameter b=material c=type, d=with or without nut

x is continuous, i.e the bolt can be 6.7mm, 15.3mm or whatever. a, b, c and d are categories and can only have specific values: a can be 4mm, 6mm or 8mm; b can be steel s1 or steel s2; c can be standard or professional; d can be with or without nut.

The way our software calculates the value is by the following equation:

y=(kx+m)*a*b*c+d

The way we retrieve the equation is by manually fitting the line to a lot of data with different values for these constants while knowing the price of the bolt. For example we see that a bolt with a nut usually cost ~$5 more than one without a bolt so we conclude that d is 5 since we just add d. To get b we compare the articles made out of material s1 to the ones made out of material s2 and we see that s1 cost ~1.2 times more so we set b to 1.2 for s1 and s2 to 1 since this is a factor we multiply the continuous equation with. And the same procedure for all the other constants.

If I would do a regression analysis out of all data I would instead get an equation which looks something like (my statistics is a bit rusty but i think it's like this):

y=kx1+ax2+bx3+cx4+dx5

Our software doesn't handle this kind of equations so my question is if I somehow could convert an regression equation in someway to the type of equation we use. It doesn't need to be perfect since the only thing I'm looking for is to get a rough line to start working from instead of having to set every parameter from the beginning. As you might suspect the manual fitting of these equations take quite some time so it would save alot of time, energy and frustration if I had a rough line to tune instead of beginning all over everytime.

We do most of the stuff in Excel and Visual Basic but the question is more of how to convert the equation than how to technically code the solution.

All help is appreciated, I asked the question on stackoverflow and they directed me here so I hope I am in good hands.

Thanks!

share|improve this question
    
TL;DR: OP has bunch of examples. Each example has features $x, a, b, c, d$ and value $y.$ OP wants to fit the examples in a model $$ y_i = (kx_i + m)a_i b_i c_i + d_i$$ with $k, m$ being the parameters computed by the fitting method. –  user2468 Apr 3 '12 at 23:12

1 Answer 1

If I understand correctly, your desired model is $$ y = (kx+m)abc+d \tag{1}$$ but linear regression (by external software) gave you $$ y = w_1k+w_2a+w_3b+w_4c+w_5d \tag{2}$$ First, note that your model is non-linear. To see that, rewrite equation $(1)$ as $$ y = kxabc + mabc + d $$ What you could do though is transform your system into linear-least squares with non-linear features. I will explain. First, let's represent $a, b, c$ using numbers.

What you need to do is to reshape your system into a matrix form: $\mathbf{y} = Xw,$ where $\mathbf y$ is a vector of $y$ values, and $X$ is a feature matrix of the form: $$ \begin{pmatrix} \color{red}{xabc} & \color{red}{abc} \\ x_1 & x_2 \\ \ldots & \ldots \end{pmatrix} \begin{pmatrix} k \\ m \end{pmatrix} = \begin{pmatrix} \color{red}{ y -d} \\ y_1 - d_1 \\ \ldots \end{pmatrix} $$ For each item (bolt), we will have a row in this matrix.

Let me show how one row would like like. Assume a particular bolt has $x = 6.7,$ $a = 4,$ $b = 2$ (i.e. s2; put 1 for s1), $c = 2$ (i.e., professional; for 1 for standard), $d = 1$ (means with; put $2$ for without). Also, assume for this item, we know $y = 2.1$

To construct the row corresponding to this item, compute $$ xabc = 107.2, \quad abc = 16, \quad y - d = 1.1$$ So put a row in the system $(107.2 \quad 16) \quad (1.1).$

So your matrix system ${\mathbf y} = Xw $ would look like: $$ \begin{pmatrix} 107.2 & 16 \\ \ldots & \ldots \\ \text{one row per item} \end{pmatrix} \begin{pmatrix} k \\ m \end{pmatrix} = \begin{pmatrix} 1.1 \\ \ldots \\ \text{one row per item} \end{pmatrix} $$

Our goal now is to find $w = (k \quad m)^{T}$ such that $$y = (k x + m)abc + d.$$ This is straight linear least squares (Google it). It is given by: $$ w = (X^{T}X)^{-1} {\mathbf y} $$ We know $X$, we know ${\mathbf y}.$ We can solve for $w$ using linear algebra packages.

share|improve this answer
    
Thank you! I have only had time to read your answer briefly but I think it is what I was hoping for. –  Joe Apr 4 '12 at 10:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.