       AW: Questions on fitting and plotting data

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

```Hi Daniel,

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

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=
ch
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: =

<<Statistics`LinearRegression`

Good luck,
Peter

----------
>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
far...

In:=3D
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}}
Out=3D
{{1,1.5,0.5},{2.3,2.8,0.5},{3,3.7,0.5},{4.2,4.6,0.5},{5.1,5,0.5},{6.4,6.4=
,

0.5},{7.2,7.7,0.5},{8,8.9,0.5}}

In:=3D
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
specified.**

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

In:=3D
Plot [fit1, {x, 0, 10}]

In:=3D
Show [%,  plot1]

Any help will be greatly appreciated.  Many thanks

-daniel
--------------------
daniel l. goscha
dgoscha at phy.ilstu.edu
<*>

```

• 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