2
$\begingroup$
Needs["ErrorBarPlots`"]
Temp1 = {77.0103,77.0103,77.013,77.0126,77.0019,77.0074,77.0028,77.0144,77.0079,77.0135,77.0209,77.0121,77.0186,77.0042,77.0047,77.0112,77.013,77.0037,77.0181,77.0093,77.0107,77.0293,77.0177,77.0107,77.0242,77.0149,77.0144,77.0223,77.0019,77.0009,77,77.0093,77.0042,77.0051,77,77.0061,77.0051,77.0028,77.0042,77,77,77,77,77,77.0051,77.0028,77.0088,77.0009,77.0019,77.0009,77.0009,77.0061,77.0009,77,77.0028,77.0051,77.0028,77,77,77.0051,77.0009,77.0042,77.0019,77.0009,77.0112,77.0051,77.0172,77.0037,77.0098,77.0019,77.0019,77.0093,77.0093,77.0037,77.0028,77.0079,77.0116,77.007,77.0084,77.0033,77.0056,77.0121,77.0139,77.0084,77.0037,77.0112,77.0093,77.0037,77.0144,77.0089,77,77.0089,77.0116,77.0074,77.0065,77.0326,77.0135,77.0112,77.0191,77.014,77.0214,77.0149,77.0396,77.021,77.0386,77.0391,77.0432,77.0679,77.0661,77.0712,77.0976,77.1005,77.1729,77.2406,77.2782,77.3474,77.3538,77.3905,77.378,77.5889,77.6812,77.8253,77.9407,78.3124,78.9056,79.6563,80.3167,80.9423,81.2899,81.8344,82.1727,82.4206,82.7636,83.1667,83.5213,83.8202,84.1422,84.5037,84.9069,85.1502,85.5487,85.8847,86.2624,86.6911,87.0015,87.4325,87.7059,88.1485,88.5077,88.8714,89.0452,89.4206,89.6778,89.986,90.2107,90.4378,90.7159,91.0194,91.2627,91.499,91.8003,92.1733,92.3193,92.6483,92.9565,93.2485,93.4941,93.7907,94.0177,94.4371,94.6387,94.8982,95.1856,95.4149,95.7231,96.0568,96.2236,96.4739,96.7983,96.9257,97.2594,97.4308,97.7042,97.8942,98.2488,98.4295,98.6473,98.8489,99.1779,99.3702,99.4606,99.8823,100.061,100.218,100.388,100.566,100.791,100.953,101.122,101.358,101.574,101.718,101.866,102.019,102.313,102.484,102.612,102.749,103.024,103.145,103.349,103.434,103.543,103.747,103.919,104.13,104.269,104.41,104.551,104.746,104.915,105.031,105.172,105.402,105.55,105.661,105.874,106.12,106.166,106.442,106.572,106.85,107.045,107.248,107.429,107.621,107.798,107.971,108.175,108.449,108.632,108.768,109.03,109.25,109.306,109.6,109.876,109.976,110.159,110.465,110.599,110.736,111.03,111.232,111.394,111.602,111.704,111.961,112.195,112.515,112.698,112.921,113.101,113.308,113.502,113.706,113.961,114.137,114.455,114.663,114.923,115.036,115.46,115.646,115.887,116.116,116.257,116.466,116.867,117.02,117.226,117.497,117.699,118.021,118.187,118.445,118.709,118.971,119.297,119.501,119.724,119.969,120.284,120.553,120.801,121.135,121.318,121.584,121.807,122.15,122.398,122.56,122.884,123.146,123.443,123.677,123.973,124.175,124.481,124.68,125.021,125.262,125.51,125.785,126.029,126.258,126.538,126.798,127.118,127.273,127.63,127.894,128.084,128.369,128.631,128.876,129.133,129.381,129.581,129.984,130.116,130.352,130.644,130.908,131.175,131.513,131.68,131.981,132.192,132.507,132.662,133.042,133.249,133.462,133.698,134.018,134.176,134.5,134.787,135.024,135.26,135.427,135.621,135.916,136.252,136.474,136.708,136.937,137.13,137.443,137.642,137.885,138.219,138.432,138.666,138.868,139.092,139.403,139.706,139.855,140.114,140.355,140.619,140.731,141.018,141.319,141.416,141.741,141.973,142.23,142.392,142.7,142.913,143.113,143.323,143.588,143.877,143.995,144.297,144.538,144.795,145.02,145.237,145.43,145.638,145.956,146.083,146.368,146.535,146.806,146.994,147.207,147.508,147.705,147.83,148.062,148.273,148.479,148.708,148.979}
Res1 = {-0.0590596,-0.058333,-0.0583262,-0.0563661,-0.0560809,-0.0574174,-0.0553823,-0.0567013,-0.0576334,-0.0553167,-0.0584771,-0.055738,-0.0569952,-0.0570642,-0.0567752,-0.0574316,-0.0554623,-0.0571769,-0.0569079,-0.0559731,-0.0562543,-0.0554004,-0.0563061,-0.0559102,-0.0568603,-0.0570075,-0.0558722,-0.0562818,-0.0552777,-0.0565093,-0.0561396,-0.0538426,-0.0566758,-0.0554335,-0.0570615,-0.0563059,-0.0555249,-0.0599199,-0.0646164,-0.0573725,-0.060857,-0.0595112,-0.0592705,-0.0586673,-0.0587583,-0.0588538,-0.0586122,-0.0584082,-0.0554043,-0.0569088,-0.0576218,-0.0574864,-0.0575047,-0.0574274,-0.0562758,-0.0585806,-0.0582723,-0.0580809,-0.0576693,-0.0569778,-0.0571192,-0.0574781,-0.0585506,-0.0569043,-0.0556723,-0.0581038,-0.0587182,-0.0565278,-0.0578766,-0.057791,-0.0578173,-0.0574738,-0.0591702,-0.0582145,-0.0565927,-0.0586872,-0.0588341,-0.0576225,-0.0576271,-0.0586373,-0.0597999,-0.058851,-0.0590652,-0.0572486,-0.0575935,-0.0581305,-0.0595872,-0.0582025,-0.057715,-0.0590527,-0.0584994,-0.0568381,-0.0583074,-0.0573008,-0.0589709,-0.057761,-0.0588189,-0.0566297,-0.0575639,-0.0595923,-0.057369,-0.0584189,-0.0571668,-0.0571397,-0.0574983,-0.0573261,-0.0569206,-0.0578125,-0.0584623,-0.0580376,-0.0578935,-0.0554843,-0.0570873,-0.0574813,-0.0544725,-0.0565674,-0.0544262,-0.0561695,-0.0555865,-0.0563076,-0.0585445,-0.060037,-0.0639273,-0.0650561,-0.0650385,-0.0665552,-0.0670298,-0.0678204,-0.0659821,-0.068091,-0.0679775,-0.0677982,-0.0674846,-0.068731,-0.0676987,-0.0657472,-0.0660872,-0.0672028,-0.0675261,-0.0683322,-0.0678529,-0.0674918,-0.068648,-0.0663066,-0.0669376,-0.0659059,-0.0664007,-0.0654311,-0.0666747,-0.0660021,-0.0662943,-0.0658858,-0.0649266,-0.0654067,-0.0640798,-0.0646458,-0.0656401,-0.0641255,-0.0631631,-0.0630764,-0.0613627,-0.0605531,-0.0574182,-0.05403,-0.0525572,-0.0482228,-0.0426708,-0.0392188,-0.0338243,-0.0257601,-0.0202828,-0.0112886,-0.00449296,0.00627436,0.0143099,0.0245699,0.0350852,0.0436044,0.0545804,0.064472,0.0752835,0.0846966,0.0944783,0.104104,0.111369,0.119883,0.130286,0.137791,0.144924,0.153071,0.157923,0.164469,0.173013,0.175786,0.181882,0.184929,0.190451,0.193461,0.197885,0.199615,0.202097,0.206852,0.208203,0.211655,0.214081,0.21788,0.222233,0.224022,0.2259,0.230576,0.232264,0.237488,0.239139,0.244794,0.246386,0.252499,0.258106,0.259725,0.264801,0.270361,0.27617,0.280877,0.28867,0.294406,0.30177,0.309902,0.317274,0.32856,0.339514,0.348883,0.363491,0.37772,0.396421,0.413767,0.435182,0.460811,0.484264,0.51087,0.538462,0.5741,0.60982,0.651437,0.692714,0.740465,0.789506,0.842263,0.898283,0.952573,1.01028,1.07144,1.13175,1.19703,1.25841,1.32268,1.38878,1.45741,1.52932,1.60378,1.68175,1.75951,1.83484,1.91717,1.9956,2.08458,2.16896,2.25919,2.35697,2.4641,2.5845,2.71767,2.86148,3.02132,3.19861,3.39711,3.61016,3.84656,4.09809,4.3701,4.66639,4.98048,5.31941,5.68344,6.07113,6.47862,6.90094,7.33218,7.7666,8.19072,8.61637,9.01023,9.41766,9.58067,9.57932,9.5792,9.57889,9.57463,9.57566,9.57388,9.57084,9.56594,9.56538,9.56222,9.55789,9.55674,9.55438,9.5513,9.54981,9.54499,9.54414,9.54549,9.54273,9.54059,9.53728,9.53232,9.52931,9.52757,9.52771,9.52737,9.52246,9.52007,9.517,9.5131,9.51187,9.50843,9.50581,9.50301,9.50278,9.50087,9.50012,9.49716,9.49523,9.49465,9.49491,9.49189,9.49149,9.48939,9.48743,9.48601,9.48192,9.48013,9.4797,9.47796,9.47547,9.4747,9.47218,9.46624,9.46334,9.46233,9.46106,9.45809,9.45669,9.45578,9.45581,9.45511,9.45277,9.4517,9.44984,9.44707,9.44935,9.44826,9.44705,9.44455,9.44178,9.43863,9.43559,9.43578,9.43225,9.43171,9.43146,9.4285,9.42912,9.42917,9.42661,9.42357,9.42201,9.4215,9.42213,9.42095,9.42278,9.42177,9.42155,9.41868,9.41882,9.4168,9.4145,9.4137,9.41289,9.41184,9.4083,9.40631,9.40605,9.40308,9.40391,9.40255,9.39902,9.39751,9.39545,9.39422,9.39438,9.39327,9.39281,9.38857,9.38815,9.38639,9.38436,9.38379,9.38151,9.38153,9.37973,9.37767}
lm = LinearModelFit[Transpose[{Temp1, Res1}], x, x]
Transpose[{Temp1, Res1}]

