MathGroup Archive 1997

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

Search the Archive

Re: Curve Fitting

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

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.

Yea, just


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:

Read in the LinearRegression package:


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


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,
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                                 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!!