当前位置:  开发笔记 > 编程语言 > 正文

拟合指数衰减并拉出R中的时间常数值

如何解决《拟合指数衰减并拉出R中的时间常数值》经验,为你挑选了1个好方法。

我试图通过单指数"衰减"来拟合下面数据中的一些曲线.图形显示并不像拉出时间常数那么重要.y轴是pA,x是以秒为单位的时间.

dput(stackover_data)
structure(list(Time = c(0.09990001, 0.19990001, 0.29990001, 0.39990001, 
0.49990001, 0.59990001, 0.69990001, 0.79990001, 0.89990001, 0.99990001, 
1.09990001, 1.19990001, 1.29990001, 1.39990001, 1.49990001, 1.59990001, 
1.69990001, 1.79990001, 1.89990001, 1.99990001, 2.09990001, 2.19990001, 
2.29990001, 2.39990001, 2.49990001, 2.59990001, 2.69990001, 2.79990001, 
2.89990001, 2.99990001, 3.09990001, 3.19990001, 3.29990001, 3.39990001, 
3.49990001, 3.59990001, 3.69990001, 3.79990001, 3.89990001, 3.99990001, 
4.09990001, 4.19990001, 4.29990001, 4.39990001, 4.49990001, 4.59990001, 
4.69990001, 4.79990001, 4.89990001, 4.99990001, 5.09990001, 5.19990001, 
5.29990001, 5.39990001, 5.49990001, 5.59990001, 5.69990001, 5.79990001, 
5.89990001, 5.99990001, 6.09990001, 6.19990001, 6.29990001, 6.39990001, 
6.49990001, 6.59990001, 6.69990001, 6.79990001, 6.89990001, 6.99990001, 
7.09990001, 7.19990001, 7.29990001, 7.39990001, 7.49990001, 7.59990001, 
7.69990001, 7.79990001, 7.89990001, 7.99990001, 8.09990001, 8.19990001, 
8.29990001, 8.39990001, 8.49990001, 8.59990001, 8.69990001, 8.79990001, 
8.89990001, 8.99990001, 9.09990001, 9.19990001, 9.29990001, 9.39990001, 
9.49990001, 9.59990001, 9.69990001, 9.79990001, 9.89990001, 9.99990001, 
10.09990001, 10.19990001, 10.29990001, 10.39990001, 10.49990001, 
10.59990001, 10.69990001, 10.79990001, 10.89990001, 10.99990001, 
11.09990001, 11.19990001, 11.29990001, 11.39990001, 11.49990001, 
11.59990001, 11.69990001, 11.79990001, 11.89990001, 11.99990001, 
12.09990001, 12.19990001, 12.29990001, 12.39990001, 12.49990001, 
12.59990001, 12.69990001, 12.79990001, 12.89990001, 12.99990001, 
13.09990001, 13.19990001, 13.29990001, 13.39990001, 13.49990001, 
13.59990001, 13.69990001, 13.79990001, 13.89990001, 13.99990001, 
14.09990001, 14.19990001, 14.29990001, 14.39990001, 14.49990001, 
14.59990001, 14.69990001, 14.79990001, 14.89990001, 14.99990001, 
15.09990001, 15.19990001, 15.29990001, 15.39990001, 15.49990001, 
15.59990001, 15.69990001, 15.79990001, 15.89990001, 15.99990001, 
16.09990001, 16.19990001, 16.29990001, 16.39990001, 16.49990001, 
16.59990001, 16.69990001, 16.79990001, 16.89990001, 16.99990001, 
17.09990001, 17.19990001, 17.29990001, 17.39990001, 17.49990001, 
17.59990001, 17.69990001, 17.79990001, 17.89990001, 17.99990001, 
18.09990001, 18.19990001, 18.29990001, 18.39990001, 18.49990001, 
18.59990001, 18.69990001, 18.79990001, 18.89990001, 18.99990001, 
19.09990001, 19.19990001, 19.29990001, 19.39990001, 19.49990001, 
19.59990001, 19.69990001, 19.79990001, 19.89990001, 19.99990001
), `Trace 1` = c(-3.08656892325052, 9.36821982641837, 8.13806079083122, 
10.7039590839898, 7.25670468903547, 4.31122291688919, 1.77905971163193, 
-6.27606834721828, -8.65955381985049, -10.1445673910916, -10.6649772153892, 
-6.52301948183154, -11.9757817854835, -0.976254254762154, 0.237467076202677, 
-11.8114896779541, -11.0022757370468, -16.1845427042923, 2.70565927469852, 
-18.9048281652216, -22.153682283437, -4363.32044948884, -3470.59111611883, 
-2877.51064886248, -2253.51505229908, -1876.62974792002, -1541.14546478629, 
-1288.26617158403, -1232.52313999354, -1042.98549163259, -938.795146277054, 
-810.913567086442, -736.390770574588, -682.044521632168, -638.575324886466, 
-596.587948389699, -629.282103146111, -569.200610245336, -587.387817942122, 
-521.939307772762, -533.776693538631, -514.782451411908, -445.949395199026, 
-451.026618716539, -461.669600651513, -442.372477296489, -426.132547857502, 
-452.471101919398, -449.377497412324, -436.817659066873, -487.464805660851, 
-442.915455035179, -458.666741489705, -454.990437793055, -455.173154690614, 
-426.885702219019, -456.985443835707, -408.869318611773, -442.418742303429, 
-407.42593099033, -414.538253423006, -316.036755461507, -248.395118743017, 
-198.708015370115, -183.88480278352, -160.041754268138, -139.020785864805, 
-123.701641615743, -137.253323547789, -124.240619047461, -121.512859107349, 
-113.719386521321, -102.98429740535, -118.721098087137, -109.789471870234, 
-122.145399997255, -109.542467905009, -96.6725326170008, -108.16233877188, 
-94.1092968366083, -88.0987495250118, -89.2245425850472, -96.3495439993499, 
-110.340434956898, -98.8777265479938, -88.0674013452629, -102.755317774957, 
-91.0752842494157, -107.959830375198, -78.8424385901398, -93.7743443479161, 
-98.3591889757604, -72.3214090579355, -85.6296201608712, -112.596656084088, 
-115.518068650615, -110.973655632476, -78.8021307215932, -85.6443070182152, 
-93.1744356389988, -100.483987323044, -87.6672104421484, -83.6481077757535, 
-82.1465876740715, -86.7838666454595, -75.9066755520263, -86.6416980998645, 
-88.9405806921788, -74.0592581080291, -86.3433338300531, -93.5114839187431, 
-91.1875849041866, -82.7018083540351, -102.859075734953, -82.1494206590809, 
-79.2197323780198, -78.1558787387238, -86.2649418863144, -93.5271994290692, 
-84.6678528566242, -71.4828270654073, -69.5618263581887, -67.2920558863641, 
-58.1490330439793, -59.8163238740351, -73.6957797622946, -61.7673947702343, 
-63.6492255747164, -64.043638367468, -73.8301991524909, -69.3055992018769, 
-65.9342860783478, -74.9891521715357, -74.5779808619617, -69.9029875902787, 
-69.746935396023, -71.35455530782, -73.5279471991205, -77.8000626250279, 
-74.6065254864801, -64.0834786591292, -45.1346212136811, -43.1615385011179, 
-42.554841323715, -50.276566542849, -56.1940469314277, -49.6368473019083, 
-53.9842269565738, -54.1480156577708, -48.2160751112714, -43.2902743874793, 
-46.4358385791469, -58.4459814967147, -49.0443619038303, -56.8007684056415, 
-56.3345802020277, -40.1704617527471, -38.2624410086947, -39.9339279963857, 
-27.7637250414188, -40.8686520798649, -30.9246406597275, -32.70021580322, 
-28.7536071219405, -32.4403271637661, -30.3389870650563, -23.2866770834185, 
-40.349370835336, -39.7478049410975, -38.4648592612063, -37.4191914226093, 
-52.1259539643142, -38.0993644763616, -37.5493511061199, -25.0794144286873, 
-32.6165749053184, -17.2616237291667, -32.1515419380766, -27.0814392288745, 
-26.2440551871993, -17.5882979851251, -19.852012057918, -22.1408312947152, 
-21.3395092026716, -28.0789344732281, -19.6443281019371, -26.6585778398899, 
-24.2994817465722, -27.847437388783, -22.0565059455712, -24.8747905836351, 
-30.7544250721296, -29.9924061105416, -22.5728855329732, -24.9767037068316, 
-18.8208568928653, -10.7306087216159, -16.4281210876173, -19.3057174287183, 
-15.9745523586581), `Trace 2` = c(5.94927992143286, 1.42121402161905, 
6.78788136514507, 3.33970424403748, -3.73956433922802, -7.3097330836793, 
-9.18242380095097, 3.29952017048882, 5.17208246028, 1.53238537592179, 
6.90832098860733, 3.16748380079213, 5.49988319742749, 3.86758484926656, 
11.981378748128, -0.208159377585758, -7.2781503569274, 1.71389537416221, 
-4.77614396689646, -0.561115871778583, -14.5385068323377, -4944.63006397872, 
-3891.23141079918, -3065.66300899921, -2527.61853791531, -2060.05223709386, 
-1763.27814995793, -1451.77884853301, -1368.42409410389, -1115.3385743493, 
-990.942590410893, -852.951182088994, -920.516421149141, -860.486324532349, 
-751.257935697359, -768.757880984424, -713.935725464811, -715.011716140783, 
-616.355633698422, -672.133827760044, -629.418857335266, -607.342562427532, 
-599.657392949772, -553.265193759536, -572.878306401819, -583.153736972572, 
-589.661926862833, -527.552306430313, -553.672277977987, -539.906254466276, 
-525.491319968336, -564.876755897633, -505.363603776286, -575.649358123809, 
-497.897048596953, -544.360501913781, -483.501835830955, -533.085516954168, 
-478.007776808595, -453.333986756674, -447.125338584774, -380.268661132557, 
-253.127091546528, -227.877427383931, -191.488369613846, -166.799480062655, 
-171.446527550207, -156.775073739292, -148.804014388301, -151.79670303645, 
-152.599645619669, -113.40778617347, -133.161498039771, -129.929086626311, 
-156.827022418459, -146.618934465797, -94.20997521855, -124.514491421933, 
-89.8538131075507, -91.6500841191965, -113.887119052802, -109.971138752404, 
-122.532101557384, -107.714865018275, -120.258046104427, -133.296582343699, 
-111.726093380577, -121.533575165211, -93.2177144160483, -97.3820468959891, 
-111.294540122284, -100.913019601926, -90.8456358331201, -94.143801546019, 
-89.9179990101121, -79.3197988311624, -87.0020882554621, -103.315348613102, 
-92.6091563297179, -87.3900461813473, -106.61173718685, -117.18534688083, 
-106.417237368758, -114.977458547258, -101.759575332149, -93.2156781534656, 
-79.4452885332048, -83.8035016923155, -85.7770898942133, -80.151862850598, 
-72.4787832080729, -75.4887322569144, -70.8074563945233, -76.9714115362765, 
-74.2305756099668, -72.7994824773122, -86.4890002605112, -68.5241155035978, 
-76.723559709657, -60.5721619300473, -64.185161607482, -81.0777473166996, 
-59.7023719535658, -48.0615168793405, -63.7668096308392, -69.0412888697281, 
-70.9894443873153, -48.8366672284658, -43.1003899300401, -50.5591327356918, 
-65.184353265464, -52.2850955061746, -66.0074402595226, -69.3081002474696, 
-69.3876079446205, -53.0919105504865, -69.3289906081927, -63.5198462609014, 
-70.9316181916525, -68.753726760587, -57.1360889764902, -45.7297495037924, 
-45.0225501894778, -45.7487568762369, -46.486850874694, -46.7437348684622, 
-41.1396209831975, -38.5056250833188, -49.8076229939374, -46.9868446480308, 
-38.4639795698766, -40.8336417843587, -49.9810721301961, -58.7820616810459, 
-51.4348042554539, -56.9132093579117, -53.527642322397, -49.7620292214747, 
-54.6821412367706, -66.7962460110546, -52.0791798888695, -43.3022792658504, 
-47.5584813904168, -36.3352478868053, -39.8699383685185, -43.9973042247199, 
-49.3191665577514, -42.0818922168797, -37.7538461067954, -29.1591142899914, 
-31.6815992654018, -35.3664789321372, -29.6435427630652, -45.5528322348158, 
-37.0568327299924, -29.6739001502498, -37.0952936191428, -44.1786405275305, 
-50.929131558954, -31.7842698176079, -31.4300485665082, -33.960404707688, 
-34.0566040705914, -41.2299273666286, -30.1094672132779, -28.6802701495622, 
-37.1973277887207, -31.7114680610898, -32.5450840790921, -28.5823680785893, 
-27.5268500574853, -15.2389866754792, -19.2079199191329, -28.9156878395334, 
-16.5863741697772, -31.6638747515138, -34.679018047114, -32.6358481677933, 
-26.3463300811612, -18.542719903123), `Trace 3` = c(4.74984904312473, 
-6.83237755613888, -4.15774846489683, 0.0116753456567835, 4.3974208810568, 
8.56175743226069, -0.271281722577697, -10.7982854290066, -18.31704442037, 
-15.7577103721081, -20.5775487342614, -17.7307614062074, -14.2844531791322, 
-5.43267691733291, 2.52755064598145, -0.79977817636393, -8.07074631773528, 
-14.6631228094247, -9.70657043283029, -11.4521183354252, -10.8401698276907, 
-5495.45466682125, -4324.53856178012, -3525.03574657791, -2774.37269062517, 
-2175.8494069729, -1790.54797875842, -1574.71991002551, -1342.90235937345, 
-1212.59715782746, -1042.56659527622, -1006.18885759924, -962.27473179716, 
-870.459562514915, -847.89784200018, -770.205392585522, -709.279500982242, 
-740.484104629636, -739.054108223511, -645.039948927494, -712.347389757369, 
-609.734365947307, -613.120930696929, -630.805982834916, -581.828460576409, 
-608.843958294059, -602.432567890874, -547.023947351376, -571.475614300591, 
-561.707380041648, -535.094375334464, -578.783728464712, -535.290908514374, 
-489.922390143035, -522.824368605682, -520.322259788742, -556.271028784585, 
-536.474251127913, -546.811709881227, -541.304029428261, -563.702125503968, 
-460.326259578172, -348.718859066443, -261.740363110507, -244.084411205067, 
-182.533320181224, -205.356578064485, -157.759947570376, -162.214202634405, 
-180.011654146528, -176.904445787135, -167.116794266109, -163.416234638164, 
-155.821745831568, -134.760994564946, -131.702791057298, -138.598664148971, 
-139.818370538306, -134.700400696581, -137.275258643317, -119.921721377143, 
-118.187525264885, -118.490007264421, -130.391338033262, -138.05114734155, 
-127.505366899025, -132.636233878671, -123.490111075107, -113.42942794286, 
-122.40925776411, -114.48254277334, -122.78054774327, -90.9528981496313, 
-96.9508488566491, -107.842237007564, -91.0521871208113, -91.0347011279681, 
-85.7054147126896, -89.7363815316723, -77.6588521980595, -76.6733051688234, 
-85.821987540449, -90.3216600489126, -66.1137192454051, -77.7157754909198, 
-89.8637060331546, -80.9149315468257, -71.7434481475478, -97.6600776026528, 
-103.405900069071, -83.7502802699966, -77.4600968679799, -77.8705250264031, 
-78.9012879762878, -87.4698127883497, -92.9587198547098, -96.1222986385502, 
-91.1990314226718, -83.8744116889207, -61.7720026226848, -83.6616594930646, 
-91.3899042204887, -74.2552104995002, -94.3117384183545, -81.130091800586, 
-87.6638514042855, -79.061763018934, -78.7472359255489, -72.9642062301352, 
-83.5759889935287, -74.066505526926, -62.6191749912397, -75.7150349466975, 
-71.8704211546101, -68.4798935028027, -77.0470926055507, -76.6024078920054, 
-66.5760393943856, -77.8848130194484, -77.5151449198185, -65.5482413040489, 
-47.6087884294611, -35.6865291924552, -47.9648700291328, -62.8176093048552, 
-48.969044800301, -46.853228499419, -52.562083189922, -58.7677963803543, 
-63.6615259259388, -51.7351340481719, -54.5967510836755, -54.1294816023731, 
-47.7621427567758, -40.9244974392914, -50.5286026229961, -45.9961132210891, 
-43.143208905187, -43.8395623054062, -49.3326618452772, -48.308625153823, 
-44.9833219970479, -32.4206723427767, -45.6628898472981, -41.4748918817457, 
-43.6438737242104, -42.9844450147366, -30.3729810016378, -44.9519080631137, 
-45.8241111308495, -40.4766896430523, -40.3007872752484, -46.4770136239361, 
-49.3759491415156, -46.0844075639024, -34.3090862431636, -26.6047381016158, 
-28.9119815377167, -33.1619464253006, -37.3813739690468, -46.5001186141503, 
-54.5235621985407, -44.5233400090119, -55.2272273265567, -48.088333647706, 
-55.3522589332341, -52.8146474401922, -60.1877313269088, -48.2512741329643, 
-34.8540879147507, -55.2019332852645, -50.8488894007021, -49.9600753927381, 
-48.5654335180739, -47.8918651630979, -45.1405419376454, -40.8504490169926, 
-38.5815843253789, -45.001677748311, -43.0547862406721)), .Names = c("Time", 
"Trace 1", "Trace 2", "Trace 3"), row.names = c(1000L, 2000L, 
3000L, 4000L, 5000L, 6000L, 7000L, 8000L, 9000L, 10000L, 11000L, 
12000L, 13000L, 14000L, 15000L, 16000L, 17000L, 18000L, 19000L, 
20000L, 21000L, 22000L, 23000L, 24000L, 25000L, 26000L, 27000L, 
28000L, 29000L, 30000L, 31000L, 32000L, 33000L, 34000L, 35000L, 
36000L, 37000L, 38000L, 39000L, 40000L, 41000L, 42000L, 43000L, 
44000L, 45000L, 46000L, 47000L, 48000L, 49000L, 50000L, 51000L, 
52000L, 53000L, 54000L, 55000L, 56000L, 57000L, 58000L, 59000L, 
60000L, 61000L, 62000L, 63000L, 64000L, 65000L, 66000L, 67000L, 
68000L, 69000L, 70000L, 71000L, 72000L, 73000L, 74000L, 75000L, 
76000L, 77000L, 78000L, 79000L, 80000L, 81000L, 82000L, 83000L, 
84000L, 85000L, 86000L, 87000L, 88000L, 89000L, 90000L, 91000L, 
92000L, 93000L, 94000L, 95000L, 96000L, 97000L, 98000L, 99000L, 
100000L, 101000L, 102000L, 103000L, 104000L, 105000L, 106000L, 
107000L, 108000L, 109000L, 110000L, 111000L, 112000L, 113000L, 
114000L, 115000L, 116000L, 117000L, 118000L, 119000L, 120000L, 
121000L, 122000L, 123000L, 124000L, 125000L, 126000L, 127000L, 
128000L, 129000L, 130000L, 131000L, 132000L, 133000L, 134000L, 
135000L, 136000L, 137000L, 138000L, 139000L, 140000L, 141000L, 
142000L, 143000L, 144000L, 145000L, 146000L, 147000L, 148000L, 
149000L, 150000L, 151000L, 152000L, 153000L, 154000L, 155000L, 
156000L, 157000L, 158000L, 159000L, 160000L, 161000L, 162000L, 
163000L, 164000L, 165000L, 166000L, 167000L, 168000L, 169000L, 
170000L, 171000L, 172000L, 173000L, 174000L, 175000L, 176000L, 
177000L, 178000L, 179000L, 180000L, 181000L, 182000L, 183000L, 
184000L, 185000L, 186000L, 187000L, 188000L, 189000L, 190000L, 
191000L, 192000L, 193000L, 194000L, 195000L, 196000L, 197000L, 
198000L, 199000L, 200000L), class = "data.frame")

我已经尝试过做lm(y~x),但它似乎没有得到正确的答案(在Igor中验证了正确的答案),显然这是因为它是线性模型而不是指数.欢迎任何所有建议.我在努力奋斗!

谢谢大家!



1> Roland..:
names(DF) <- make.names(names(DF))
plot(Trace.1 ~ Time, data = DF)
#remove the initial values that clearly don't follow the model
DF1 <- DF[-seq_len(which((diff(DF$Trace.1) < -1e3))),]

plot(Trace.1 ~ Time, data = DF1)
fit <- nls(Trace.1 ~ SSasymp(Time, Asym, R0, lrc), data = DF1)
summary(fit)
coef(fit)
help("SSasymp") #for an explanation of the parameters
lines(DF1$Time, predict(fit))

结果情节

推荐阅读
kikokikolove
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有