Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Automate datafitting to a series of parameterized function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70306] Re: [mg70277] Automate datafitting to a series of parameterized function
  • From: "Peng Yu" <pengyu.ut at gmail.com>
  • Date: Thu, 12 Oct 2006 05:37:37 -0400 (EDT)
  • References: <200610110553.BAA19424@smc.vnet.net> <452D0E8E.8000102@wolfram.com>

On 10/11/06, Darren Glosemeyer <darreng at wolfram.com> wrote:
> The model is a linear model in the basis functions 1, x, x^2,..., so you
> can use Regress to easily get this information.
>
> This will give the fitted function and residuals for the model with n terms.
>
> << Statistics`LinearRegression`
>
> fittedAndResiduals[n_] := {BestFit, FitResiduals} /. Regress[data,
> x^Range[0, n], x,
>     RegressionReport -> {BestFit, FitResiduals} ];
>
>
> The mentioned results for a constant model can then be computed directly
> as follows, and for higher order models by choosing the appropriate
> value of n.
>
> res0 = fittedAndResiduals[0];
> error0 = res0[[2]]^2;
> avererror0 = Total[error0]/Length[data]
> maxerror = Max[error0]
>
>
> If there is a maximum power for the terms, say 5, that you wish to
> allow, results for all those models could be obtained as follows.
>
> Table[Block[{res = fittedAndResiduals[n], error},
>       error = res[[2]]^2;
>       {res[[1]], Total[error]/Length[data], Max[error]}], {n, 0, 5}]
>
>
> Other diagnostics could also be obtained from Regress or computed from
> results obtained from Regress if desired.

Thank you for your reply. I gave an linear fitting example because I
just want to describe the problem simply. But that doesn't mean my
real problem can be reduced to a linear fitting problem.

Is there any way to solve the nonlinear fit problem?

Thanks,
Peng


  • Prev by Date: Re: Re: Copy input and User Defined Variables
  • Next by Date: Re: convergence checking
  • Previous by thread: Automate datafitting to a series of parameterized function
  • Next by thread: Re: Automate datafitting to a series of parameterized function