# Fitting: Newb questions

I am currently working with a list of data and trying to fit some parameters to it. I'm pretty sure I'm just making some boneheaded mistakes here.

The data is represented as disslist={a,b,c,d,e...}, where a,b,c,d,e are numbers.

The parameters are represented as:en2 = {f,g,0,0,0,0}, en3={0,h,k,0,0}.. and so on, where f,g,h,k are numbers

What I want to fit is a simple y[[ i ]]= v[ j ]*en#[[ i,j ]], for the v[ j ]s;

where i is the depth of my data list and j is the depth of my parameters.

so: a=v[1]f+v[2]g; b=v[2]h+v[3]k and so on...

If this isn't clear enough, I can provide my code:

I'm trying to use the FindFit function; however, I return errors:

FindFit[disslist, aa*en2*x + ab*en3*x + ac*en4*x + ad*en5*x + ae*en6*x + af*en7*x + ag*en8*x + ah*en9*x + ai*en13*x + aj*en14*x + ak*en15*x + al*en16*x + am*en100*x, {aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am}, x]


FindFit::eqineq: "Constraints in {18 aa x,10 ah x,100 am x,24 aa x+7 ab x,16 aa x+13 ab x,8 aa x+19 ab x,15 ab x+8 ac x,5 ab x+16 ac x,2 ac x+15 ad x,5 ad x+10 ae x,8 af x+4 ag x,5 ai x+2 aj x,2 ak x+4 al x} are not all equality or inequality constraints. With the exception of integer domain constraints for linear programming, domain constraints or constraints with Unequal (!=) are not supported."

FindFit[{0.0436684, 0.0559257, 0.0923392, 0.101887, 0.107537, 0.121057, 0.125166, 0.122422, 0.119247, 0.117625, 0.103468, 0.131411, 0.132292, 0.166463}, {8 aa x, 18 aa x, 24 aa x + 7 ab x, 16 aa x + 13 ab x, 8 aa x + 19 ab x, 15 ab x + 8 ac x, 5 ab x + 16 ac x, 2 ac x + 15 ad x, 5 ad x + 10 ae x, 8 af x + 4 ag x, 10 ah x, 5 ai x + 2 aj x, 2 ak x + 4 al x, 100 am x}, {aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am}, x]