How could I use LinearModelFit[data, x, x] to find a fit that maximizes the slope of the fit line?

Here is a plot of the data that I am trying to fit. I want to find the best fit line for the linear portion of the plot.

 plot

$\endgroup$
  • 4
    $\begingroup$ To what end do you wish to maximize the slope? Often in fitting, you are in fact minimizing something… $\endgroup$ – J. M. will be back soon Jun 21 '15 at 22:49
  • $\begingroup$ I restated what I am trying to achieve. I want to maximize the slope of the fit in that linear region of the plot $\endgroup$ – Daniel Schulze Jun 21 '15 at 23:32
  • $\begingroup$ A vertical line would maximize the slope, but what good would that do? There's probably some constraint that you're not mentioning here. Like a line that still fits in the error bars within a certain region or so. $\endgroup$ – Sjoerd C. de Vries Jun 22 '15 at 9:50
  • $\begingroup$ yes sorry. that is the constraint. A line that maximizes the slope, but also still fits within the error bars of the vertical region. $\endgroup$ – Daniel Schulze Jun 26 '15 at 8:08
4
$\begingroup$

The data does not look smoothly sigmoid. In particularly, there is an abrupt termination of the rise and the maximum slope appears to occur at end-point. Fitting the rising curve as an exponential:

data = Transpose[{Temp1, Res1}];
cut = data[[200 ;; 292]]
lmf[u_] := 
 Exp[Normal@LinearModelFit[{#1, Log@#2} & @@@ cut, x, x]] /. x -> u
slope[u_] := D[lmf[x], x] /. x -> u

The slopes are shown:

Manipulate[
 Show[ListPlot[data], 
  Plot[Evaluate@lmf[x], {x, data[[200, 1]], data[[292, 1]]}, 
   PlotStyle -> Red], 
  Graphics[{Black, Thick, , 
    Line[{{p, lmf[p]} - 10 {1, slope[p]}, {p, lmf[p]} + 
       10 {1, slope[p]}}]}], 
  Epilog -> {Red, PointSize[0.03], Point[{p, lmf[p]}], Black, 
    Text[slope[p], {p, lmf[p]} + {10, 0}]}], {p, data[[200, 1]], 
  data[[292, 1]]}]

enter image description here

$\endgroup$

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