Re: Asking NonlinearRegression
- To: mathgroup at smc.vnet.net
- Subject: [mg88763] Re: [mg88733] Asking NonlinearRegression
- From: Darren Glosemeyer <darreng at wolfram.com>
- Date: Fri, 16 May 2008 05:30:00 -0400 (EDT)
- References: <200805151050.GAA21764@smc.vnet.net>
Navri Navri Bintang wrote:
> Hi,
>
> I have a problem with nonlinear regression in Mathematica. I want to fit my data (below) to this following equation:
>
> y = Exp[(1-Exp[a*(1-Exp[-b*x])])*(Exp[-b*x])/(1-Exp[-b*x])]
>
> and I would like to find a and b values and also determined r-squared value.
>
> I try to use NonlinearRegression/NonlinearFit code, but its not working, I hope someone could help me
>
> Thanks a lot
>
> DATA:
> x y
> 1 0.00
> 2 0.00
> 3 0.00
> 4 0.00
> 5 0.00
> 6 0.00
> 7 0.00
> 8 0.00
> 9 0.00
> 10 0.00
> 11 0.00
> 12 0.00
> 13 0.00
> 14 0.00
> 15 0.00
> 16 0.00
> 17 0.00
> 18 0.00
> 19 0.00
> 20 0.00
> 21 0.00
> 22 0.00
> 23 0.00
> 24 0.00
> 25 0.00
> 26 0.00
> 27 0.00
> 28 0.00
> 29 0.00
> 30 0.00
> 31 0.00
> 32 0.00
> 33 0.00
> 34 0.00
> 35 0.00
> 36 0.00
> 37 0.00
> 38 0.00
> 39 0.00
> 40 0.00
> 42 0.00
> 44 0.00
> 46 0.00
> 48 0.00
> 50 0.00
> 52 0.04
> 54 0.06
> 56 0.08
> 58 0.09
> 60 0.16
> 65 0.24
> 70 0.32
> 75 0.43
> 80 0.49
> 85 0.58
> 90 0.80
> 95 0.91
> 100 1.00
> 105 1
>
>
> Rgds,
> Navri
>
>
>
>
>
When something is not working, it helps to know what not working means
(for instance, a function may not be evaluating or there may be
something undesirable about the result). A couple of possibilities in
this case are that the package wasn't loaded or that non-default
starting values are needed for the parameters.
Regardless of whether or not part of the problem was package loading,
this example will need non-default starting values. By default, 1 is
used as the starting value for each parameter if no value is specified
and this is not a good starting point for the parameters in this
example. Looking at 3D plots as a function of a and b for a couple of
the larger x values, it looked like 5 would be reasonable for a and .1
would be reasonable for b and with the sharp nature of the curve it
would help to give two starting values so the method didn't take too big
of an initial step. Doing so, it worked fine.
In[1]:= << NonlinearRegression`
In[2]:= data = Import["data.tsv"]
Out[2]= {{1, 0.}, {2, 0.}, {3, 0.}, {4, 0.}, {5, 0.}, {6, 0.}, {7, 0.},
{8, 0.}, {9, 0.},
> {10, 0.}, {11, 0.}, {12, 0.}, {13, 0.}, {14, 0.}, {15, 0.}, {16,
0.}, {17, 0.},
> {18, 0.}, {19, 0.}, {20, 0.}, {21, 0.}, {22, 0.}, {23, 0.}, {24,
0.}, {25, 0.},
> {26, 0.}, {27, 0.}, {28, 0.}, {29, 0.}, {30, 0.}, {31, 0.}, {32,
0.}, {33, 0.},
> {34, 0.}, {35, 0.}, {36, 0.}, {37, 0.}, {38, 0.}, {39, 0.}, {40,
0.}, {42, 0.},
> {44, 0.}, {46, 0.}, {48, 0.}, {50, 0.}, {52, 0.04}, {54, 0.06},
{56, 0.08},
> {58, 0.09}, {60, 0.16}, {65, 0.24}, {70, 0.32}, {75, 0.43}, {80,
0.49}, {85, 0.58},
> {90, 0.8}, {95, 0.91}, {100, 1.}, {105, 1}}
In[3]:= NonlinearRegress[data,
Exp[(1 - Exp[a*(1 - Exp[-b*x])])*(Exp[-b*x])/(1 - Exp[-b*x])],
{{a,
5, 5.1}, {b, .1, .11}}, x]
Out[3]= {BestFitParameters -> {a -> 5.2052, b -> 0.0724853},
> ParameterCITable -> Estimate Asymptotic SE
CI ,
a 5.2052 0.209949 {4.78478, 5.62561}
b 0.0724853 0.00290763 {0.0666629,
0.0783077}
> EstimatedVariance -> 0.000964242,
> ANOVATable -> DF SumOfSq MeanSq ,
Model 2 4.37984 2.18992
Error 57 0.0549618 0.000964242
Uncorrected Total 59 4.4348
Corrected Total 58 3.78327
> AsymptoticCorrelationMatrix -> 1. 0.985653,
0.985653 1.
> FitCurvatureTable -> Curvature}
Max Intrinsic 0.105066
Max Parameter-Effects 0.130725
95. % Confidence Region 0.562647
If you are using a version prior to 6.0, instead load
Statistics`NonlinearFit` and flip the parameter and variable arguments
in NonlinearRegress.
Darren Glosemeyer
Wolfram Research
- References:
- Asking NonlinearRegression
- From: Navri Navri Bintang <navri_bintang@yahoo.com>
- Asking NonlinearRegression