MathGroup Archive 1997

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

Search the Archive

AW: Questions on fitting and plotting data

  • To: mathgroup at
  • Subject: [mg7969] AW: [mg7952] Questions on fitting and plotting data
  • From: Buttgereit <Buttgereit at>
  • Date: Wed, 30 Jul 1997 02:37:36 -0400
  • Sender: owner-wri-mathgroup at

Hi Daniel,

what you have seems to be a list of mean values (as you have SD or SEM). =
you want to fit a line to your data you should drop the errors before

linefunc=3DFit[ Drop[#,-1]&/@yourData, {1,x}, x]

will drop the last element in each row (that is: the error) returning the=

equation of the line fit to your data. The information on the error of ea=
point is not taken into account.

You can see your fit result with the data using this:

Plot[ linefunc, {x, 0,10}, Prolog->First[ plot1 ] ]

First[ plot1 ] extracts the graphics primitives from the graphics object
you have created with ErrorListPlot[ ... ]. Prolog will prepend these
primitives to the list of primitives created by linefunc so they will be
shown together in the graphics created by Plot[ ... ].

This should be what you intend at the moment...

You can find information on this topic in the information package of the
Statistics`LinearRegression` Package (provided you have Mathematica V. 3 =
for V. 2.2 I think you will need the "Guide to Standard Mathematica
Packages" available by Wolfram Research). =

If you want the available responses (which are averaged in your present
data) to be taken into account, you will find a solution here, too:
Regress[ ] is able to use multiple responses.
Note that you have to read in the Package: =


Good luck,

>Subject: [mg7969] [mg7952] Questions on fitting and plotting data

I am *very* low on the Mma learning curve so this may be obvious, but
here is what I am trying to do.  I have a set of data that I want to
plot, fit, and then plot the fit over it.  The problem I am having is
getting the correct fit and getting it to plot.  Here is what I have so

t2 =3D {{1, 1.5, .5}, {2.3, 2.8, .5}, {3, 3.7, .5}, {4.2, 4.6, .5},
  {5.1, 5, .5}, {6.4, 6.4, .5}, {7.2, 7.7, .5}, {8, 8.9, .5}}


plot1 =3D ErrorListPlot[t2]

**now, here is where I start getting the problems - this is obviously
NOT the correct least-square fit solution to the data I have

fit1 =3D Fit[t2, {1, x }, {x, y}]
Out[40] =3D
0.5-5.55112x10^-17 x

Plot [fit1, {x, 0, 10}]

Show [%,  plot1]

Any help will be greatly appreciated.  Many thanks

daniel l. goscha
dgoscha at

  • Prev by Date: Re: Wrong behavior of CrossProduct
  • Next by Date: Re: subscripts in function definitions
  • Previous by thread: Button Palette MMA 3.0
  • Next by thread: Printing problems