EDIT: Here is the necessary code to generate my problem, thanks for any help you might be able to provide (and please don't laugh at my clunky coding skills).

vars = {{{8, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0,
9}, {0, 13}, {0, 14}, {0, 15}, {0, 16}, {0, 100}}, {{18, 2}, {0,
3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 13}, {0,
14}, {0, 15}, {0, 16}, {0, 100}}, {{24, 2}, {7, 3}, {0, 4}, {0,
5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 13}, {0, 14}, {0,
15}, {0, 16}, {0, 100}}, {{16, 2}, {13, 3}, {0, 4}, {0, 5}, {0,
6}, {0, 7}, {0, 8}, {0, 9}, {0, 13}, {0, 14}, {0, 15}, {0,
16}, {0, 100}}, {{8, 2}, {19, 3}, {0, 4}, {0, 5}, {0, 6}, {0,
7}, {0, 8}, {0, 9}, {0, 13}, {0, 14}, {0, 15}, {0, 16}, {0,
100}}, {{0, 2}, {15, 3}, {8, 4}, {0, 5}, {0, 6}, {0, 7}, {0,
8}, {0, 9}, {0, 13}, {0, 14}, {0, 15}, {0, 16}, {0, 100}}, {{0,
2}, {5, 3}, {16, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0,
13}, {0, 14}, {0, 15}, {0, 16}, {0, 100}}, {{0, 2}, {0, 3}, {2,
4}, {15, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 13}, {0,
14}, {0, 15}, {0, 16}, {0, 100}}, {{0, 2}, {0, 3}, {0, 4}, {5,
5}, {10, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 13}, {0, 14}, {0,
15}, {0, 16}, {0, 100}}, {{0, 2}, {0, 3}, {0, 4}, {0, 5}, {0,
6}, {8, 7}, {4, 8}, {0, 9}, {0, 13}, {0, 14}, {0, 15}, {0,
16}, {0, 100}}, {{0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0,
7}, {0, 8}, {10, 9}, {0, 13}, {0, 14}, {0, 15}, {0, 16}, {0,
100}}, {{0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0,
8}, {0, 9}, {5, 13}, {2, 14}, {0, 15}, {0, 16}, {0, 100}}, {{0,
2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0,
13}, {0, 14}, {2, 15}, {4, 16}, {0, 100}}, {{0, 2}, {0, 3}, {0,
4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 13}, {0, 14}, {0,
15}, {0, 16}, {100, 100}}};

ML = {{0.0436684, 0.0131391, 46}, {0.0559257, 0.00703646,
41}, {0.0923392, 0.00655266, 31}, {0.101887, 0.00474388,
29}, {0.107537, 0.00641074, 27}, {0.121057, 0.0077509,
23}, {0.125166, 0.00713694, 21}, {0.122422, 0.0231287,
17}, {0.119247, 0.0424084, 15}, {0.117625, 0.066116,
12}, {0.103468, 0.0763496, 10}, {0.131411, 0.121693,
7}, {0.132292, 0.133947, 6}, {0.166463, 0.17827, 0}};

Do[dissociation[i] = ML[[i, 1]]; desorption[i] = ML[[i, 2]];
ensemble2[i] = vars[[i, 1, 1]]; ensemble3[i] = vars[[i, 2, 1]];
ensemble4[i] = vars[[i, 3, 1]]; ensemble5[i] = vars[[i, 4, 1]];
ensemble6[i] = vars[[i, 5, 1]]; ensemble7[i] = vars[[i, 6, 1]];
ensemble8[i] = vars[[i, 7, 1]]; ensemble9[i] = vars[[i, 8, 1]];
ensemble13[i] = vars[[i, 9, 1]]; ensemble14[i] = vars[[i, 10, 1]];
ensemble15[i] = vars[[i, 11, 1]]; ensemble16[i] = vars[[i, 12, 1]];
ensemble100[i] = vars[[i, 13, 1]];, {i, 1, 14}];

disslist = Table[dissociation[i], {i, 1, 14}];
desorblist = Table[desorption[i], {i, 1, 14}];
en2 = Table[ensemble2[i], {i, 1, 14}];
en3 = Table[ensemble3[i], {i, 1, 14}];
en4 = Table[ensemble4[i], {i, 1, 14}];
en5 = Table[ensemble5[i], {i, 1, 14}];
en6 = Table[ensemble6[i], {i, 1, 14}];
en7 = Table[ensemble7[i], {i, 1, 14}];
en8 = Table[ensemble8[i], {i, 1, 14}];
en9 = Table[ensemble9[i], {i, 1, 14}];
en13 = Table[ensemble13[i], {i, 1, 14}];
en14 = Table[ensemble14[i], {i, 1, 14}];
en15 = Table[ensemble15[i], {i, 1, 14}];
en16 = Table[ensemble16[i], {i, 1, 14}];
en100 = Table[ensemble100[i], {i, 1, 14}];

FindFit[disslist, aa*en2*x + ab*en3*x + ac*en4*x + ad*en5*x + ae*en6*x + af*en7*x + ag*en8*x + ah*en9*x + ai*en13*x + aj*en14*x + ak*en15*x + al*en16*x + am*en100*x, {aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am}, x]

-
Please provide all code and data that is necessary to reproduce your problem. –  Yves Klett Oct 12 at 20:11
Hi Yves, I have updated the problem with the code necessary to generate the issue. –  user8307 Oct 12 at 20:29

The problem with your FindFit is that your function is not what you seem to think it is. Your function is supposed to be a single function of x

aa*en2*x + ab*en3*x + ac*en4*x + ad*en5*x + ae*en6*x + af*en7*x + ag*en8*x
+ ah*en9*x + ai*en13*x + aj*en14*x + ak*en15*x + al*en16*x + am*en100*x


but instead it is the vector

{8 aa x, 18 aa x, 24 aa x + 7 ab x, 16 aa x + 13 ab x,
8 aa x + 19 ab x, 15 ab x + 8 ac x, 5 ab x + 16 ac x,
2 ac x + 15 ad x, 5 ad x + 10 ae x, 8 af x + 4 ag x, 10 ah x,
5 ai x + 2 aj x, 2 ak x + 4 al x, 100 am x}


You will need to be clearer about what you want in order to know how to fix it.

-
Thank you for the response. I am looking to find the optimal solutions to the aa,ab's, etc. to fit the single-response. Since each point in the dataset expresses a different combination of aa,ab's, I'm having a hard time figuring out how to express this guy within a framework that is intuitive to implement in Mathematica. I would prefer to avoid using other software. –  user8307 Oct 13 at 13:07
Here's what I can't understand yet about your problem setup: you have 13 unknowns (the aa, ab etc). You have 14 pieces of data in datalist. I do not understand what you mean by "to fit the single response". –  bill s Oct 13 at 16:17