MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Extracting Parameter Values from NonlinearModelFit


numberOfDataSets = 5;
numberOfDataPointsPerDataSet = 25;

data =
  Table[Reverse[Sort[RandomVariate[
      ExponentialDistribution[RandomReal[
        {.1, .5}]], numberOfDataPointsPerDataSet]]],
   {numberOfDataSets}];

model = a Exp[-k x];

{aValues, kValues} =
  Transpose[{a, k} /.
      NonlinearModelFit[#, {model, .1 < k < 1},
        {a, k}, x]["BestFitParameters"] & /@ data];

Manipulate[
 Show[
  Plot[model /. {a -> aValues[[n]], k -> kValues[[n]]},
   {x, 1, Length[data[[n]]]}],
  ListPlot[data[[n]],
   PlotStyle -> {Red, AbsolutePointSize[4]}],
  PlotRange -> All,
  Frame -> True,
  Axes -> False],
 {n, Range[Length[data]]}]


Bob Hanlon


On Thu, Aug 30, 2012 at 4:07 AM, colang <colangmp at gmail.com> wrote:
> Hi,
>
> I'm modelling a series (>2000) of data points (5x2 lists) using NonlinearModelFit, and trying to extract the Fitted Parameter Values to separate lists using the following code:
>
> model = a Exp[-k x];
> i = 1;
> For[i = 1, i <= Length[data],
>   {nlm = NonlinearModelFit[data[[i]], {model, k<1}, {a, b}, x]["BestFitParameters"];
>    aValues = Append[aValues, nlm[[1, 2]]];
>    kValues = Append[kValues, nlm[[2, 2]]]},
>   i++
>   ];
>
> I'm able to determine the Parameters via nlm, but can't extract the parameter values.
>
> Any thoughts?
>
> Thanks in advance!
>
> C
>



  • Prev by Date: Re: How to specify x-axis in List when using ListPlot
  • Next by Date: Exiting a Nested operation...
  • Previous by thread: Extracting Parameter Values from NonlinearModelFit
  • Next by thread: What is this shorthand notation?