Let's say I have written a function which performs convolution and returns value calculated for the time, t.
CalculateConvolution[length_, aifMatrix_, Ktrans_, Kep_, dt_, t_] :=
aifMatrix[[(Round[t/dt] + 1)]].CreateKernel[Ktrans, Kep, dt, length];
aifMatrix
- is a matrix;
CreateKernel[Ktrans, Kep, dt, length]
- is a function that returns a vector;
CreateKernel[Ktrans_, Kep_, dt_, length_] := Module[{kernel = ConstantArray[0, length]},
Do[kernel[[i]] = Ktrans*Exp[-Kep*dt*i], {i, 1, length, 1}]; kernel];
After that I use the next function to perform nonlinear least squares fitting:
NonlinearModelFit[TheoreticalTissueData, CalculateConvolutionOptimized[
Length[fiitedAIF], fittedConvMatrix, Ktrans, Ktrans/(Kep*60), 0.5, t], {Ktrans, Kep}, t]
where the TheoreticalTissueData
is the data which I need to fit.
So, when I run this code I get the fitted data in the next form:
{value1, value2, ..., valuen}
which corresponds to the fitted curve, however I can't extract fitted parameters: Ktrans
,Kep
.
I tried to use ["ParameterTable"]
, however I didn't receive any results (because it worked for several minutes without any results, so I aborted calculations).
What is the easiest way to get the fit parameters for this case?
NonlinearModelFit
, the result should be aFittedModel
object, not something in the form of{value1, value2, ...}
. Can you clarify what you get? Once you do have aFittedModel
objects (let's say stored in the variablefm
), evaluatingfm["ParameterTable"]
should probably be quick. If it's not, can you give a short but complete example that reproduces the problem? If you need to retrieve the parameter values for programmatic use, try"BestFitParameters"
instead of"ParameterTable"
(which is for visual inspection). $\endgroup$