Re: Curve Fitting

• To: mathgroup at smc.vnet.net
• Subject: [mg6452] Re: [mg6433] Curve Fitting
• From: jason at pernet.com (jason welter)
• Date: Fri, 21 Mar 1997 22:59:56 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```At 12:52 AM 3/20/97 -0500, you wrote:
>I'm new with Mathematica. Could anyone show me how to obtain the
>equation of the curve fitting graph from a data set? Email is very
>appreciated. Thanks.
>Andy

Yea, just

Fit[data,{1,x},x]

where "data" is a list of numbers, "{1,x}" are the fitting parameters
and "x" is the variable you want to use.  But this is all in your book
and you can read it on your own.  If you want to get more complicated
with multivariate fitting and statistical analysis then look at the
following example I used when I was doing my thesis work:

<<"Statistics\\LinearRegression"

Note that "data" is an list of lists that look like:

data={{1,1,1,1,1,1,1,.9876},
{1,1,1,1,1,1,2,.8765},
{1,1,1,1,1,2,1,.7654},
...}

Where the first column represents the variable "gpm", the second "gpw"
and so on until the list of variables "{gpm,gpw,pw,gpo,x,y,date}" is
fully accounted for.

The list: "{gpm,gpm^2,gpm^3,gpm^4,gpm^5,gpw,gpw^2,pw,pw^2,gpo,
gpo^2,gpo^3,gpo^4,gpo^5,gpo^6}" are the variables and their powers I
want to fit to the data.

All the other stuff is used for statistical analysis.  Just type equation
for the equation, CovMatrix for the Covariance Matrix etc.

output = Regress[data,{gpm,gpm^2,gpm^3,gpm^4,gpm^5,gpw,gpw^2,pw,pw^2,gpo,
gpo^2,gpo^3,gpo^4,gpo^5,gpo^6},{gpm,gpw,pw,gpo,x,y,date},
OutputControl->NoPrint,OutputList->{ParameterTable,
ANOVATable,FitResiduals,PredictedResponse,RSquared,CorrelationMatrix,
CovarianceMatrix,CorrelationMatrix,BestFit}];
residuals = FitResiduals /. output;
response = PredictedResponse /. output;
param = ParameterTable /. output;
anova = ANOVATable /. output;
n = Length[residuals];
equation = BestFit /. output;
R2 = Apply[Plus,(FitResiduals /. output)^2];
CovMatrix = CovarianceMatrix /. output;
CorMatrix = CorrelationMatrix /. output;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/| ________Ec  My message to you is:  Be courageous!  I have
/ |/________Ei  lived a long time.  I have seen history repeat
Vg------| |/--------Ef  itself again and again.  I have seen many
| | ________Ev  depressions in business.  Always America
Ef------| |/            has come out stronger and more prosperous.
Be as brave as your fathers before you.
Have faith!  Go forward.
Jason Welter                                 --- Thomas A. Edison's
jason at pernet.com                                 last public mesage.

```

• Prev by Date: Re: Discontinuity
• Next by Date: Reading data from web pages
• Previous by thread: Re: Curve Fitting
• Next by thread: Fourier Help!!