Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: naive question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92838] Re: naive question
  • From: annetts729 <davidannetts at aapt.net.au>
  • Date: Tue, 14 Oct 2008 05:00:35 -0400 (EDT)
  • References: <gcv7ku$e63$1@smc.vnet.net>

Hi Francisco

> I am using Fit within a function, and I want it to produce only a list of
>  coefficients, without the variables.
> For example, if I plug into fit the following: Fit[{{1,2,3},{4,5,6},{7,8,=
9}},{1,x1,x2},{x1,x2}],
> Mathematica produces:
> 1.55556+0.555556 x1+0.444444 x2
>
> I want to get only the following list:
> {1.55556,0.555556,0.444444}
>
> It seem awfully simple, but I haven't managed.
> How can I do it?

One particularly ugly method is suggested after TreeFrom and I
wouldn't recommend using

res = Fit[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {1, x1, x2}, {x1, x2}]
 {res[[1]], res[[2, 1]], res[[3, 1]]}

You can easily extract what you're after after loading
LinearRegression`

Needs["LinearRegression`"]
BestFitParameters /.
 Quiet@Regress[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {1, x1, x2}, {x1,
    x2}, RegressionReport -> {BestFitParameters}]

Regards,

Dave.


  • Prev by Date: Re: Easiest Mathematica algorhitm needed
  • Next by Date: Re: naive question
  • Previous by thread: Re: naive question
  • Next by thread: Re: naive question