Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9815
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: FindFit and squared residuals |
| Date | 2012-04-26 09:34 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jnb4ru$5ku$1@smc.vnet.net> (permalink) |
| References | <jn7v77$6g8$1@smc.vnet.net> |
On Apr 24, 9:40 pm, leigh pascoe <le...@evry.inserm.fr> wrote:
> Is there a command to get the sum of the squared residuals after using
> FindFit?
>
> Here is an example that fits a function and then plots the data and the
> fitted function
>
> inc1[x_, M_, \[Tau]_, \[Phi]_] :=
> M/\[Tau] \[Phi]^M E^(-(x/\[Tau])) (1 - E^(-(x/\[Tau])))^(M - 1)
>
> franceMaleCDdata19882005 = {{2.5,
> 0}, {7.5, .000008}, {12.5, .00004}, {17.5, .00012}, {22.5, \
> .000142}, {27.5, .00012}, {32.5, .000084}, {37.5,
> 0.000060}, {42.5, .000050}, {47.5, .000046}, {52.5, .000039}, \
> {57.5, 0.000043}, {62.5, .000022}, {67.5, .000026}, {72.5, .000016}, \
> {77.5, 0.000019}, {82.5, .000015}, {87.5, .000017}};
> franceMaleCDdata19882005plot =
> ListPlot[franceMaleCDdata19882005,
> PlotStyle -> {Red, Dashed, Thick}, PlotRange -> All,
> Joined -> True];
> franceMaleCDdata19882005fit =
> FindFit[franceMaleCDdata19882005,
> inc1[x, M, \[Tau], \[Phi]], {{M, 10}, {\[Tau], 5}, {\[Phi], .6}}, x]
> Show[Plot[
> inc1[x, M, \[Tau], \[Phi]] /. franceMaleCDdata19882005fit, {x, 0,
> 85}, PlotRange -> All], franceMaleCDdata19882005plot]
>
> What is the minimised value of the squared residuals in this case? I
> would like to compare the fit with the more complex function shown below
> (the fit is obviously better, but with more parameters used}.
>
> inc4[x_, N1_, N2_, \[Tau]1_, \[Tau]2_, \[Phi]_] := (
> E^(-(x/\[Tau]1)) (1 - E^(-(x/\[Tau]1)))^(-1 +
> N1) (1 - E^(-(x/\[Tau]2)))^N2 N1 \[Phi]^(N1 + N2))/\[Tau]1 + (
> E^(-(x/\[Tau]2)) (1 - E^(-(x/\[Tau]1)))^
> N1 (1 - E^(-(x/\[Tau]2)))^(-1 + N2) N2 \[Phi]^(N1 + N2))/\[Tau]2
>
> franceMaleCDdata19882005fit =
> FindFit[franceMaleCDdata19882005,
> inc4[x, N1,
> N2, \[Tau]1, \[Tau]2, \[Phi]], {{N1, 8}, {N2, 2}, {\[Tau]1,
> 7}, {\[Tau]2, 23}, {\[Phi], .6}}, x]
> Show[Plot[
> inc4[x, N1, N2, \[Tau]1, \[Tau]2, \[Phi]] /.
> franceMaleCDdata19882005fit, {x, 0, 85},
> PlotRange -> All], franceMaleCDdata19882005plot]
>
> Thanks for any help.
>
> Leigh
franceMaleCDdata19882005fit1 = FindFit[franceMaleCDdata19882005,
inc1[x, M, \[Tau], \[Phi]], {{M, 10}, {\[Tau], 5}, {\[Phi], .6}}, x]
{M -> 6.57389, \[Tau] -> 12.5364, \[Phi] -> 0.431395}
rss1 = #.#&[#2 - inc1[#1, M, \[Tau], \[Phi]] /. % &
@@@ franceMaleCDdata19882005]
3.24064*^-9
franceMaleCDdata19882005fit4 = FindFit[franceMaleCDdata19882005,
inc4[x, N1, N2, \[Tau]1, \[Tau]2, \[Phi]], {{N1, 8}, {N2, 2},
{\[Tau]1, 7}, {\[Tau]2, 23}, {\[Phi], .6}}, x]
{N1 -> 22.378, N2 -> 1.10261, \[Tau]1 -> 5.88081, \[Tau]2 -> 40.3166,
\[Phi] -> 0.797117}
rms4 = #.#&[#2 - inc4[#1, N1, N2, \[Tau]1, \[Tau]2, \[Phi]] /. % &
@@@ franceMaleCDdata19882005]
3.31283*^-10
rss1/rss4
9.78209
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
FindFit and squared residuals leigh pascoe <leigh@evry.inserm.fr> - 2012-04-25 04:40 +0000 Re: FindFit and squared residuals Ray Koopman <koopman@sfu.ca> - 2012-04-26 09:34 +0000
csiph-web