Nonlinear fit
- To: mathgroup at smc.vnet.net
- Subject: [mg41096] Nonlinear fit
- From: "Gustavo Seabra" <seabra at ksu.edu>
- Date: Fri, 2 May 2003 03:59:34 -0400 (EDT)
- Organization: Kansas State University
- Sender: owner-wri-mathgroup at wolfram.com
Hi all,
I am trying to make a nonlinear fit to a function (f[x]) that is defined
differently for different intervals, something like (it's abbreviated here,
to give just the idea):
f[x_]:=g[x+a]/;x>k
f[x_]:=g[x+b]/;x<=k
I know the function is ok because, if I set the parameters, I can plot it
with no problem:
Plot[f[x]./{p1->p1_initial_value,p2->p2_initial_value,...},{x,x1,x2}]
However, if I try to fit a data set to this function with NonlinearRegress
or NonlinearFit:
NonlinearFit[data,f[x],x,{p1,p2,...}]
I get:
"NonlinearFit::nonum :
The model is not numerical at {p1->value,p2->value...,x->value}. Check
that all model parameters are included in the parameter list."
Now, I'm sure I included all parameters. As I said, if I try to plot
f[x], even with the parameters from this answer, it works fine. Also, if i
use a different f[x], defined the same for all x, all works fine. Any
suggestion on what am I doing wrong?
Thanks a lot,
Gustavo Seabra.
P.S. If anyone needs more detail, I can provide the notebook with everything
in it. I just didn't want to post it here to avoid too long a post.
- Follow-Ups:
- RE: Nonlinear fit
- From: "Yahoo" <stefanofricano@yahoo.it>
- RE: Nonlinear fit